#include <stdint.h>
Data Structures | |
| struct | fifo |
| The structure forming the FIFO. More... | |
Functions | |
| void | init_fifo (struct fifo *fifo, uint8_t *buffer, unsigned int size) |
| Initialise a Fifo. | |
| int | writeByte_fifo (struct fifo *fifo, unsigned char data) |
| Write one byte to the fifo. | |
| uint32_t | write_fifo (struct fifo *fifo, const uint8_t *buffer, uint32_t size) |
| Write upto the requested number of bytes into the fifo. | |
| int | readByte_fifo (struct fifo *fifo, uint8_t *data) |
| Read a byte from the fifo. | |
| uint32_t | read_fifo (struct fifo *fifo, uint8_t *buffer, uint32_t size) |
| Read upto the requested number of bytes from the fifo. | |
| uint32_t | getSize_fifo (struct fifo *fifo) |
| Get the current size of the fifo. | |
A First In First Out implementation. The size of data written to and read from the fifo is one byte.
NOTE: These fifo functions are not re-entrant so protect them.
| uint32_t getSize_fifo | ( | struct fifo * | fifo | ) | [inline] |
Get the current size of the fifo.
| fifo | The FIFO on which the operation will be performed. |
| void init_fifo | ( | struct fifo * | fifo, | |
| uint8_t * | buffer, | |||
| unsigned int | size | |||
| ) |
Initialise a Fifo.
Initialise the fifo to be empty. Set the buffer to the supplied buffer and set the fifo maximum size accordingly. The read and write pointers are positioned at the start of the buffer.
| fifo | The FIFO on which the operation will be performed. | |
| buffer | The buffer to be used by the fifo. | |
| size | The size of the buffer in bytes. |
| uint32_t read_fifo | ( | struct fifo * | fifo, | |
| uint8_t * | buffer, | |||
| uint32_t | size | |||
| ) |
Read upto the requested number of bytes from the fifo.
| fifo | The FIFO on which the operation will be performed. | |
| buffer | The buffer into which the fifo data will be place. | |
| size | The maximum number of bytes to move. |
| int readByte_fifo | ( | struct fifo * | fifo, | |
| uint8_t * | data | |||
| ) |
Read a byte from the fifo.
Attempts to read the next byte from the fifo.
| fifo | The FIFO on which the operation will be performed. | |
| data | Pointer to the location to which the read byte value is written. |
| uint32_t write_fifo | ( | struct fifo * | fifo, | |
| const uint8_t * | buffer, | |||
| uint32_t | size | |||
| ) |
Write upto the requested number of bytes into the fifo.
Data is written into the fifo from the supplied buffer. Data at the start of the buffer is written first. Writing will stop if the fifo becomes fall.
| fifo | The FIFO on which the operation will be performed. | |
| buffer | The buffer from which the data will be taken. | |
| size | The maximum number of bytes to write into the fifo. |
| int writeByte_fifo | ( | struct fifo * | fifo, | |
| unsigned char | data | |||
| ) |
Write one byte to the fifo.
Attempts to write the supplied byte to the fifo.
| fifo | The FIFO on which the operation will be performed. | |
| data | The data to be added to the fifo |
1.4.7