something wrong with parity

This commit is contained in:
hg 2014-06-05 22:16:57 +02:00
parent 462cc9d424
commit da110a3be0
2 changed files with 13 additions and 16 deletions

View File

@ -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

View File

@ -7,7 +7,7 @@
#define UART_TX_BUFFER_SIZE 32
#define UART_RX_BUFFER_SIZE 32
#define UART_RX_BUFFER_SIZE 16
void uartInit();