something wrong with parity
This commit is contained in:
parent
462cc9d424
commit
da110a3be0
27
src/uart.cpp
27
src/uart.cpp
@ -42,19 +42,6 @@ void uartInit() {
|
|||||||
IE2 |= UCA0RXIE;
|
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) {
|
void uartWrite(uint8_t o) {
|
||||||
if (txBufferWriteIdx == (UART_TX_BUFFER_SIZE - 1)) {
|
if (txBufferWriteIdx == (UART_TX_BUFFER_SIZE - 1)) {
|
||||||
@ -84,11 +71,21 @@ void uartWrite(uint8_t o) {
|
|||||||
|
|
||||||
|
|
||||||
ISR(USCIAB0TX, UART_TX_ISR) {
|
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) {
|
ISR(USCIAB0RX, UART_RX_ISR) {
|
||||||
if ((IFG2 | UCA0RXIE) != 0) {
|
while ((IFG2 & UCA0RXIE) != 0) {
|
||||||
if (rxBufferWriteIdx == UART_RX_BUFFER_SIZE - 1) {
|
if (rxBufferWriteIdx == UART_RX_BUFFER_SIZE - 1) {
|
||||||
if (rxBufferReadIdx == UART_RX_BUFFER_SIZE) {
|
if (rxBufferReadIdx == UART_RX_BUFFER_SIZE) {
|
||||||
// rx buffer overflow
|
// rx buffer overflow
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define UART_TX_BUFFER_SIZE 32
|
#define UART_TX_BUFFER_SIZE 32
|
||||||
#define UART_RX_BUFFER_SIZE 32
|
#define UART_RX_BUFFER_SIZE 16
|
||||||
|
|
||||||
|
|
||||||
void uartInit();
|
void uartInit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user