FreeRTOS学习记录 04--队列篇

本文详细介绍了FreeRTOS中队列的基础知识,包括Queue_t结构体及其初始化,以及动态创建队列的过程。重点讲解了xQueueGenericSend()和xQueueGenericReceive()的实现,阐述了入队和出队的逻辑。此外,还简要提及了信号量,如二值信号量、优先级翻转和互斥信号量的概念及其在队列操作中的作用。
摘要由CSDN通过智能技术生成

0 前言

@ Author         :Dargon
@ Record Date    :2021/07/13
@ Reference Book : `FreeRTOS源码详解与应用开发`,`ARM Cortex-M3与Cortex-M4权威指南`,`B站正点原子FreeRTOS讲解视频`
@ Purpose        :学习正点原子的miniFly,该飞控基于FreeRTOS系统开发的,所以学习一下记录下关于RTOS系统的一些基本操作,大概了解系统的工作原理,如何创建,运行,切换任务等等基本操作流程。在此进行学习的记录。

1 队列的基础知识

1.1 队列 Queue_t

  • 结构体 Queue_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. */
    
        union							/* Use of a union is an exception to the coding standard to ensure two mutually exclusive structure members don't appear simultaneously (wasting RAM). */
        {
         
            int8_t *pcReadFrom;			/*< Points to the last place that a queued item was read from when the structure is used as a queue. */
            UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */
        } u;
    
        List_t xTasksWaitingToSend;		/*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */
        List_t xTasksWaitingToReceive;	/*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */
    
        volatile UBaseType_t uxMessagesWaiting;/*< The number of items currently in the queue. */
        UBaseType_t uxLength;			
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值