/* Put a byte into the ring buffer. If ring buffer is full, it will discard an old data and put into a new data.  */
rt_size_t rt_ringbuffer_putchar_force(struct rt_ringbuffer *rb, const rt_uint8_t ch)
/* Put a byte into the ring buffer. If ring buffer is full, it will discard an old data and put into a new data.  */
rt_size_t rt_ringbuffer_putchar_force(struct rt_ringbuffer *rb, const rt_uint8_t ch)
{
    enum rt_ringbuffer_state old_state;
    RT_ASSERT(rb != RT_NULL);
    old_state = rt_ringbuffer_status(rb);
    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;
        if (old_state == RT_RINGBUFFER_FULL)
        {
            rb->read_mirror = ~rb->read_mirror;
            rb->read_index = rb->write_index;
        }
    }
    else
    {
        rb->write_index++;
        if (old_state == RT_RINGBUFFER_FULL)
            rb->read_index = rb->write_index;
    }
    return 1;
}