* @brief Initialize the ring buffer object. * * @param rb A pointer to the ring buffer object. * @param pool A pointer to the buffer. * @param size The size of the buffer in bytes. */
| 35 | * @param size The size of the buffer in bytes. |
| 36 | */ |
| 37 | void rt_ringbuffer_init(struct rt_ringbuffer *rb, |
| 38 | rt_uint8_t *pool, |
| 39 | rt_int32_t size) |
| 40 | { |
| 41 | RT_ASSERT(rb != RT_NULL); |
| 42 | RT_ASSERT(size > 0); |
| 43 | |
| 44 | /* initialize read and write index */ |
| 45 | rb->read_mirror = rb->read_index = 0; |
| 46 | rb->write_mirror = rb->write_index = 0; |
| 47 | |
| 48 | /* set buffer pool and size */ |
| 49 | rb->buffer_ptr = pool; |
| 50 | rb->buffer_size = RT_ALIGN_DOWN(size, RT_ALIGN_SIZE); |
| 51 | } |
| 52 | RTM_EXPORT(rt_ringbuffer_init); |
| 53 | |
| 54 | /** |
no outgoing calls
no test coverage detected