Serial subsystem. More...
#include "serial.h"
#include <avr/interrupt.h>
#include "config.h"
#include "arduino.h"
Defines | |
#define | BUFSIZE 64 |
size of TX and RX buffers. MUST be a value | |
#define | ASCII_XOFF 19 |
ascii XOFF character | |
#define | ASCII_XON 17 |
ascii XON character | |
#define | buf_canread(buffer) ((buffer ## head - buffer ## tail ) & (BUFSIZE - 1)) |
check if we can read from this buffer | |
#define | buf_pop(buffer, data) do { data = buffer ## buf[buffer ## tail]; buffer ## tail = (buffer ## tail + 1) & (BUFSIZE - 1); } while (0) |
read from buffer | |
#define | buf_canwrite(buffer) ((buffer ## tail - buffer ## head - 1) & (BUFSIZE - 1)) |
check if we can write to this buffer | |
#define | buf_push(buffer, data) do { buffer ## buf[buffer ## head] = data; buffer ## head = (buffer ## head + 1) & (BUFSIZE - 1); } while (0) |
write to buffer | |
Functions | |
void | serial_init () |
initialise serial subsystem | |
Variables | |
volatile uint8_t | rxhead = 0 |
rx buffer head pointer. Points to next available space. | |
volatile uint8_t | rxtail = 0 |
rx buffer tail pointer. Points to last character in buffer | |
volatile uint8_t | rxbuf [BUFSIZE] |
rx buffer | |
volatile uint8_t | txhead = 0 |
tx buffer head pointer. Points to next available space. | |
volatile uint8_t | txtail = 0 |
tx buffer tail pointer. Points to last character in buffer | |
volatile uint8_t | txbuf [BUFSIZE] |
tx buffer |
Serial subsystem.
Teacup's serial subsystem is a powerful, thoroughly tested and highly modular serial management system.
It uses ringbuffers for both transmit and receive, and intelligently decides whether to wait or drop transmitted characters if the buffer is full.
It also supports XON/XOFF flow control of the receive buffer, to help avoid overruns.
void serial_init | ( | void | ) |
initialise serial subsystem
set up baud generator and interrupts, clear buffers
Referenced by init().