59 #ifndef MSB430_UART1_H
60 #define MSB430_UART1_H
62 #define UART_RX RXBUF1
63 #define UART_TX TXBUF1
64 #define UART_RESET_RX() do { U1IFG &= ~URXIFG1; } while(0)
65 #define UART_RESET_RXTX() do { U1IFG &= ~(URXIFG1 | UTXIFG1); } while(0)
66 #define UART_WAIT_RX() while((U1IFG & URXIFG1) == 0) { _NOP(); }
67 #define UART_WAIT_TX() while((U1IFG & UTXIFG1) == 0) { _NOP(); }
68 #define UART_WAIT_TXDONE() while((UTCTL1 & TXEPT) == 0) { _NOP(); }
74 extern volatile unsigned char uart_lockcnt;
80 #define UART_MODE_RS232 (0x00u)
81 #define UART_MODE_SPI (0x01u)
82 #define UART_MODE_DEFAULT UART_MODE_RS232
83 #define UART_NUM_MODES (UART_MODE_SPI + 1)
84 #define UART_MODE_RESET (0xFFu)
87 #define UART_WAIT_LOCK(x) ((uart_mode != x) && (uart_lockcnt))
88 #define UART_MODE_IS(x) (uart_mode == x)
90 typedef int(*uart_handler_t)(
unsigned char);
100 void uart_set_speed(
unsigned,
unsigned,
unsigned,
unsigned);
101 void uart_set_handler(
unsigned, uart_handler_t);
102 int uart_lock(
unsigned);
103 int uart_lock_wait(
unsigned);
104 int uart_unlock(
unsigned);
105 void uart_set_mode(
unsigned);
106 int uart_get_mode(
void);