ringbuffer.h
1.69 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _RINGBUF_H_
#define _RINGBUF_H_
#include "cmsis_os.h"
#if !defined(__WINDOWS__) && !defined (FREERTOS) && !defined (LINUX)
#define FREERTOS
#endif
/**
* Put data in a specific length.
* @param *buffer the position of buffer specified by user.
* @param len the length of data which user wants to put.
* @return WRITE_SUCCEED if write succeed,FAIL_LACK_OF_SPACE if no enough space to write in.
*/
int8_t RINGBUF_SEND(const char * buffer, uint16_t len);
/**
* Take data out in a specific length.
* @param *buffer the position of buffer specified by user.
* @param len the length of data which user wants to take.
* @return RINGBUF_READ if read succeed,FAIL_READ_TOO_FAST if readpoint would pass writepoint.
*/
int8_t RINGBUF_READ(uint8_t * buffer, uint16_t len);
/**
* Get data from a specific length.
* @param *buffer the position of buffer specified by user.
* @param len the length of data which user wants to get,not take out!!
* @return RINGBUF_READ if read succeed,FAIL_READ_TOO_FAST if readpoint would pass writepoint.
*/
int8_t RINGBUF_PEEK(uint8_t * buffer, uint16_t len);
/**
* use buffer specified by user as ringbuffer.
* @param *buffer the position of buffer specified by user.
* @param len the length of buffer which user wants.
* @return NULL.
*/
void RINGBUF_INIT(uint8_t * ringbuffer, uint16_t len);
/**
* check if read too fast.
* @param NULL
* @return 1 if read gradually,0 if readpoint catch writepoint.
*/
uint8_t RINGBUF_CHECKIO(void);
/**
* request for space avaliable to write.
* @param NULL
* @return len the space avaliable to use of this ringbuffer.
*/
uint16_t RINGBUF_AVALIABLE_SPACE(void);
#endif