]> git.karo-electronics.de Git - oswald.git/blobdiff - metawatch/mw_uart.c
Add option for debug UART on digital watch
[oswald.git] / metawatch / mw_uart.c
index 16a1a29a8d26c764e5eade40c72eb96ba2720cf4..a85ce8c063b79e2ee0c5383f4877b915d3ba647d 100644 (file)
@@ -9,19 +9,28 @@
 
 static char UART_RX_CHAR = 0;
 
-#if defined MW_DEVBOARD_V2
+#if defined MW_DEVBOARD_V2 || MW_DEBUG_UART
 
 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;
+                       LPM3_EXIT_ISR();
+                       break;
+               case 4: // TXIFG
+                       break;
+               default:
+                       break;
+       }
 }
 
 void init_debug_uart(void)
@@ -36,7 +45,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 +64,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();