diff options
Diffstat (limited to 'libraries/fifo.h')
-rw-r--r-- | libraries/fifo.h | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/libraries/fifo.h b/libraries/fifo.h index c56d410..700d2ec 100644 --- a/libraries/fifo.h +++ b/libraries/fifo.h @@ -1,30 +1,30 @@ -/* - FIFO Ring Buffer uint8_t array ring_buffer (example length is 8) - with data (x) and read and write index: - - --- --- --- --- --- --- --- --- - | | | x | x | x | | | | - --- --- --- --- --- --- --- --- - ^ ^ - | | - read_index | - write_index - - --- --- --- --- --- --- --- --- - | x | x | | | | x | x | x | - --- --- --- --- --- --- --- --- - ^ ^ - | | - write_index | - read_index - - - input data goes to position of write_index - - output data comes from read_index position - - after input/output operation the according index has to be modified - - according to the idea of ring buffers the write_index could be - smaller than the read_index +/* + FIFO Ring Buffer uint8_t array ring_buffer (example length is 8) + with data (x) and read and write index: + + --- --- --- --- --- --- --- --- + | | | x | x | x | | | | + --- --- --- --- --- --- --- --- + ^ ^ + | | + read_index | + write_index + + --- --- --- --- --- --- --- --- + | x | x | | | | x | x | x | + --- --- --- --- --- --- --- --- + ^ ^ + | | + write_index | + read_index + + - input data goes to position of write_index + - output data comes from read_index position + - after input/output operation the according index has to be modified + - according to the idea of ring buffers the write_index could be + smaller than the read_index */ @@ -37,15 +37,14 @@ typedef struct FIFO{ - uint8_t *buffer_ptr; - uint16_t read_index; - uint16_t write_index; - uint16_t bufferlength; + uint8_t *buffer_ptr; + uint16_t bufferlength; + uint16_t read_index; + uint16_t write_index; } FIFO; -void fifo_init(FIFO *fifo, uint16_t bufferlength); -void fifo_deinit(FIFO *fifo); +void fifo_init(FIFO *fifo, uint8_t *buffer, uint16_t bufferlength); uint16_t fifo_get_buffersize(FIFO *fifo); |