works
This commit is contained in:
parent
2a621fbaf9
commit
b4c4cd44a3
@ -46,7 +46,7 @@ int main() {
|
|||||||
uartWrite('W');
|
uartWrite('W');
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
__bis_status_register(LPM0_bits);
|
// __bis_status_register(LPM0_bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
src/uart.cpp
35
src/uart.cpp
@ -27,6 +27,9 @@ static inline void disableDataRegisterEmptyInterrupt() {
|
|||||||
void uartInit() {
|
void uartInit() {
|
||||||
UCA0CTL1 |= UCSWRST;
|
UCA0CTL1 |= UCSWRST;
|
||||||
|
|
||||||
|
P1SEL = BIT1 + BIT2;
|
||||||
|
P1SEL2 = BIT1 + BIT2;
|
||||||
|
|
||||||
UCA0CTL1 |= UCSSEL0; // ACLK
|
UCA0CTL1 |= UCSSEL0; // ACLK
|
||||||
|
|
||||||
UCA0BR0 = 13;
|
UCA0BR0 = 13;
|
||||||
@ -43,7 +46,24 @@ void uartInit() {
|
|||||||
// stdout = mystdout;
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void uartWrite(uint8_t o) {
|
void uartWrite(uint8_t o) {
|
||||||
|
#if 0
|
||||||
|
UCA0TXBUF = o;
|
||||||
|
#else
|
||||||
if (txBufferWriteIdx == (UART_TX_BUFFER_SIZE - 1)) {
|
if (txBufferWriteIdx == (UART_TX_BUFFER_SIZE - 1)) {
|
||||||
while (txBufferReadIdx == UART_TX_BUFFER_SIZE);
|
while (txBufferReadIdx == UART_TX_BUFFER_SIZE);
|
||||||
} else {
|
} else {
|
||||||
@ -58,6 +78,8 @@ void uartWrite(uint8_t o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enableDataRegisterEmptyInterrupt();
|
enableDataRegisterEmptyInterrupt();
|
||||||
|
_realUartTx();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,18 +91,9 @@ void uartWrite(uint8_t o) {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ISR(USCIAB0TX, UART_TX_ISR) {
|
ISR(USCIAB0TX, UART_TX_ISR) {
|
||||||
if ((IFG2 | UCA0TXIE) != 0) {
|
_realUartTx();
|
||||||
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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user