2026 sim: drive the Unity simulation with the real remote over the radio
Dongle (app):
- bridge mode: stands in for the robot's radio (ch 96 / 250k / HXPD1,
auto-ack, dynamic payloads, ack payloads). Received packets go to the PC
as A5-framed 'R' frames; the PC's 'A' frames become the ack payload of
the next packet, like robot/Comms.cpp; dropped after ~0.5 s without a
refresh. 'S' status once a second.
- USART RX through circular DMA into a ring buffer, overrun stall
disabled, error flags cleared: a burst (e.g. SignalRGB probing the port)
used to deafen the app until a replug.
- RX test mode ('x') accepts protocol v4's dynamic-length packets.
- safeboot_flash.py --knock: keeps knocking across a replug to catch
safeboot's cold-boot window when the app doesn't answer.
Unity:
- SimRemote sources: Keyboard, or the real remote via the dongle
(DongleLink.cs: kernel32 serial, auto-finds the CH340, all port I/O on
one background thread). Packets go into the firmware byte for byte, the
robot's telemetry goes back on the ack, so the remote's display shows
the sim. Tested end to end with the real remote.
- Dropped the USB joystick and robot-serial-harness inputs and the old
Serial/Serial2/Serial3/HandleHoystick scripts (and their components in
Main.unity): no USB links to remote or robot any more.
- Test panel: dongle status; no sideways scroll bar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b3b2629cd
commit
2b4750f8f4
24 files changed
+682
-710
No files matched your search
@@ -36,6 +36,7 @@
|
||||
#define USART1_CR1 REG(0x40013800)
|
||||
#define USART1_BRR REG(0x4001380C)
|
||||
#define USART1_ISR REG(0x4001381C)
|
||||
#define USART1_ICR REG(0x40013820)
|
||||
#define USART1_RDR REG(0x40013824)
|
||||
#define USART1_TDR REG(0x40013828)
|
||||
/* SysTick */
|
||||
@@ -65,14 +66,22 @@ static inline void uart_putc(char c)
|
||||
USART1_TDR = (uint8_t)c;
|
||||
}
|
||||
static inline void uart_puts(const char *s) { while (*s) uart_putc(*s++); }
|
||||
/* Clear overrun / noise / framing / parity errors. While ORE is set the USART
|
||||
* stops moving new bytes into RDR, so one burst the app didn't read in time
|
||||
* (e.g. SignalRGB probing the COM port) used to deafen it until a replug. */
|
||||
static inline void uart_clear_errors(void)
|
||||
{
|
||||
if (USART1_ISR & 0x0Fu) USART1_ICR = 0x0Fu; /* ORECF NCF FECF PECF */
|
||||
}
|
||||
static inline int uart_getc(void) /* non-blocking, -1 if none */
|
||||
{
|
||||
uart_clear_errors();
|
||||
if (USART1_ISR & (1u << 5)) return (uint8_t)USART1_RDR;
|
||||
return -1;
|
||||
}
|
||||
static inline uint8_t uart_getc_block(void)
|
||||
{
|
||||
while (!(USART1_ISR & (1u << 5))) {}
|
||||
while (!(USART1_ISR & (1u << 5))) uart_clear_errors();
|
||||
return (uint8_t)USART1_RDR;
|
||||
}
|
||||
static inline void systick_setup(void) { STK_LOAD = 8000 - 1; STK_VAL = 0; STK_CTRL = 5; }
|
||||
|
||||
Reference in new issue
Block a user