此处消息队列源自FREERTOS,还是采用先进先出的方式.去掉任务,信号量,等待等等功能。最后的流程打印很容易看。
// queue-01.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdlib.h"
/* exact-width signed integer types */
typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
// typedef signed __INT64 int64_t;
/* exact-width unsigned integer types */
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
// typedef unsigned __INT64 uint64_t;
typedef struct QueueDefinition
{
int8_t *pcHead; /*指向队列存储区开始地址。< Points to the beginning of the queue storage area. */
int8_t *pcTail; /*指向队列存储区最后一个字节< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */
int8_t *pcWriteTo; /*指向存储区中下一个空闲区域。< Points to the free next place in the storage area. */
int8_t *pcReadFrom; /*当用作队列的时候指向最后一个出队的队列项首地址< Points to the last place that a queued item was read from when the structure is used as a queue. */
uint32_t uxMessagesWaiting; /*队列中当前队列项数量,也就是消息数 < The number of items currently in the queue. */
uint32_t uxLength; /*创建队列时指定的队列长度,也就是队列中最大允许的队列项(消息)数量< The length of the queue defined as the number of items it will hold, not the number of bytes. */
uint32_t uxItemSize; /*创建队列时指定的每个队列项(消息)最大长度,单位字节< The size of each items that the queue will hold. */
} Queue_t;
int xQueueGenericCreateStatic(Queue_t *pxQueue,const uint32_t uxQueueLength, const uint32_t uxItemSize,uint8_t *QueueStorageHead)
{
Queue_t *const pxNewQueue = pxQueue;
//printf("xQueueGenericCreate uxQueueLength=%d uxItemSize=%d *****\r\n",uxQueueLength,uxItemSize);
if ((uxItemSize == (uint32_t)0)|| (uxQueueLength

最低0.47元/天 解锁文章
126

被折叠的 条评论
为什么被折叠?



