#include <inttypes.h>
Go to the source code of this file.
Data Structures | |
struct | buffer |
The 'ring' buffer. More... | |
Defines | |
#define | BUFFER_BITS 7 |
Default buffer size is 2^7 = 128 bytes. | |
#define | buffer_init(b) b.head = b.tail = 0 |
Initialize the buffer's indexes. | |
Functions | |
char | buffer_put (struct buffer *b, char c) |
Insert a byte into a buffer. | |
char | buffer_get (struct buffer *b) |
Take a byte out of a buffer. | |
uint8_t | buffer_size (struct buffer *b) |
Get the buffer occupancy. |
#define BUFFER_BITS 7 |
Default buffer size is 2^7 = 128 bytes.
#define buffer_init | ( | b | ) | b.head = b.tail = 0 |
Initialize the buffer's indexes.
char buffer_get | ( | struct buffer * | b | ) |
Take a byte out of a buffer.
This function removes a byte from the buffer, adjusting the buffer indexes as needed.
[in] | b | The buffer from which to read. |
[out] | c | Where to store the byte that was read. |
char | 1 on success, 0 if the buffer was empty and nothing was read. |
char buffer_put | ( | struct buffer * | b, | |
char | c | |||
) |
Insert a byte into a buffer.
This function inserts a byte into the buffer, adjusting the buffer indexes as needed.
[in] | b | The buffer to insert into. |
[in] | c | The byte to insert. |
char | 1 on success, 0 if there was no room in the buffer. |
uint8_t buffer_size | ( | struct buffer * | b | ) |
Get the buffer occupancy.
[in] | b | The buffer to check the occupancy of. |
uint8_t | The number of bytes currently stored in the buffer. |