APM:Libraries
|
Simple circular buffer for PEM input. More...
Go to the source code of this file.
Classes | |
struct | Pulse_buffer |
Typedefs | |
typedef struct Pulse_buffer | pulse_buffer |
Functions | |
static void | pb_init (volatile pulse_buffer *pb, uint16_t size, Pulse *buf) |
static uint16_t | pb_full_count (volatile pulse_buffer *pb) |
Return the number of elements stored in the ring buffer. More... | |
static int | pb_is_full (volatile pulse_buffer *pb) |
Returns true if and only if the ring buffer is full. More... | |
static int | pb_is_empty (volatile pulse_buffer *pb) |
Returns true if and only if the ring buffer is empty. More... | |
static void | pb_insert (volatile pulse_buffer *pb, Pulse element) |
static Pulse | pb_remove (volatile pulse_buffer *pb) |
Remove and return the first item from a ring buffer. More... | |
static int | pb_safe_insert (volatile pulse_buffer *pb, Pulse element) |
Attempt to insert an element into a ring buffer. More... | |
static void | pb_reset (volatile pulse_buffer *pb) |
Discard all items from a ring buffer. More... | |
Simple circular buffer for PEM input.
(c) 2017 night _gho st@yk octp a.ru
based on: ring_buffer.h
This implementation is not thread-safe. In particular, none of these functions is guaranteed re-entrant.
Definition in file ring_buffer_pulse.h.
typedef struct Pulse_buffer pulse_buffer |
Ring buffer type.
The buffer is empty when head == tail.
The buffer is full when the head is one byte in front of the tail, modulo buffer length.
One element is left free to distinguish empty from full.
|
inlinestatic |
Return the number of elements stored in the ring buffer.
pb | Buffer whose elements to count. |
Definition at line 66 of file ring_buffer_pulse.h.
Referenced by getPPM_count().
|
inlinestatic |
Initialise a ring buffer.
pb | Instance to initialise |
size | Number of items in buf. The ring buffer will always leave one element unoccupied, so the maximum number of elements it can store will be size - 1. Thus, size must be at least 2. |
buf | Buffer to store items into |
Definition at line 55 of file ring_buffer_pulse.h.
Referenced by pwmInit().
|
inlinestatic |
Append element onto the end of a ring buffer.
pb | Buffer to append onto. |
element | Value to append. |
Definition at line 100 of file ring_buffer_pulse.h.
Referenced by pb_safe_insert(), and pwmIRQHandler().
|
inlinestatic |
Returns true if and only if the ring buffer is empty.
pb | Buffer to test. |
Definition at line 90 of file ring_buffer_pulse.h.
Referenced by getPPM_Pulse().
|
inlinestatic |
Returns true if and only if the ring buffer is full.
pb | Buffer to test. |
Definition at line 80 of file ring_buffer_pulse.h.
Referenced by pb_safe_insert(), and pwmIRQHandler().
|
inlinestatic |
Remove and return the first item from a ring buffer.
pb | Buffer to remove from, must contain at least one element. |
Definition at line 110 of file ring_buffer_pulse.h.
Referenced by getPPM_Pulse().
|
inlinestatic |
Discard all items from a ring buffer.
pb | Ring buffer to discard all items from. |
Definition at line 137 of file ring_buffer_pulse.h.
|
inlinestatic |
Attempt to insert an element into a ring buffer.
pb | Buffer to insert into. |
element | Value to insert into pb. If pb is not full, appends element onto buffer. |
Definition at line 124 of file ring_buffer_pulse.h.