39 #include "dev/uart1.h"
40 #include "dev/watchdog.h"
41 #include "isr_compat.h"
43 static int (*uart1_input_handler)(
unsigned char c);
47 #ifdef UART1_CONF_RX_WITH_DMA
48 #define RX_WITH_DMA UART1_CONF_RX_WITH_DMA
56 static uint8_t
rxbuf[RXBUFSIZE];
57 static uint16_t last_size;
58 static struct ctimer rxdma_timer;
61 handle_rxdma_timer(
void *ptr)
65 while(last_size != size) {
66 uart1_input_handler((
unsigned char)
rxbuf[RXBUFSIZE - last_size]);
69 last_size = RXBUFSIZE;
85 uart1_set_input(
int (*
input)(
unsigned char c))
90 uart1_input_handler =
input;
94 uart1_writeb(
unsigned char c)
98 while((UCA1STAT & UCBUSY));
113 UCA1CTL1 |= UCSSEL_2;
115 ubr = (MSP430_CPU_SPEED / ubr);
116 UCA1BR0 = ubr & 0xff;
117 UCA1BR1 = (ubr >> 8) & 0xff;
123 P5SEL |= BIT6 | BIT7;
136 UCA1CTL1 &= ~UCSWRST;
142 DMACTL0 = DMA0TSEL_20;
145 DMA0SA = (
unsigned int)&UCA1RXBUF;
146 DMA0DA = (
unsigned int)&
rxbuf;
148 last_size = RXBUFSIZE;
149 DMA0CTL = DMADT_4 + DMASBDB + DMADSTINCR_3 + DMAEN + DMAREQ;
151 msp430_add_lpm_req(MSP430_REQUIRE_LPM1);
156 ISR(USCI_A1, uart1_rx_interrupt)
160 ENERGEST_ON(ENERGEST_TYPE_IRQ);
162 if(UCA1STAT & UCRXERR) {
166 if(uart1_input_handler !=
NULL) {
167 if(uart1_input_handler(c)) {
173 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
static void input(void)
Process a received 6lowpan packet.
Header file for the energy estimation mechanism
#define NULL
The null pointer.
static uint8_t transmitting(void)
Check the RF's TX status.
void watchdog_periodic(void)
Writes the WDT clear sequence.
#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 ctimer_reset(struct ctimer *c)
Reset a callback timer with the same interval as was previously set.
tcirc_buf rxbuf
The RX circular buffer, for storing characters from serial port.