all the prepared mini meterbus client stuff
This commit is contained in:
33
src/uart.cpp
33
src/uart.cpp
@ -40,30 +40,23 @@ void uartInit() {
|
||||
UCA0CTL1 &= ~UCSWRST;
|
||||
|
||||
IE2 |= UCA0RXIE;
|
||||
|
||||
|
||||
// FILE *mystdout = fdevopen(uartPutchar, NULL);
|
||||
// stdout = mystdout;
|
||||
}
|
||||
|
||||
inline void _realUartTx() {
|
||||
if ((IFG2 | UCA0TXIE) != 0) {
|
||||
if (txBufferReadIdx != txBufferWriteIdx) {
|
||||
UCA0TXBUF = txBuffer[txBufferReadIdx];
|
||||
txBufferReadIdx++;
|
||||
if (txBufferReadIdx > UART_TX_BUFFER_SIZE) {
|
||||
txBufferReadIdx = 0;
|
||||
}
|
||||
} else {
|
||||
disableDataRegisterEmptyInterrupt();
|
||||
}
|
||||
}
|
||||
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 0
|
||||
UCA0TXBUF = o;
|
||||
#else
|
||||
if (txBufferWriteIdx == (UART_TX_BUFFER_SIZE - 1)) {
|
||||
while (txBufferReadIdx == UART_TX_BUFFER_SIZE);
|
||||
} else {
|
||||
@ -78,8 +71,6 @@ void uartWrite(uint8_t o) {
|
||||
}
|
||||
|
||||
enableDataRegisterEmptyInterrupt();
|
||||
// _realUartTx();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +84,7 @@ void uartWrite(uint8_t o) {
|
||||
|
||||
|
||||
ISR(USCIAB0TX, UART_TX_ISR) {
|
||||
_realUartTx();
|
||||
_realUartTx();
|
||||
}
|
||||
|
||||
ISR(USCIAB0RX, UART_RX_ISR) {
|
||||
|
Reference in New Issue
Block a user