38 #include "dev/uart1.h" 39 #include "dev/watchdog.h" 40 #include "isr_compat.h" 42 static int (*uart1_input_handler)(
unsigned char c);
46 #ifdef UART1_CONF_RX_WITH_DMA 47 #define RX_WITH_DMA UART1_CONF_RX_WITH_DMA 55 static uint8_t rxbuf[RXBUFSIZE];
56 static uint16_t last_size;
57 static struct ctimer rxdma_timer;
60 handle_rxdma_timer(
void *ptr)
64 while(last_size != size) {
65 uart1_input_handler((
unsigned char)rxbuf[RXBUFSIZE - last_size]);
68 last_size = RXBUFSIZE;
84 uart1_set_input(
int (*
input)(
unsigned char c))
89 uart1_input_handler =
input;
93 uart1_writeb(
unsigned char c)
97 while((UCA1STAT & UCBUSY));
112 UCA1CTL1 |= UCSSEL_2;
114 ubr = (MSP430_CPU_SPEED / ubr);
115 UCA1BR0 = ubr & 0xff;
116 UCA1BR1 = (ubr >> 8) & 0xff;
122 P5SEL |= BIT6 | BIT7;
135 UCA1CTL1 &= ~UCSWRST;
141 DMACTL0 = DMA0TSEL_20;
144 DMA0SA = (
unsigned int)&UCA1RXBUF;
145 DMA0DA = (
unsigned int)&rxbuf;
147 last_size = RXBUFSIZE;
148 DMA0CTL = DMADT_4 + DMASBDB + DMADSTINCR_3 + DMAEN + DMAREQ;
150 msp430_add_lpm_req(MSP430_REQUIRE_LPM1);
155 ISR(USCI_A1, uart1_rx_interrupt)
160 if(UCA1STAT & UCRXERR) {
164 if(uart1_input_handler != NULL) {
165 if(uart1_input_handler(c)) {
static uint8_t transmitting(void)
Check the RF's TX status.
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
void ctimer_reset(struct ctimer *c)
Reset a callback timer with the same interval as was previously set.
#define CLOCK_SECOND
A second, measured in system clock time.
void ctimer_set(struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr)
Set a callback timer.
void watchdog_periodic(void)
Writes the WDT clear sequence.
static void input(void)
Process a received 6lowpan packet.