no-OS
circular_buffer.h
Go to the documentation of this file.
1 /***************************************************************************/
41 #ifndef CIRCULAR_BUFFER_H
42 #define CIRCULAR_BUFFER_H
43 
44 /******************************************************************************/
45 /***************************** Include Files **********************************/
46 /******************************************************************************/
47 
48 #include <stdint.h>
49 
50 /******************************************************************************/
51 /*************************** Types Declarations *******************************/
52 /******************************************************************************/
53 
58 struct cb_ptr {
60  uint32_t idx;
62  uint32_t spin_count;
66  uint32_t async_size;
67 };
68 
75  uint32_t size;
77  int8_t *buff;
79  struct cb_ptr write;
81  struct cb_ptr read;
82 };
83 
84 /******************************************************************************/
85 /************************ Functions Declarations ******************************/
86 /******************************************************************************/
87 
88 int32_t cb_init(struct circular_buffer **desc, uint32_t size);
89 /* Configure cb structure with given parameters without memory allocation */
90 int32_t cb_cfg(struct circular_buffer *desc, int8_t *buf, uint32_t size);
91 int32_t cb_remove(struct circular_buffer *desc);
92 int32_t cb_size(struct circular_buffer *desc, uint32_t *size);
93 
94 int32_t cb_write(struct circular_buffer *desc, const void *data,
95  uint32_t nb_elements);
96 int32_t cb_read(struct circular_buffer *desc, void *data, uint32_t nb_elements);
97 
98 int32_t cb_prepare_async_write(struct circular_buffer *desc,
99  uint32_t raw_size_to_write,
100  void **write_buff,
101  uint32_t *raw_size_avilable);
102 int32_t cb_end_async_write(struct circular_buffer *desc);
103 
104 int32_t cb_prepare_async_read(struct circular_buffer *desc,
105  uint32_t raw_size_to_read,
106  void **read_buff,
107  uint32_t *raw_size_avilable);
108 int32_t cb_end_async_read(struct circular_buffer *desc);
109 
110 #endif
cb_end_async_write
int32_t cb_end_async_write(struct circular_buffer *desc)
circular_buffer::write
struct cb_ptr write
Definition: circular_buffer.h:79
cb_prepare_async_write
int32_t cb_prepare_async_write(struct circular_buffer *desc, uint32_t raw_size_to_write, void **write_buff, uint32_t *raw_size_avilable)
cb_ptr::spin_count
uint32_t spin_count
Definition: circular_buffer.h:62
cb_prepare_async_read
int32_t cb_prepare_async_read(struct circular_buffer *desc, uint32_t raw_size_to_read, void **read_buff, uint32_t *raw_size_avilable)
cb_remove
int32_t cb_remove(struct circular_buffer *desc)
cb_ptr::async_size
uint32_t async_size
Definition: circular_buffer.h:66
cb_init
int32_t cb_init(struct circular_buffer **desc, uint32_t size)
circular_buffer::buff
int8_t * buff
Definition: circular_buffer.h:77
cb_size
int32_t cb_size(struct circular_buffer *desc, uint32_t *size)
cb_cfg
int32_t cb_cfg(struct circular_buffer *desc, int8_t *buf, uint32_t size)
cb_ptr::async_started
bool async_started
Definition: circular_buffer.h:64
cb_write
int32_t cb_write(struct circular_buffer *desc, const void *data, uint32_t nb_elements)
cb_end_async_read
int32_t cb_end_async_read(struct circular_buffer *desc)
cb_ptr::idx
uint32_t idx
Definition: circular_buffer.h:60
circular_buffer
Circular buffer descriptor.
Definition: circular_buffer.h:73
cb_read
int32_t cb_read(struct circular_buffer *desc, void *data, uint32_t nb_elements)
circular_buffer::read
struct cb_ptr read
Definition: circular_buffer.h:81
cb_ptr
Circular buffer pointer.
Definition: circular_buffer.h:58
circular_buffer::size
uint32_t size
Definition: circular_buffer.h:75