forked from Archive/PX4-Autopilot
px4io: fixed the io_reg_{set,get} errors
this fixes the PX4IO state machine to avoid the io errors we were seeing. There are still some open questions with this code, but it now seems to give zero errors, which is an improvement!
This commit is contained in:
parent
0b89051be1
commit
9064f8bf09
|
@ -149,12 +149,6 @@ interface_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
interface_tick()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
reset the I2C bus
|
reset the I2C bus
|
||||||
used to recover from lockups
|
used to recover from lockups
|
||||||
|
|
|
@ -159,9 +159,6 @@ user_start(int argc, char *argv[])
|
||||||
/* start the FMU interface */
|
/* start the FMU interface */
|
||||||
interface_init();
|
interface_init();
|
||||||
|
|
||||||
/* add a performance counter for the interface */
|
|
||||||
perf_counter_t interface_perf = perf_alloc(PC_ELAPSED, "interface");
|
|
||||||
|
|
||||||
/* add a performance counter for mixing */
|
/* add a performance counter for mixing */
|
||||||
perf_counter_t mixer_perf = perf_alloc(PC_ELAPSED, "mix");
|
perf_counter_t mixer_perf = perf_alloc(PC_ELAPSED, "mix");
|
||||||
|
|
||||||
|
@ -203,11 +200,6 @@ user_start(int argc, char *argv[])
|
||||||
/* track the rate at which the loop is running */
|
/* track the rate at which the loop is running */
|
||||||
perf_count(loop_perf);
|
perf_count(loop_perf);
|
||||||
|
|
||||||
/* kick the interface */
|
|
||||||
perf_begin(interface_perf);
|
|
||||||
interface_tick();
|
|
||||||
perf_end(interface_perf);
|
|
||||||
|
|
||||||
/* kick the mixer */
|
/* kick the mixer */
|
||||||
perf_begin(mixer_perf);
|
perf_begin(mixer_perf);
|
||||||
mixer_tick();
|
mixer_tick();
|
||||||
|
@ -218,6 +210,7 @@ user_start(int argc, char *argv[])
|
||||||
controls_tick();
|
controls_tick();
|
||||||
perf_end(controls_perf);
|
perf_end(controls_perf);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* check for debug activity */
|
/* check for debug activity */
|
||||||
show_debug_messages();
|
show_debug_messages();
|
||||||
|
|
||||||
|
@ -234,6 +227,7 @@ user_start(int argc, char *argv[])
|
||||||
(unsigned)minfo.mxordblk);
|
(unsigned)minfo.mxordblk);
|
||||||
last_debug_time = hrt_absolute_time();
|
last_debug_time = hrt_absolute_time();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,6 @@ static DMA_HANDLE rx_dma;
|
||||||
static int serial_interrupt(int irq, void *context);
|
static int serial_interrupt(int irq, void *context);
|
||||||
static void dma_reset(void);
|
static void dma_reset(void);
|
||||||
|
|
||||||
/* if we spend this many ticks idle, reset the DMA */
|
|
||||||
static unsigned idle_ticks;
|
|
||||||
|
|
||||||
static struct IOPacket dma_packet;
|
static struct IOPacket dma_packet;
|
||||||
|
|
||||||
/* serial register accessors */
|
/* serial register accessors */
|
||||||
|
@ -150,16 +147,6 @@ interface_init(void)
|
||||||
debug("serial init");
|
debug("serial init");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
interface_tick()
|
|
||||||
{
|
|
||||||
/* XXX look for stuck/damaged DMA and reset? */
|
|
||||||
if (idle_ticks++ > 100) {
|
|
||||||
dma_reset();
|
|
||||||
idle_ticks = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rx_handle_packet(void)
|
rx_handle_packet(void)
|
||||||
{
|
{
|
||||||
|
@ -230,9 +217,6 @@ rx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg)
|
||||||
/* disable UART DMA */
|
/* disable UART DMA */
|
||||||
rCR3 &= ~(USART_CR3_DMAT | USART_CR3_DMAR);
|
rCR3 &= ~(USART_CR3_DMAT | USART_CR3_DMAR);
|
||||||
|
|
||||||
/* reset the idle counter */
|
|
||||||
idle_ticks = 0;
|
|
||||||
|
|
||||||
/* handle the received packet */
|
/* handle the received packet */
|
||||||
rx_handle_packet();
|
rx_handle_packet();
|
||||||
|
|
||||||
|
@ -308,6 +292,7 @@ serial_interrupt(int irq, void *context)
|
||||||
|
|
||||||
/* it was too short - possibly truncated */
|
/* it was too short - possibly truncated */
|
||||||
perf_count(pc_badidle);
|
perf_count(pc_badidle);
|
||||||
|
dma_reset();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +328,8 @@ dma_reset(void)
|
||||||
sizeof(dma_packet),
|
sizeof(dma_packet),
|
||||||
DMA_CCR_MINC |
|
DMA_CCR_MINC |
|
||||||
DMA_CCR_PSIZE_8BITS |
|
DMA_CCR_PSIZE_8BITS |
|
||||||
DMA_CCR_MSIZE_8BITS);
|
DMA_CCR_MSIZE_8BITS |
|
||||||
|
DMA_CCR_PRIVERYHI);
|
||||||
|
|
||||||
/* start receive DMA ready for the next packet */
|
/* start receive DMA ready for the next packet */
|
||||||
stm32_dmastart(rx_dma, rx_dma_callback, NULL, false);
|
stm32_dmastart(rx_dma, rx_dma_callback, NULL, false);
|
||||||
|
|
Loading…
Reference in New Issue