mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
new printf() is too fucking fast, causing DMA buffer overrun in UART transmit. fixed that. Doesn't affect GCC targets.
got rid of more 16bit ints in new pid controller. git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@348 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
76617bc7e4
commit
ab75f221bb
4 changed files with 27 additions and 16 deletions
|
@ -8,10 +8,11 @@
|
|||
|
||||
// Receive buffer, circular DMA
|
||||
volatile uint8_t rxBuffer[UART_BUFFER_SIZE];
|
||||
uint32_t rxDMAPos = 0;
|
||||
volatile uint32_t rxDMAPos = 0;
|
||||
volatile uint8_t txBuffer[UART_BUFFER_SIZE];
|
||||
uint32_t txBufferTail = 0;
|
||||
uint32_t txBufferHead = 0;
|
||||
volatile uint32_t txBufferTail = 0;
|
||||
volatile uint32_t txBufferHead = 0;
|
||||
volatile bool txDMAEmpty = false;
|
||||
|
||||
static void uartTxDMA(void)
|
||||
{
|
||||
|
@ -23,7 +24,7 @@ static void uartTxDMA(void)
|
|||
DMA1_Channel4->CNDTR = UART_BUFFER_SIZE - txBufferTail;
|
||||
txBufferTail = 0;
|
||||
}
|
||||
|
||||
txDMAEmpty = false;
|
||||
DMA_Cmd(DMA1_Channel4, ENABLE);
|
||||
}
|
||||
|
||||
|
@ -34,6 +35,8 @@ void DMA1_Channel4_IRQHandler(void)
|
|||
|
||||
if (txBufferHead != txBufferTail)
|
||||
uartTxDMA();
|
||||
else
|
||||
txDMAEmpty = true;
|
||||
}
|
||||
|
||||
void uartInit(uint32_t speed)
|
||||
|
@ -109,6 +112,11 @@ uint16_t uartAvailable(void)
|
|||
return (DMA_GetCurrDataCounter(DMA1_Channel5) != rxDMAPos) ? true : false;
|
||||
}
|
||||
|
||||
bool uartTransmitDMAEmpty(void)
|
||||
{
|
||||
return txDMAEmpty;
|
||||
}
|
||||
|
||||
bool uartTransmitEmpty(void)
|
||||
{
|
||||
return (txBufferTail == txBufferHead);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue