Envorimental Monitoring
Loading...
Searching...
No Matches
ring_buffer.h
Go to the documentation of this file.
1
12
13#ifndef INC_RING_BUFFER_H_
14#define INC_RING_BUFFER_H_
15
16#include "stdint.h"
17#include "stdbool.h"
18
25typedef struct
26{
27 float *buffer;
28 uint16_t head;
29 uint16_t tail;
30 uint16_t count;
31 uint16_t size;
33
44void buffer_init(buf_handle_t *p_handle, float *p_buffer, uint16_t size);
45
51bool buffer_isFull(buf_handle_t *p_handle);
52
57void buffer_clear(buf_handle_t *p_handle);
58
64bool buffer_isEmpty(buf_handle_t *p_handle);
65
73int buffer_get_value(buf_handle_t *p_handle, float *p_sensor_data);
74
85int buffer_write_value(buf_handle_t *p_handle, float p_sensor_data);
86
87#endif /* INC_RING_BUFFER_H_ */
int buffer_get_value(buf_handle_t *p_handle, float *p_sensor_data)
Reads and removes the oldest sample from the buffer (FIFO order).
Definition ring_buffer.c:37
void buffer_init(buf_handle_t *p_handle, float *p_buffer, uint16_t size)
Initialises a ring buffer handle.
Definition ring_buffer.c:11
bool buffer_isFull(buf_handle_t *p_handle)
Checks whether the buffer is full.
Definition ring_buffer.c:20
bool buffer_isEmpty(buf_handle_t *p_handle)
Checks whether the buffer is empty.
Definition ring_buffer.c:32
int buffer_write_value(buf_handle_t *p_handle, float p_sensor_data)
Writes a new sample into the buffer.
Definition ring_buffer.c:48
void buffer_clear(buf_handle_t *p_handle)
Resets the buffer to an empty state without clearing storage memory.
Definition ring_buffer.c:25
Ring buffer control structure.
Definition ring_buffer.h:26
uint16_t size
Definition ring_buffer.h:31
uint16_t tail
Definition ring_buffer.h:29
uint16_t head
Definition ring_buffer.h:28
uint16_t count
Definition ring_buffer.h:30
float * buffer
Definition ring_buffer.h:27