提交 1d7b34f4 编写于 作者: Nameless-Y's avatar Nameless-Y

[components][dataqueue]修改is_init为magic数

上级 dfcd38b7
......@@ -22,10 +22,11 @@ struct rt_data_item;
/* data queue implementation */
struct rt_data_queue
{
rt_uint32_t magic;
rt_uint16_t size;
rt_uint16_t lwm;
rt_bool_t waiting_lwm;
rt_bool_t is_init;
rt_uint16_t get_index;
rt_uint16_t put_index;
......
......@@ -13,6 +13,8 @@
#include <rtdevice.h>
#include <rthw.h>
#define DATAQUEUE_MAGIC 0xbead0e0e
struct rt_data_item
{
const void *data_ptr;
......@@ -29,9 +31,9 @@ rt_data_queue_init(struct rt_data_queue *queue,
queue->evt_notify = evt_notify;
queue->magic = DATAQUEUE_MAGIC;
queue->size = size;
queue->lwm = lwm;
queue->is_init = RT_TRUE;
queue->get_index = 0;
queue->put_index = 0;
......@@ -58,11 +60,7 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
rt_thread_t thread;
rt_err_t result;
if(queue->is_init != RT_TRUE)
{
return RT_ERROR;
}
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(queue != RT_NULL);
result = RT_EOK;
......@@ -152,11 +150,7 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
rt_thread_t thread;
rt_err_t result;
if(queue->is_init != RT_TRUE)
{
return RT_ERROR;
}
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(queue != RT_NULL);
RT_ASSERT(data_ptr != RT_NULL);
RT_ASSERT(size != RT_NULL);
......@@ -256,11 +250,7 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue,
{
rt_ubase_t level;
if(queue->is_init != RT_TRUE)
{
return RT_ERROR;
}
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(queue != RT_NULL);
level = rt_hw_interrupt_disable();
......@@ -286,10 +276,7 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
struct rt_thread *thread;
register rt_ubase_t temp;
if(queue->is_init != RT_TRUE)
{
return;
}
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
rt_enter_critical();
/* wakeup all suspend threads */
......@@ -351,11 +338,7 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
{
rt_ubase_t level;
if(queue->is_init != RT_TRUE)
{
return RT_ERROR;
}
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(queue != RT_NULL);
level = rt_hw_interrupt_disable();
......@@ -363,7 +346,7 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
/* wakeup all suspend threads */
rt_data_queue_reset(queue);
queue->is_init = RT_FALSE;
queue->magic = 0;
rt_free(queue->queue);
rt_hw_interrupt_enable(level);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册