39 #include "dev/uart1.h"
40 #include "dev/watchdog.h"
41 #include "isr_compat.h"
43 static int (*uart1_input_handler)(
unsigned char c);
45 static volatile uint8_t transmitting;
51 return (UCA1STAT & UCBUSY) | transmitting;
55 uart1_set_input(
int (*input)(
unsigned char c))
57 uart1_input_handler = input;
61 uart1_writeb(
unsigned char c)
65 while((UCA1STAT & UCBUSY));
76 uart1_init(
unsigned long ubr)
82 ubr = (MSP430_CPU_SPEED / ubr);
84 UCA1BR1 = (ubr >> 8) & 0xff;
103 UCA1CTL1 &= ~UCSWRST;
107 ISR(USCI_A1, uart1_rx_interrupt)
111 ENERGEST_ON(ENERGEST_TYPE_IRQ);
113 if(UCA1STAT & UCRXERR) {
117 if(uart1_input_handler !=
NULL) {
118 if(uart1_input_handler(c)) {
124 ENERGEST_OFF(ENERGEST_TYPE_IRQ);