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

Function rt_ringbuffer_putchar

components/drivers/ipc/ringbuffer.c:272–294  ·  view source on GitHub ↗

* @brief Put a byte into the ring buffer. If ring buffer is full, this operation will fail. * * @param rb A pointer to the ring buffer object. * @param ch A byte put into the ring buffer. * * @return Return the data size we put into the ring buffer. The ring buffer is full if returns 0. Otherwise, it will return 1. */

Source from the content-addressed store, hash-verified

270 * @return Return the data size we put into the ring buffer. The ring buffer is full if returns 0. Otherwise, it will return 1.
271 */
272rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
273{
274 RT_ASSERT(rb != RT_NULL);
275
276 /* whether has enough space */
277 if (!rt_ringbuffer_space_len(rb))
278 return 0;
279
280 rb->buffer_ptr[rb->write_index] = ch;
281
282 /* flip mirror */
283 if (rb->write_index == rb->buffer_size - 1)
284 {
285 rb->write_mirror = ~rb->write_mirror;
286 rb->write_index = 0;
287 }
288 else
289 {
290 rb->write_index++;
291 }
292
293 return 1;
294}
295RTM_EXPORT(rt_ringbuffer_putchar);
296
297/**

Callers 7

rt_bypass_putcharFunction · 0.85
rt_hw_serial_control_isrFunction · 0.85
drv_uart.cFile · 0.85
uart_irq_handlerFunction · 0.85
sci_uart_irq_callbackFunction · 0.85
hpm_uart_isrFunction · 0.85
ringbuffer_sampleFunction · 0.85

Calls

no outgoing calls

Tested by 1

ringbuffer_sampleFunction · 0.68