FREERTOS-简化版消息队列

此处消息队列源自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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

oshan2012

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值