2021-07-16 16:07:57 +00:00
|
|
|
#include "ring_buffer.h"
|
|
|
|
|
|
|
|
uint8_t read_entry(struct ring_buffer *buf)
|
|
|
|
{
|
2021-07-17 03:26:54 +00:00
|
|
|
if (buf->read == buf->write)
|
2021-07-16 16:07:57 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint8_t data = buf->buffer[buf->read];
|
|
|
|
buf->read = (buf->read + 1) % RING_BUFFER_SIZE;
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void write_entry(struct ring_buffer *buf, uint8_t entry)
|
|
|
|
{
|
|
|
|
buf->buffer[buf->write] = entry;
|
|
|
|
buf->write = (buf->write + 1) % RING_BUFFER_SIZE;
|
|
|
|
}
|