/* Change Logs: Date Author Notes  armink the first version  xqyjlj perf rt_hw_interrupt_disable/enable ring block buffer object initialization */
void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num)
/* Change Logs: Date Author Notes  armink the first version  xqyjlj perf rt_hw_interrupt_disable/enable ring block buffer object initialization */
void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num)
{
    rt_size_t i;
    RT_ASSERT(rbb);
    RT_ASSERT(buf);
    RT_ASSERT(block_set);
    rbb->buf = buf;
    rbb->buf_size = buf_size;
    rbb->blk_set = block_set;
    rbb->blk_max_num = blk_max_num;
    rbb->tail = &rbb->blk_list;
    rt_slist_init(&rbb->blk_list);
    rt_slist_init(&rbb->free_list);
    for (i = 0; i < blk_max_num; i++)
    {
        block_set[i].status = RT_RBB_BLK_UNUSED;
        rt_slist_init(&block_set[i].list);
        rt_slist_insert(&rbb->free_list, &block_set[i].list);
    }
    rt_spin_lock_init(&(rbb->spinlock));
}