Wirepas SDK
|
Example:
Definition in file ringbuffer.h.
Go to the source code of this file.
Data Structures | |
struct | ringbuffer_t |
Macros | |
#define | MASK (BUFFER_SIZE-1) |
#define | Ringbuffer_size(p) (BUFFER_SIZE) |
#define | Ringbuffer_usage(p) ((uint16_t)((p).in - (p).out)) |
#define | Ringbuffer_free(p) (Ringbuffer_size(p)-Ringbuffer_usage(p)) |
#define | Ringbuffer_contents(p) ((p).buf) |
#define | Ringbuffer_reset(p) do{ (p).out = 0; (p).in = 0; }while(false) |
#define | Ringbuffer_isReset(p) ((p).out == 0 && (p).in == 0) |
#define | Ringbuffer_getHeadIdx(p) ((p).in & MASK) |
#define | Ringbuffer_getHeadByte(p) ((p).buf[Ringbuffer_getHeadIdx(p)]) |
#define | Ringbuffer_getHeadPtr(p) (uint8_t *)(&Ringbuffer_getHeadByte(p)) |
#define | Ringbuffer_incrHead(p, a) ((p).in += (a)) |
#define | Ringbuffer_getTailIdx(p) ((p).out & MASK) |
#define | Ringbuffer_getTailByte(p) ((p).buf[Ringbuffer_getTailIdx(p)]) |
#define | Ringbuffer_getTailPtr(p) (uint8_t *)(&Ringbuffer_getTailByte(p)) |
#define | Ringbuffer_incrTail(p, a) ((p).out += (a)) |
struct ringbuffer_t |
Definition at line 30 of file ringbuffer.h.
Data Fields | ||
---|---|---|
uint8_t | buf[BUFFER_SIZE] | |
uint16_t | in | |
uint16_t | out |
#define MASK (BUFFER_SIZE-1) |
Definition at line 28 of file ringbuffer.h.
#define Ringbuffer_contents | ( | p | ) | ((p).buf) |
Access the contents of the buffer
Definition at line 45 of file ringbuffer.h.
#define Ringbuffer_free | ( | p | ) | (Ringbuffer_size(p)-Ringbuffer_usage(p)) |
Number of free bytes
Definition at line 42 of file ringbuffer.h.
#define Ringbuffer_getHeadByte | ( | p | ) | ((p).buf[Ringbuffer_getHeadIdx(p)]) |
Byte at the current head position
Definition at line 55 of file ringbuffer.h.
#define Ringbuffer_getHeadIdx | ( | p | ) | ((p).in & MASK) |
Array index of the head
Definition at line 53 of file ringbuffer.h.
#define Ringbuffer_getHeadPtr | ( | p | ) | (uint8_t *)(&Ringbuffer_getHeadByte(p)) |
Pointer to the current head position
Definition at line 57 of file ringbuffer.h.
#define Ringbuffer_getTailByte | ( | p | ) | ((p).buf[Ringbuffer_getTailIdx(p)]) |
Byte at the current tail position
Definition at line 64 of file ringbuffer.h.
#define Ringbuffer_getTailIdx | ( | p | ) | ((p).out & MASK) |
Array index of the tail
Definition at line 62 of file ringbuffer.h.
#define Ringbuffer_getTailPtr | ( | p | ) | (uint8_t *)(&Ringbuffer_getTailByte(p)) |
Pointer to the current tail position
Definition at line 66 of file ringbuffer.h.
#define Ringbuffer_incrHead | ( | p, | |
a | |||
) | ((p).in += (a)) |
Move head forward by 'a' bytes
Definition at line 59 of file ringbuffer.h.
#define Ringbuffer_incrTail | ( | p, | |
a | |||
) | ((p).out += (a)) |
Move tail forward by 'a' bytes
Definition at line 68 of file ringbuffer.h.
#define Ringbuffer_isReset | ( | p | ) | ((p).out == 0 && (p).in == 0) |
Check if buffer is reset
Definition at line 50 of file ringbuffer.h.
#define Ringbuffer_reset | ( | p | ) | do{ (p).out = 0; (p).in = 0; }while(false) |
Reset the buffer
Definition at line 48 of file ringbuffer.h.
#define Ringbuffer_size | ( | p | ) | (BUFFER_SIZE) |
Total capacity of the buffer in bytes
Definition at line 38 of file ringbuffer.h.
#define Ringbuffer_usage | ( | p | ) | ((uint16_t)((p).in - (p).out)) |
Number of used bytes
Definition at line 40 of file ringbuffer.h.