FIFOs for use by USART module. More...
#include <avr/interrupt.h>
Go to the source code of this file.
Data Structures | |
struct | fifo_item_s |
definition of item unit in FIFO More... | |
struct | fifo_s |
state of FIFO More... | |
Typedefs | |
typedef struct fifo_item_s | fifo_item_t |
definition of item unit in FIFO | |
typedef uint8_t | fifo_size_t |
definition for type for number of items in FIFO | |
typedef struct fifo_s | fifo_t |
state of FIFO | |
Functions | |
void | fifo_init (fifo_t *fifo, fifo_item_t *buffer, fifo_size_t size) |
initialize FIFO state | |
fifo_item_t * | fifo_get_buffer (fifo_t *f) |
get buffer pointer for FIFO | |
uint8_t | fifo_is_empty (const fifo_t *f) |
test if FIFO is empty (contains no items) | |
uint8_t | fifo_is_full (const fifo_t *f) |
test if FIFO is full | |
void | fifo_putQ_item (fifo_t *f, fifo_item_t c) |
"fast" put into FIFO | |
fifo_item_t | fifo_getQ_item (fifo_t *f) |
"fast" get from FIFO | |
fifo_item_t | fifo_get_item (fifo_t *f) |
get from FIFO | |
uint8_t | fifo_get_uint8 (fifo_t *f) |
get uint8_t from FIFO | |
void | fifo_put_item (fifo_t *f, fifo_item_t i) |
put into FIFO | |
void | fifo_put_uint8 (fifo_t *f, uint8_t b) |
put uint8_t into FIFO |
FIFOs for use by USART module.
fifo_item_t fifo_getQ_item | ( | fifo_t * | f | ) | [inline] |
"fast" get from FIFO
fifo_getQ_item() gets an item from the FIFO without guarding against concurrent access. It assumes interrupts are turned off. Use it only when you can be sure this is really the case (e.g. in an interrupt handler).
{ fifo_size_t tail; tail = f->tail; if (f->num_items) { fifo_item_t data = f->buffer[tail++]; if (tail >= f->size) { /* wrap around to start of buffer */ tail = 0; } f->tail = tail; f->num_items--; return data; } f->underflow = 1; return (fifo_item_t){0,0xFF}; }
void fifo_init | ( | fifo_t * | fifo, | |
fifo_item_t * | buffer, | |||
fifo_size_t | size | |||
) |
initialize FIFO state
fifo | pointer to state structure to initialize | |
buffer | pointer to buffer to use | |
size | size of buffer (in fifo_item_t units) |
{ f->buffer = buffer; f->size = size; f->head = 0; f->tail = 0; f->num_items = 0; f->overflow = 0; f->underflow = 0; }
void fifo_putQ_item | ( | fifo_t * | f, | |
fifo_item_t | c | |||
) | [inline] |
"fast" put into FIFO
fifo_putQ_item() puts an item into the FIFO without guarding against concurrent access. It assumes interrupts are turned off. Use it only when you can be sure this is really the case (e.g. in an interrupt handler).