39 #ifndef NIBOBEE_USART_H_
40 #define NIBOBEE_USART_H_
43 #include <avr/pgmspace.h>
49 #define USART_TXBUF_SIZE 16
50 #define USART_RXBUF_SIZE 8
57 extern uint8_t usart_txbuf[USART_TXBUF_SIZE];
58 extern uint8_t usart_rxbuf[USART_RXBUF_SIZE];
60 extern volatile uint8_t usart_txbuf_begin;
61 extern volatile uint8_t usart_txbuf_end;
63 extern volatile uint8_t usart_rxbuf_begin;
64 extern volatile uint8_t usart_rxbuf_end;
109 void usart_send(
const char * s,
unsigned int len);
123 static inline char usart_rxempty() {
124 return usart_rxbuf_begin==usart_rxbuf_end;
131 static inline char usart_txempty() {
132 return usart_txbuf_begin==usart_txbuf_end;
139 static inline char usart_rxfull() {
140 return usart_rxbuf_end==USART_RXBUF_SIZE;
147 static inline char usart_txfull() {
148 return usart_txbuf_end==USART_TXBUF_SIZE;
155 static inline char usart_rxavail() {
157 int s=(int)usart_rxbuf_end-(
int)usart_rxbuf_begin;
158 if (usart_rxfull())
return USART_RXBUF_SIZE;
159 return (s<0)?(USART_RXBUF_SIZE+s):s;
166 static inline char usart_txfree() {
168 int s=(int)usart_txbuf_end-(
int)usart_txbuf_begin;
169 if (usart_txfull())
return 0;
170 return (s<0)?(-s):(USART_TXBUF_SIZE-s);
178 #endif // NIBOBEE_USART_H_
void usart_send_P(PGM_P s, unsigned int len)
void usart_send(const char *s, unsigned int len)
void usart_write(const char *s)
char usart_putchar(char c)
void usart_setbaudrate(uint16_t baud)
void usart_write_P(PGM_P s)