#ifndef _Cirule_Buffer_h__ #define _Cirule_Buffer_h__ #include #ifndef min #define min(x,y)(xbuffer_len) { cbuff->w_pos = 0; }else { cbuff->w_pos = pos; } } } static __inline__ int circle_get_read_position(c_buffer_t *cbuff){ return cbuff->r_pos; } static __inline__ int circle_get_write_space(c_buffer_t *cbuff){ int16_t size = (cbuff->w_pos >= cbuff->r_pos)?(cbuff->buffer_len - cbuff->w_pos + cbuff->r_pos):(cbuff->r_pos - cbuff->w_pos); size -= 1; if (size <= 0){ return CBUFF_FULL; } return size; } void circle_buffer_init(c_buffer_t *cbuff, uint8_t *buffer, int16_t max_len); void circle_reset(c_buffer_t *cbuff); int circle_put_one_data(c_buffer_t *cbuff, uint8_t data); int circle_put_data(c_buffer_t *cbuff, uint8_t *data, int16_t len); int circle_get_one_data(c_buffer_t *cbuff, uint8_t *data); int circle_get_data(c_buffer_t *cbuffer, uint8_t *data, int16_t len); #endif /* _Cirule_Buffer_h__ */