如果队列创建成功,将返回一个有效的队列句柄(QueueHandle_t类型)。 如果队列创建失败,返回值将为NULL。 使用示例: xStaticQueue_txQueueBuffer;StaticQueue_t xStaticQueue;QueueHandle_t xQueue;xQueue=xQueueCreateStatic(QUEUE_LENGTH,ITEM_SIZE,xQueueBuffer.ucQueueStorage,&xStaticQueue);if(xQueue==NULL){/...
#include "FreeRTOS.h" #include "queue.h" uint8_t ucQueueStorage[100]; // 预分配的存储空间 StaticQueue_t xStaticQueue; // 静态队列控制块 QueueHandle_t xQueue; int main(void) { xQueue = xQueueGenericCreateStatic(5, sizeof(int32_t), ucQueueStorage, &xStaticQueue, 0); if(xQueue ...
uint8_t *pucQueueStorage,//指向队列项的存储区 StaticQueue_t *pxStaticQueue,//用来保存队列结构体 const uint8_t ucQueueType);//队列类型 /***/ 返回值:创建成功返回队列句柄;失败返回NULL 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 动态创建...
有一个结构体用于描述队列,叫做 Queue_t,这个结构体在文件 queue.c 中定义。 3、队列创建 在使用队列之前必须先创建队列,有两种创建队列的方法,一种是静态的,使用函数xQueueCreateStatic();另一个是动态的,使用函数 xQueueCreate()。这两个函数本质上都是宏,真正完成队列创建的函数是 xQueueGenericCreate()和 ...
StaticQueue_t *pxQueueBuffer); /*example:创建一个深度为5,队列单元占uint16_t大小队列*/ QueueHandle_t QueueHandleTest; QueueHandleTest = xQueueCreate(5, sizeof(uint16_t)); 3.3、向队列写入数据 任务或者中断向队列写入数据称为发送消息。通常情况下,队列被作为 FIFO(先入先出)使用,即数据由队列尾...
pxQueueBuffer 必须执行一个StaticQueue_t结构体,用来保存队列的数据结构 返回值 非0:成功,返回句柄,以后使用句柄来操作队列NULL:失败,因为pxQueueBuffer为NULL 示例代码: 代码语言:javascript 复制 // 示例代码 #define QUEUE_LENGTH 10 #define ITEM_SIZE sizeof( uint32_t ) // xQueueBuffer用来保存队列结构体...
static QueueHandle_t xQueue2 = NULL; typedef struct Msg { uint8_t ucMessageID; uint16_t usData[2]; uint32_t ulData[2]; }MSG_T; MSG_T g_tMsg; /* *** * 函数名: AppObjCreate * 功能说明: 创建任务通信机制 * 形参: 无 * 返回值: 无 ***...
// 动态创建队列QueueHandle_txQueueCreate(UBaseType_t uxQueueLength, UBaseType_t uxItemSize);// 静态创建队列QueueHandle_txQueueCreateStatic(UBaseType_t uxQueueLength, UBaseType_t uxItemSize,uint8_t*pucQueueStorageBuffer, StaticQueue_t *pxQueueBuffer);// 删除动态创建的队列voidvQueueDelete(...
作用:静态分配queue内存 函数原型:QueueHandle_t xQueueCreateStatic( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t *pucQueueStorageBuffer, StaticQueue_t *pxQueueBuffer ); 参数:uxQueueLength 队列长度,最多能存放多少个数据(item) ...
消息队列控制块本质上是一个结构体。 typedef struct QueueDefinition { int8_t *pcHead; /*< Points to the beginning of the queue storage area. */ int8_t *pcTail; /*< Points to the byte a…