-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathring_buff.h
38 lines (31 loc) · 985 Bytes
/
ring_buff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
============================================================================
Name : ring_buff.h
Author :
Version :
Copyright : Your copyright notice
Description : code description
============================================================================
*/
#ifndef INC_RING_BUFF_H_
#define INC_RING_BUFF_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef struct {
uint8_t* buffer;
uint8_t* head; // Points to the next byte to be written
uint8_t* tail; // Points to the next byte to be read
uint16_t size;
} RingBuffer_t;
void RingBuffer_Init(RingBuffer_t *buffer, uint8_t *buffer_ptr, uint16_t sz);
int8_t RingBuffer_Push(RingBuffer_t *buffer, uint8_t data);
uint8_t RingBuffer_Pop(RingBuffer_t *buffer);
uint16_t RingBuffer_Available(RingBuffer_t *buffer);
uint8_t RingBuffer_Peek(RingBuffer_t *buffer);
void RingBuffer_Clear(RingBuffer_t *buffer);
#ifdef __cplusplus
}
#endif
#endif /* INC_RING_BUFF_H_ */