X-Git-Url: https://git.karo-electronics.de/?p=oswald.git;a=blobdiff_plain;f=metawatch%2Fmw_uart.c;h=79b650e7f73ca46373c476c541f4a3f1b2011850;hp=16a1a29a8d26c764e5eade40c72eb96ba2720cf4;hb=1b5790095c23913d02531727e47b79af3568e0b1;hpb=3e320aaa4175a0ed469581f1dea2eac35b390878 diff --git a/metawatch/mw_uart.c b/metawatch/mw_uart.c index 16a1a29..79b650e 100644 --- a/metawatch/mw_uart.c +++ b/metawatch/mw_uart.c @@ -16,12 +16,20 @@ void debug_uart_tx_char(char c); #pragma vector=USCI_A3_VECTOR __interrupt void UCA_ISR (void) { - /* clear IRQ flag */ - UCA3IFG &= ~UCRXIFG; - UART_RX_CHAR = UCA3RXBUF; - _event_src |= DBG_UART_RCV_EVENT; - /* wake up to handle the received char */ - LPM3_EXIT; + switch (UCA3IV) { + case 2: // RXIFG + /* clear IRQ flag */ + UCA3IFG &= ~UCRXIFG; + UART_RX_CHAR = UCA3RXBUF; + _event_src |= DBG_UART_RCV_EVENT; + /* wake up to handle the received char */ + LPM3_EXIT; + break; + case 4: // TXIFG + break; + default: + break; + } } void init_debug_uart(void) @@ -36,7 +44,7 @@ void init_debug_uart(void) /* 16,000,000 115200 138 7 0 */ UCA3BR0 = 138; - UCA3MCTL = UCBRS_7 + UCBRF_0; + UCA3MCTL = UCBRS_7 | UCBRF_0; /* set P10.4 & P10.5 to UCA function */ P10SEL |= BIT4; @@ -55,6 +63,8 @@ void init_debug_uart(void) void debug_uart_tx_char(const char c) { + while (UCA3STAT & UCBUSY) + nop(); UCA3TXBUF = c; while ((UCA3IFG & UCTXIFG) == 0 ) nop();