diff options
author | px4dev <px4@purgatory.org> | 2013-07-04 23:22:59 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-07-04 23:22:59 -0700 |
commit | 83213c66df27e41d5941ff21a4249df3f6f5f45e (patch) | |
tree | e2cff84844d0b3b3501071925212e82623a451f6 /src | |
parent | 94b638d848a62312a9cd6722779965d211565d3c (diff) | |
download | px4-firmware-83213c66df27e41d5941ff21a4249df3f6f5f45e.tar.gz px4-firmware-83213c66df27e41d5941ff21a4249df3f6f5f45e.tar.bz2 px4-firmware-83213c66df27e41d5941ff21a4249df3f6f5f45e.zip |
Reset the PX4IO rx DMA if we haven't seen any traffic in a while; this gets us back into sync.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/px4iofirmware/serial.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/modules/px4iofirmware/serial.c b/src/modules/px4iofirmware/serial.c index 93cff26c2..4eef99d9f 100644 --- a/src/modules/px4iofirmware/serial.c +++ b/src/modules/px4iofirmware/serial.c @@ -73,6 +73,9 @@ static DMA_HANDLE rx_dma; static int serial_interrupt(int irq, void *context); static void dma_reset(void); +/* if we spend this many ticks idle, reset the DMA */ +static unsigned idle_ticks; + #define MAX_RW_REGS 32 // by agreement w/FMU #pragma pack(push, 1) @@ -160,6 +163,10 @@ void interface_tick() { /* XXX look for stuck/damaged DMA and reset? */ + if (idle_ticks++ > 100) { + dma_reset(); + idle_ticks = 0; + } } static void @@ -175,6 +182,7 @@ rx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg) /* we just received a request; sort out what to do */ rCR3 &= ~USART_CR3_DMAR; + idle_ticks = 0; /* work out how big the packet actually is */ //unsigned rx_length = sizeof(IOPacket) - stm32_dmaresidual(rx_dma); |