/* Put a byte into the ring buffer. If ring buffer is full, this operation will fail.  */
rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
/* Put a byte into the ring buffer. If ring buffer is full, this operation will fail.  */
rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
{
    RT_ASSERT(rb != RT_NULL);
    if (!rt_ringbuffer_space_len(rb))
        return 0;
    rb->buffer_ptr[rb->write_index] = ch;
    if (rb->write_index == rb->buffer_size - 1)
    {
        rb->write_mirror = ~rb->write_mirror;
        rb->write_index = 0;
    }
    else
    {
        rb->write_index++;
    }
    return 1;
}