| 12345678910111213141516171819202122232425262728293031323334353637 |
- #ifndef _Cirule_Buffer_h__
- #define _Cirule_Buffer_h__
- #include <stdint.h>
- #ifndef min
- #define min(x,y)(x<y)?x:y;
- #endif
- #define CBUFF_SUCCESS 0
- #define CBUFF_FULL -1
- #define CBUFF_EMPTY -2
- typedef struct {
- char * buffer;
- int16_t buffer_len;
- int16_t w_pos;
- int16_t r_pos;
- }c_buffer_t;
- //used by dma
- static __inline__ void circle_update_write_position(c_buffer_t *cbuff, int pos){
- cbuff->w_pos = pos;
- }
- static __inline__ int circle_get_read_position(c_buffer_t *cbuff){
- return cbuff->r_pos;
- }
- void circle_buffer_init(c_buffer_t *cbuff, char *buffer, int16_t max_len);
- void circle_reset(c_buffer_t *cbuff);
- int circle_put_one_data(c_buffer_t *cbuff, char data);
- int circle_put_data(c_buffer_t *cbuff, char *data, int16_t len);
- int circle_get_one_data(c_buffer_t *cbuff, char *data);
- int circle_get_data(c_buffer_t *cbuffer, char *data, int16_t len);
- #endif /* _Cirule_Buffer_h__ */
|