19 lines
392 B
C
19 lines
392 B
C
|
#include "ring_buffer.h"
|
||
|
|
||
|
uint8_t read_entry(struct ring_buffer *buf)
|
||
|
{
|
||
|
if (buf->read >= buf->write)
|
||
|
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;
|
||
|
}
|