From a454f06bf82ce4d036e4f9d1379a39247631bd61 Mon Sep 17 00:00:00 2001 From: peabody124 Date: Tue, 23 Nov 2010 17:13:48 +0000 Subject: [PATCH] OP-203 PIOS_UART: Tweaked the way the interrupts are reenabled to get comms stable again git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2143 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PiOS/STM32F10x/pios_usart.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flight/PiOS/STM32F10x/pios_usart.c b/flight/PiOS/STM32F10x/pios_usart.c index 00c8dd7f8..7745f2ad4 100644 --- a/flight/PiOS/STM32F10x/pios_usart.c +++ b/flight/PiOS/STM32F10x/pios_usart.c @@ -202,7 +202,7 @@ int32_t PIOS_USART_RxBufferGet(uint8_t usart) return -2; } - if (!fifoBuf_getUsed(&usart_dev->rx)) { + if (fifoBuf_getUsed(&usart_dev->rx) == 0) { /* Nothing new in the buffer */ return -1; } @@ -395,12 +395,11 @@ int32_t PIOS_USART_TxBufferPutMoreNonBlocking(uint8_t usart, const uint8_t * buf /* Copy bytes to be transmitted into transmit buffer */ /* This operation should be atomic! */ PIOS_IRQ_Disable(); + uint16_t used = fifoBuf_getUsed(&usart_dev->tx); fifoBuf_putData(&usart_dev->tx,buffer,len); - - if (fifoBuf_getUsed(&usart_dev->tx) == len) { - /* Buffer has just become non-empty, enable tx interrupt. */ + + if(used == 0) /* enable sending when was empty */ USART_ITConfig(usart_dev->cfg->regs, USART_IT_TXE, ENABLE); - } PIOS_IRQ_Enable(); /* No error */