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

Function rt_ringbuffer_getchar

components/drivers/ipc/ringbuffer.c:346–368  ·  view source on GitHub ↗

* @brief Get a byte from the ring buffer. * * @param rb The pointer to the ring buffer object. * @param ch A pointer to the buffer, used to store one byte. * * @return 0 The ring buffer is empty. * @return 1 Success */

Source from the content-addressed store, hash-verified

344 * @return 1 Success
345 */
346rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch)
347{
348 RT_ASSERT(rb != RT_NULL);
349
350 /* ringbuffer is empty */
351 if (!rt_ringbuffer_data_len(rb))
352 return 0;
353
354 /* put byte */
355 *ch = rb->buffer_ptr[rb->read_index];
356
357 if (rb->read_index == rb->buffer_size - 1)
358 {
359 rb->read_mirror = ~rb->read_mirror;
360 rb->read_index = 0;
361 }
362 else
363 {
364 rb->read_index++;
365 }
366
367 return 1;
368}
369RTM_EXPORT(rt_ringbuffer_getchar);
370
371/**

Callers 12

_vcom_getcFunction · 0.85
rt_bypass_getcharFunction · 0.85
rt_hw_serial_control_isrFunction · 0.85
console_getcharFunction · 0.85
client_getcharFunction · 0.85
hpm_uart_isrFunction · 0.85
drv_uart_v2.cFile · 0.85
uart_msg_getcFunction · 0.85
console_getcFunction · 0.85
uart_transmitFunction · 0.85
consumer_thread_entryFunction · 0.85

Calls 1

rt_ringbuffer_data_lenFunction · 0.85

Tested by 1

consumer_thread_entryFunction · 0.68