37#include "dev/watchdog.h"
39#include "isr_compat.h"
41static int (*uart1_input_handler)(
unsigned char c);
43static volatile uint8_t transmitting;
45#ifdef UART1_CONF_TX_WITH_INTERRUPT
46#define TX_WITH_INTERRUPT UART1_CONF_TX_WITH_INTERRUPT
48#define TX_WITH_INTERRUPT 1
55static uint8_t txbuf_data[TXBUFSIZE];
62 return (UCA0STAT & UCBUSY) | transmitting;
66uart1_set_input(
int (*input)(
unsigned char c))
68 uart1_input_handler = input;
72uart1_writeb(
unsigned char c)
84 if(transmitting == 0) {
92 while(!(IFG2 & UCA0TXIFG));
108 UCA0CTL1 |= UCSSEL_2;
112 UCA0CTL1 &= ~UCSWRST;
118ISR(USCIAB1RX, uart1_rx_interrupt)
123 if(UCA0STAT & UCRXERR) {
127 if(uart1_input_handler != NULL) {
128 if(uart1_input_handler(c)) {
136ISR(USCIAB1TX, uart1_tx_interrupt)
138 if(IFG2 & UCA0TXIFG) {
int ringbuf_get(struct ringbuf *r)
Get a byte from the ring buffer.
int ringbuf_put(struct ringbuf *r, uint8_t c)
Insert a byte into the ring buffer.
int ringbuf_elements(struct ringbuf *r)
Get the number of elements currently in the ring buffer.
Header file for the ring buffer library.
Structure that holds the state of a ring buffer.
A brief description of what this file is.
void uart1_init(unsigned long ubr)
Initalize the RS232 port.