MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ringbuffer_data_len

Function rt_ringbuffer_data_len

components/drivers/ipc/ringbuffer.c:378–397  ·  view source on GitHub ↗

* @brief Get the size of data in the ring buffer in bytes. * * @param rb The pointer to the ring buffer object. * * @return Return the size of data in the ring buffer in bytes. */

Source from the content-addressed store, hash-verified

376 * @return Return the size of data in the ring buffer in bytes.
377 */
378rt_size_t rt_ringbuffer_data_len(struct rt_ringbuffer *rb)
379{
380 switch (rt_ringbuffer_status(rb))
381 {
382 case RT_RINGBUFFER_EMPTY:
383 return 0;
384 case RT_RINGBUFFER_FULL:
385 return rb->buffer_size;
386 case RT_RINGBUFFER_HALFFULL:
387 default:
388 {
389 rt_size_t wi = rb->write_index, ri = rb->read_index;
390
391 if (wi > ri)
392 return wi - ri;
393 else
394 return rb->buffer_size - (ri - wi);
395 }
396 }
397}
398RTM_EXPORT(rt_ringbuffer_data_len);
399
400/**

Callers 15

vcom_tx_thread_entryFunction · 0.85
serial_fops_pollFunction · 0.85
_serial_fifo_rxFunction · 0.85
rt_hw_serial_isrFunction · 0.85
rt_hw_can_isrFunction · 0.85
rt_hw_inputcapture_isrFunction · 0.85

Calls 1

rt_ringbuffer_statusFunction · 0.70

Tested by

no test coverage detected