Added volatile qualifier to ringbuffer library to be interrupt safe.
This commit is contained in:
@@ -61,14 +61,14 @@ extern "C" {
|
|||||||
RING_BUFFER const *b);
|
RING_BUFFER const *b);
|
||||||
bool Ringbuf_Empty(
|
bool Ringbuf_Empty(
|
||||||
RING_BUFFER const *b);
|
RING_BUFFER const *b);
|
||||||
uint8_t *Ringbuf_Get_Front(
|
volatile uint8_t *Ringbuf_Get_Front(
|
||||||
RING_BUFFER const *b);
|
RING_BUFFER const *b);
|
||||||
uint8_t *Ringbuf_Pop_Front(
|
volatile uint8_t *Ringbuf_Pop_Front(
|
||||||
RING_BUFFER * b);
|
RING_BUFFER * b);
|
||||||
bool Ringbuf_Put(
|
bool Ringbuf_Put(
|
||||||
RING_BUFFER * b, /* ring buffer structure */
|
RING_BUFFER * b, /* ring buffer structure */
|
||||||
uint8_t * data_element); /* one element to add to the ring */
|
volatile uint8_t *data_element); /* one element to add to the ring */
|
||||||
uint8_t *Ringbuf_Alloc(
|
volatile uint8_t *Ringbuf_Alloc(
|
||||||
RING_BUFFER *b);
|
RING_BUFFER *b);
|
||||||
/* Note: element_count must be a power of two */
|
/* Note: element_count must be a power of two */
|
||||||
void Ringbuf_Init(
|
void Ringbuf_Init(
|
||||||
|
|||||||
@@ -91,10 +91,10 @@ bool Ringbuf_Empty(
|
|||||||
* ALGORITHM: none
|
* ALGORITHM: none
|
||||||
* NOTES: none
|
* NOTES: none
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
uint8_t *Ringbuf_Get_Front(
|
volatile uint8_t *Ringbuf_Get_Front(
|
||||||
RING_BUFFER const *b)
|
RING_BUFFER const *b)
|
||||||
{
|
{
|
||||||
uint8_t *data_element = NULL; /* return value */
|
volatile uint8_t *data_element = NULL; /* return value */
|
||||||
|
|
||||||
if (!Ringbuf_Empty(b)) {
|
if (!Ringbuf_Empty(b)) {
|
||||||
data_element = b->buffer;
|
data_element = b->buffer;
|
||||||
@@ -110,10 +110,10 @@ uint8_t *Ringbuf_Get_Front(
|
|||||||
* ALGORITHM: none
|
* ALGORITHM: none
|
||||||
* NOTES: none
|
* NOTES: none
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
uint8_t *Ringbuf_Pop_Front(
|
volatile uint8_t *Ringbuf_Pop_Front(
|
||||||
RING_BUFFER * b)
|
RING_BUFFER * b)
|
||||||
{
|
{
|
||||||
uint8_t *data_element = NULL;
|
volatile uint8_t *data_element = NULL;
|
||||||
|
|
||||||
if (!Ringbuf_Empty(b)) {
|
if (!Ringbuf_Empty(b)) {
|
||||||
data_element = b->buffer;
|
data_element = b->buffer;
|
||||||
@@ -132,10 +132,10 @@ uint8_t *Ringbuf_Pop_Front(
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
bool Ringbuf_Put(
|
bool Ringbuf_Put(
|
||||||
RING_BUFFER * b, /* ring buffer structure */
|
RING_BUFFER * b, /* ring buffer structure */
|
||||||
uint8_t *data_element)
|
volatile uint8_t *data_element)
|
||||||
{ /* one element to add to the ring */
|
{ /* one element to add to the ring */
|
||||||
bool status = false; /* return value */
|
bool status = false; /* return value */
|
||||||
uint8_t *ring_data = NULL; /* used to help point ring data */
|
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||||
unsigned i; /* loop counter */
|
unsigned i; /* loop counter */
|
||||||
|
|
||||||
if (b && data_element) {
|
if (b && data_element) {
|
||||||
@@ -160,10 +160,10 @@ bool Ringbuf_Put(
|
|||||||
* ALGORITHM: none
|
* ALGORITHM: none
|
||||||
* NOTES: none
|
* NOTES: none
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
uint8_t *Ringbuf_Alloc(
|
volatile uint8_t *Ringbuf_Alloc(
|
||||||
RING_BUFFER *b)
|
RING_BUFFER *b)
|
||||||
{
|
{
|
||||||
uint8_t *ring_data = NULL; /* used to help point ring data */
|
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
/* limit the amount of elements that we accept */
|
/* limit the amount of elements that we accept */
|
||||||
|
|||||||
Reference in New Issue
Block a user