/* get a block from the ring block buffer object */
rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb)
/* get a block from the ring block buffer object */
rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb)
{
    rt_base_t level;
    rt_rbb_blk_t block = RT_NULL;
    rt_slist_t *node;
    RT_ASSERT(rbb);
    if (rt_slist_isempty(&rbb->blk_list))
        return 0;
    level = rt_spin_lock_irqsave(&(rbb->spinlock));
    for (node = rt_slist_first(&rbb->blk_list); node; node = rt_slist_next(node))
    {
        block = rt_slist_entry(node, struct rt_rbb_blk, list);
        if (block->status == RT_RBB_BLK_PUT)
        {
            block->status = RT_RBB_BLK_GET;
            goto __exit;
        }
    }
    block = RT_NULL;
__exit:
    rt_spin_unlock_irqrestore(&(rbb->spinlock), level);
    return block;
}