38 #include "dev/uart1.h"
39 #include "dev/watchdog.h"
43 static int (*uart1_input_handler)(
unsigned char c);
45 static volatile uint8_t transmitting;
47 #ifdef UART1_CONF_TX_WITH_INTERRUPT
48 #define TX_WITH_INTERRUPT UART1_CONF_TX_WITH_INTERRUPT
50 #define TX_WITH_INTERRUPT 1
57 static uint8_t txbuf_data[TXBUFSIZE];
64 return (UCA0STAT & UCBUSY) | transmitting;
68 uart1_set_input(
int (*input)(
unsigned char c))
70 uart1_input_handler = input;
74 uart1_writeb(
unsigned char c)
86 if(transmitting == 0) {
94 while(!(IFG2 & UCA0TXIFG));
109 uart1_init(
unsigned long ubr)
113 UCA0CTL1 |= UCSSEL_2;
117 UCA0CTL1 &= ~UCSWRST;
123 interrupt(USCIAB1RX_VECTOR)
124 uart1_rx_interrupt(
void)
127 ENERGEST_ON(ENERGEST_TYPE_IRQ);
130 if(UCA0STAT & UCRXERR) {
134 if(uart1_input_handler !=
NULL) {
135 if(uart1_input_handler(c)) {
140 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
143 #if TX_WITH_INTERRUPT
144 interrupt(USCIAB1TX_VECTOR)
145 uart1_tx_interrupt(
void)
147 ENERGEST_ON(ENERGEST_TYPE_IRQ);
148 if(IFG2 & UCA0TXIFG) {
156 ENERGEST_OFF(ENERGEST_TYPE_IRQ);