GlobLib
HAL and API libraries for MCUs and hardware.
|
8-Bit circular FIFO software buffer. More...
Files | |
file | fifo8.h |
Header file for 8-bit circular FIFO software buffer. | |
Data Structures | |
struct | FIFO8 |
Data structure for FIFO8 perihperal interface. More... | |
Enumerations |
Functions | |
fifo8_error_t | FIFO8_init (FIFO8 *target, fifo8_mode_t mode, uint8_t *buffer, uint16_t size, void(*output)(uint8_t byte)) |
Initializes the FIFO8 buffer. More... | |
fifo8_error_t | FIFO8_put (FIFO8 *target, uint8_t byte) |
Adds a character to the buffer. More... | |
fifo8_error_t | FIFO8_get (FIFO8 *target) |
Takes a character from the buffer. More... | |
uint16_t | FIFO8_size (FIFO8 *target) |
Return the size in bytes of the FIFO8 buffer. More... | |
fifo8_error_t | FIFO8_flush (FIFO8 *target) |
Flush all contents of the FIFO8 to the output function. More... | |
uint8_t | FIFO8_pop (FIFO8 *target) |
Reset the fifo buffer and set its size to 0. | |
8-Bit circular FIFO software buffer.
struct FIFO8 |
Data structure for FIFO8 perihperal interface.
This structure containts variables needed by each instance of of the FIFO8 buffer.
Values contained in this structure do not need to be modified manually, they are managed by function calls.
A new instance of this structure must be initialized by FIFO8_setup().
Data Fields | |
uint8_t * | buffer |
Pointer to the FIFO8 memory buffer. | |
uint16_t | head |
The current write position in the FIFO8 memory buffer. | |
uint16_t | tail |
The current read position in the FIFO8 memory buffer. | |
uint16_t | mask |
Bit mask used for FIFO8 buffer memory wrapping. | |
uint8_t | idle |
Used to determine if the FIFO8 is already outputing bytes. | |
fifo8_mode_t | mode |
The FIFO8 mode of operation. | |
void(* | out )(uint8_t byte) |
Pointer to the output function used by read function FIFO_get() | |
enum fifo8_error_t |
enum fifo8_mode_t |
fifo8_error_t FIFO8_flush | ( | FIFO8 * | target | ) |
Flush all contents of the FIFO8 to the output function.
This function recursibly calles FIFO8_get() until the memory buffer is empty.
target | Pointer to the FIFO8 object to get the size of. |
fifo8_error_t FIFO8_get | ( | FIFO8 * | target | ) |
Takes a character from the buffer.
The character taken from the buffer is passed to the output function set in FIFO8_init()
target | Pointer to the FIFO8 object to take a byte from. |
fifo8_error_t FIFO8_init | ( | FIFO8 * | target, |
fifo8_mode_t | mode, | ||
uint8_t * | buffer, | ||
uint16_t | size, | ||
void(*)(uint8_t byte) | output | ||
) |
Initializes the FIFO8 buffer.
This must be called before any other function of the FIFO8 buffer will work.
target | Pointer to the FIFO8 object to initialize. |
mode | The mode of the buffer. |
buffer | Pointer to the first byte of memory to be used for the buffer. |
size | The size of the buffer (Must be a power or 2). |
output | Pointer to the output function called when FIFO8_get() is used. |
fifo8_error_t FIFO8_put | ( | FIFO8 * | target, |
uint8_t | byte | ||
) |
Adds a character to the buffer.
If the FIFO8 mode is FIFO8_AUTO, and this is the first byte in the fifo, this will start the output stream as well.
target | Pointer to the FIFO8 object to add a byte to. |
byte | The byte to add to the buffer. |