From da110a3be082efdaad3ef09d980e651c7b69f171 Mon Sep 17 00:00:00 2001 From: hg Date: Thu, 5 Jun 2014 22:16:57 +0200 Subject: [PATCH] something wrong with parity --- src/uart.cpp | 27 ++++++++++++--------------- src/uart.h | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/uart.cpp b/src/uart.cpp index d9dbf2d..c4af638 100644 --- a/src/uart.cpp +++ b/src/uart.cpp @@ -42,19 +42,6 @@ void uartInit() { IE2 |= UCA0RXIE; } -inline void _realUartTx() { - if ((IFG2 | UCA0TXIE) != 0) { - if (txBufferReadIdx != txBufferWriteIdx) { - UCA0TXBUF = txBuffer[txBufferReadIdx]; - txBufferReadIdx++; - if (txBufferReadIdx > UART_TX_BUFFER_SIZE) { - txBufferReadIdx = 0; - } - } else { - disableDataRegisterEmptyInterrupt(); - } - } -} void uartWrite(uint8_t o) { if (txBufferWriteIdx == (UART_TX_BUFFER_SIZE - 1)) { @@ -84,11 +71,21 @@ void uartWrite(uint8_t o) { ISR(USCIAB0TX, UART_TX_ISR) { - _realUartTx(); + if ((IFG2 & UCA0TXIE) != 0) { + if (txBufferReadIdx != txBufferWriteIdx) { + UCA0TXBUF = txBuffer[txBufferReadIdx]; + txBufferReadIdx++; + if (txBufferReadIdx > UART_TX_BUFFER_SIZE) { + txBufferReadIdx = 0; + } + } else { + disableDataRegisterEmptyInterrupt(); + } + } } ISR(USCIAB0RX, UART_RX_ISR) { - if ((IFG2 | UCA0RXIE) != 0) { + while ((IFG2 & UCA0RXIE) != 0) { if (rxBufferWriteIdx == UART_RX_BUFFER_SIZE - 1) { if (rxBufferReadIdx == UART_RX_BUFFER_SIZE) { // rx buffer overflow diff --git a/src/uart.h b/src/uart.h index 185b9b2..4e361d5 100644 --- a/src/uart.h +++ b/src/uart.h @@ -7,7 +7,7 @@ #define UART_TX_BUFFER_SIZE 32 -#define UART_RX_BUFFER_SIZE 32 +#define UART_RX_BUFFER_SIZE 16 void uartInit();