|
RT-Thread_2.0.0alpha
rt_inline void serial_ringbuffer_putc(struct serial_ringbuffer *rbuffer,
char ch)
{
rt_base_t level;
/* disable interrupt */
level = rt_hw_interrupt_disable();
rbuffer->buffer[rbuffer->put_index] = ch;
rbuffer->put_index = (rbuffer->put_index + 1) & (RT_SERIAL_RB_BUFSZ - 1);
/* if the next position is read index, discard this 'read char' */
if (rbuffer->put_index == rbuffer->get_index)
{
rbuffer->get_index = (rbuffer->get_index + 1) & (RT_SERIAL_RB_BUFSZ - 1);
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
}
#ifndef RT_SERIAL_RB_BUFSZ
#define RT_SERIAL_RB_BUFSZ 64
#endif
如果把RT_SERIAL_RB_BUFSZ定义100(非2的N次方数)上面的函数是不是有问题? |
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|