freeRTOS的数据类型定义(portmacro.h文件里)

news2024/11/16 9:35:05

freeRTOS的数据类型定义(portmacro.h文件里)
解读:
https://www.bilibili.com/video/BV1n8411y7DF/?buvid=XY4F2994565924F2FFA7142AEEB2220A602A4&is_story_h5=false&mid=%2B8iBjJuKH0VIWaMd8h0wSQ%3D%3D&p=1&plat_id=114&share_from=ugc&share_medium=android&share_plat=android&share_session_id=1aaba7b3-09dc-4ae9-a31f-7400aa75af10&share_source=QQ&share_tag=s_i&timestamp=1696659412&unique_k=z6Cmkld&up_id=394425633
1.变量名和函数名
在这里插入图片描述
在这里插入图片描述
2.宏定义
在这里插入图片描述

代码:

/*
 * FreeRTOS Kernel V10.4.6
 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * https://www.FreeRTOS.org
 * https://github.com/FreeRTOS
 *
 */

#ifndef PORTMACRO_H
    #define PORTMACRO_H

    #ifdef __cplusplus
        extern "C" {
    #endif

/*------------------------------------------------------------------------------
 * Port specific definitions.
 *
 * The settings in this file configure FreeRTOS correctly for the given hardware
 * and compiler.
 *
 * These settings should not be altered.
 *------------------------------------------------------------------------------
 */

    #ifndef configENABLE_FPU
        #error configENABLE_FPU must be defined in FreeRTOSConfig.h.  Set configENABLE_FPU to 1 to enable the FPU or 0 to disable the FPU.
    #endif /* configENABLE_FPU */

    #ifndef configENABLE_MPU
        #error configENABLE_MPU must be defined in FreeRTOSConfig.h.  Set configENABLE_MPU to 1 to enable the MPU or 0 to disable the MPU.
    #endif /* configENABLE_MPU */

    #ifndef configENABLE_TRUSTZONE
        #error configENABLE_TRUSTZONE must be defined in FreeRTOSConfig.h.  Set configENABLE_TRUSTZONE to 1 to enable TrustZone or 0 to disable TrustZone.
    #endif /* configENABLE_TRUSTZONE */

/*-----------------------------------------------------------*/

/**
 * @brief Type definitions.
 */
    #define portCHAR          char
    #define portFLOAT         float
    #define portDOUBLE        double
    #define portLONG          long
    #define portSHORT         short
    #define portSTACK_TYPE    uint32_t
    #define portBASE_TYPE     long

    typedef portSTACK_TYPE   StackType_t;
    typedef long             BaseType_t;
    typedef unsigned long    UBaseType_t;

    #if ( configUSE_16_BIT_TICKS == 1 )
        typedef uint16_t     TickType_t;
        #define portMAX_DELAY              ( TickType_t ) 0xffff
    #else
        typedef uint32_t     TickType_t;
        #define portMAX_DELAY              ( TickType_t ) 0xffffffffUL

/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
 * not need to be guarded with a critical section. */
        #define portTICK_TYPE_IS_ATOMIC    1
    #endif
/*-----------------------------------------------------------*/

/**
 * Architecture specifics.
 */
    #define portARCH_NAME                      "Cortex-M23"
    #define portSTACK_GROWTH                   ( -1 )
    #define portTICK_PERIOD_MS                 ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
    #define portBYTE_ALIGNMENT                 8
    #define portNOP()
    #define portINLINE                         __inline
    #ifndef portFORCE_INLINE
        #define portFORCE_INLINE               inline __attribute__( ( always_inline ) )
    #endif
    #define portHAS_STACK_OVERFLOW_CHECKING    1
    #define portDONT_DISCARD                   __attribute__( ( used ) )
/*-----------------------------------------------------------*/

/**
 * @brief Extern declarations.
 */
    extern BaseType_t xPortIsInsideInterrupt( void );

    extern void vPortYield( void ) /* PRIVILEGED_FUNCTION */;

    extern void vPortEnterCritical( void ) /* PRIVILEGED_FUNCTION */;
    extern void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */;

    extern uint32_t ulSetInterruptMask( void ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */;
    extern void vClearInterruptMask( uint32_t ulMask ) /* __attribute__(( naked )) PRIVILEGED_FUNCTION */;

    #if ( configENABLE_TRUSTZONE == 1 )
        extern void vPortAllocateSecureContext( uint32_t ulSecureStackSize ); /* __attribute__ (( naked )) */
        extern void vPortFreeSecureContext( uint32_t * pulTCB ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */;
    #endif /* configENABLE_TRUSTZONE */

    #if ( configENABLE_MPU == 1 )
        extern BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */;
        extern void vResetPrivilege( void ) /* __attribute__ (( naked )) */;
    #endif /* configENABLE_MPU */
/*-----------------------------------------------------------*/

/**
 * @brief MPU specific constants.
 */
    #if ( configENABLE_MPU == 1 )
        #define portUSING_MPU_WRAPPERS    1
        #define portPRIVILEGE_BIT         ( 0x80000000UL )
    #else
        #define portPRIVILEGE_BIT         ( 0x0UL )
    #endif /* configENABLE_MPU */


/* MPU regions. */
    #define portPRIVILEGED_FLASH_REGION                   ( 0UL )
    #define portUNPRIVILEGED_FLASH_REGION                 ( 1UL )
    #define portUNPRIVILEGED_SYSCALLS_REGION              ( 2UL )
    #define portPRIVILEGED_RAM_REGION                     ( 3UL )
    #define portSTACK_REGION                              ( 4UL )
    #define portFIRST_CONFIGURABLE_REGION                 ( 5UL )
    #define portLAST_CONFIGURABLE_REGION                  ( 7UL )
    #define portNUM_CONFIGURABLE_REGIONS                  ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 )
    #define portTOTAL_NUM_REGIONS                         ( portNUM_CONFIGURABLE_REGIONS + 1 )   /* Plus one to make space for the stack region. */

/* Device memory attributes used in MPU_MAIR registers.
 *
 * 8-bit values encoded as follows:
 *  Bit[7:4] - 0000 - Device Memory
 *  Bit[3:2] - 00 --> Device-nGnRnE
 *				01 --> Device-nGnRE
 *				10 --> Device-nGRE
 *				11 --> Device-GRE
 *  Bit[1:0] - 00, Reserved.
 */
    #define portMPU_DEVICE_MEMORY_nGnRnE                  ( 0x00 )   /* 0000 0000 */
    #define portMPU_DEVICE_MEMORY_nGnRE                   ( 0x04 )   /* 0000 0100 */
    #define portMPU_DEVICE_MEMORY_nGRE                    ( 0x08 )   /* 0000 1000 */
    #define portMPU_DEVICE_MEMORY_GRE                     ( 0x0C )   /* 0000 1100 */

/* Normal memory attributes used in MPU_MAIR registers. */
    #define portMPU_NORMAL_MEMORY_NON_CACHEABLE           ( 0x44 )   /* Non-cacheable. */
    #define portMPU_NORMAL_MEMORY_BUFFERABLE_CACHEABLE    ( 0xFF )   /* Non-Transient, Write-back, Read-Allocate and Write-Allocate. */

/* Attributes used in MPU_RBAR registers. */
    #define portMPU_REGION_NON_SHAREABLE                  ( 0UL << 3UL )
    #define portMPU_REGION_INNER_SHAREABLE                ( 1UL << 3UL )
    #define portMPU_REGION_OUTER_SHAREABLE                ( 2UL << 3UL )

    #define portMPU_REGION_PRIVILEGED_READ_WRITE          ( 0UL << 1UL )
    #define portMPU_REGION_READ_WRITE                     ( 1UL << 1UL )
    #define portMPU_REGION_PRIVILEGED_READ_ONLY           ( 2UL << 1UL )
    #define portMPU_REGION_READ_ONLY                      ( 3UL << 1UL )

    #define portMPU_REGION_EXECUTE_NEVER                  ( 1UL )
/*-----------------------------------------------------------*/

/**
 * @brief Settings to define an MPU region.
 */
    typedef struct MPURegionSettings
    {
        uint32_t ulRBAR; /**< RBAR for the region. */
        uint32_t ulRLAR; /**< RLAR for the region. */
    } MPURegionSettings_t;

/**
 * @brief MPU settings as stored in the TCB.
 */
    typedef struct MPU_SETTINGS
    {
        uint32_t ulMAIR0;                                              /**< MAIR0 for the task containing attributes for all the 4 per task regions. */
        MPURegionSettings_t xRegionsSettings[ portTOTAL_NUM_REGIONS ]; /**< Settings for 4 per task regions. */
    } xMPU_SETTINGS;
/*-----------------------------------------------------------*/

/**
 * @brief SVC numbers.
 */
    #define portSVC_ALLOCATE_SECURE_CONTEXT    0
    #define portSVC_FREE_SECURE_CONTEXT        1
    #define portSVC_START_SCHEDULER            2
    #define portSVC_RAISE_PRIVILEGE            3
/*-----------------------------------------------------------*/

/**
 * @brief Scheduler utilities.
 */
    #define portYIELD()                                 vPortYield()
    #define portNVIC_INT_CTRL_REG     ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
    #define portNVIC_PENDSVSET_BIT    ( 1UL << 28UL )
    #define portEND_SWITCHING_ISR( xSwitchRequired )    do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
    #define portYIELD_FROM_ISR( x )                     portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/

/**
 * @brief Critical section management.
 */
    #define portSET_INTERRUPT_MASK_FROM_ISR()         ulSetInterruptMask()
    #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x )    vClearInterruptMask( x )
    #define portDISABLE_INTERRUPTS()                  __asm volatile ( " cpsid i " ::: "memory" )
    #define portENABLE_INTERRUPTS()                   __asm volatile ( " cpsie i " ::: "memory" )
    #define portENTER_CRITICAL()                      vPortEnterCritical()
    #define portEXIT_CRITICAL()                       vPortExitCritical()
/*-----------------------------------------------------------*/

/**
 * @brief Tickless idle/low power functionality.
 */
    #ifndef portSUPPRESS_TICKS_AND_SLEEP
        extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
        #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )    vPortSuppressTicksAndSleep( xExpectedIdleTime )
    #endif
/*-----------------------------------------------------------*/

/**
 * @brief Task function macros as described on the FreeRTOS.org WEB site.
 */
    #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )
    #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )
/*-----------------------------------------------------------*/

    #if ( configENABLE_TRUSTZONE == 1 )

/**
 * @brief Allocate a secure context for the task.
 *
 * Tasks are not created with a secure context. Any task that is going to call
 * secure functions must call portALLOCATE_SECURE_CONTEXT() to allocate itself a
 * secure context before it calls any secure function.
 *
 * @param[in] ulSecureStackSize The size of the secure stack to be allocated.
 */
        #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize )    vPortAllocateSecureContext( ulSecureStackSize )

/**
 * @brief Called when a task is deleted to delete the task's secure context,
 * if it has one.
 *
 * @param[in] pxTCB The TCB of the task being deleted.
 */
        #define portCLEAN_UP_TCB( pxTCB )                           vPortFreeSecureContext( ( uint32_t * ) pxTCB )
    #endif /* configENABLE_TRUSTZONE */
/*-----------------------------------------------------------*/

    #if ( configENABLE_MPU == 1 )

/**
 * @brief Checks whether or not the processor is privileged.
 *
 * @return 1 if the processor is already privileged, 0 otherwise.
 */
        #define portIS_PRIVILEGED()      xIsPrivileged()

/**
 * @brief Raise an SVC request to raise privilege.
 *
 * The SVC handler checks that the SVC was raised from a system call and only
 * then it raises the privilege. If this is called from any other place,
 * the privilege is not raised.
 */
        #define portRAISE_PRIVILEGE()    __asm volatile ( "svc %0 \n" ::"i" ( portSVC_RAISE_PRIVILEGE ) : "memory" );

/**
 * @brief Lowers the privilege level by setting the bit 0 of the CONTROL
 * register.
 */
        #define portRESET_PRIVILEGE()    vResetPrivilege()
    #else
        #define portIS_PRIVILEGED()
        #define portRAISE_PRIVILEGE()
        #define portRESET_PRIVILEGE()
    #endif /* configENABLE_MPU */
/*-----------------------------------------------------------*/

/**
 * @brief Barriers.
 */
    #define portMEMORY_BARRIER()    __asm volatile ( "" ::: "memory" )
/*-----------------------------------------------------------*/

    #ifdef __cplusplus
        }
    #endif

#endif /* PORTMACRO_H */

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1067133.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

铭控传感亮相2023国际物联网展,聚焦“多场景物联感知方案”应用

金秋九月&#xff0c;聚焦IoT基石技术&#xff0c;荟萃最全物联感知企业&#xff0c;齐聚IOTE 2023第20届国际物联网展深圳站。铭控传感携智慧楼宇&#xff0c;数字工厂&#xff0c;智慧消防&#xff0c;智慧泵房等多场景物联感知方案及多品类无线传感器闪亮登场&#xff0c;现…

windows内核编程(2021年出版)笔记

1. Windows内部概览 1.1 进程 进程包含以下内容&#xff1a; 可执行程序&#xff0c;代码和数据私有的虚拟地址空间&#xff0c;分配内存时从这里分配主令牌&#xff0c;保存进程默认安全上下文&#xff0c;进程中的线程执行代码时会用到它私有句柄表&#xff0c;保存进程运…

C语言之共用体、枚举类型、typedef

共用体 共用体的所有成员共享同一个内存地址 插入一个知识点&#xff1a;字符串不可以直接赋值&#xff0c;要不就在定义的时候赋值&#xff0c;要不就只能使用scanf函数赋值或者<string>中的strcpy赋值 证明 如果要同时访问联合体中多个成员的值...... 则会出现以下情…

自动化项目实战->测试博客系统

1.熟悉项目-->哪些场景容易出现问题 2.针对核心流程设计测试用例(手工测试用例) 3.将手工测试用例转换为自动化测试用例 4.部署到服务器 一、针对核心流程设计测试用例 二、将手工测试用例转换为自动化测试用例 2.1设计自动化测试用例的代码结构 初始化动作:BeforeAll--…

[NISACTF 2022]popchains - 反序列化+伪协议

[NISACTF 2022]popchains 一、解题流程二、小小疑惑 一、解题流程 1、链条&#xff1a;Road_is_Long&#xff08;construct->wakeup【page$r】-> toString【string$m】&#xff09;-> Make_a_Change&#xff08;construct->get【effort$t】&#xff09;-> Try_W…

数据压缩与管理:掌握Linux VDO和LVM的力量

1.逻辑卷(LVM&#xff0c;Logical Volume Management) 动态的为服务器磁盘添加空间&#xff0c;而不会影响原磁盘的数据&#xff0c;也不需要对原始磁盘重新分区。 1.1 LVM介绍 以下是LVM的示意图&#xff1a; 我们拿到一块硬盘后首先对齐进行划分分区&#xff0c;也就得到…

Web:前端常用的几种Http请求GET和POST样例

1、简述 在Web开发过程中&#xff0c;少不了发起Http请求服务端的接口数据&#xff0c;在不同的框架中使用了不同的Http请求方式&#xff0c;常用的请求有fetch、 ajax、 axios、XMLHttpRequest、request&#xff0c;以下样例仅供参考。 2、Fetch Fetch API 是一种 JavaScr…

Redis的五种常用数据类型

1.字符串 String的数据结构是简单的Key-Value模型&#xff0c;Value可以是字符串&#xff0c;也可以是数字。 String是Redis最基本的类型&#xff0c;是二进制安全的&#xff0c;意味着Redis的string可以包含任何数据&#xff0c;比如jpg图片。 一个redis中字符串value最大是…

光伏系统MPPT、恒功率控制切换Simulink仿真

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

从0开始学go第五天

gin框架返回JSON package mainimport ("net/http""github.com/gin-gonic/gin" )func main() {r : gin.Default()r.GET("/json", func(c *gin.Context) {//用map序列化//方法一&#xff1a;用map&#xff0c;后面用接口类型// data : map[string…

电视盒子什么品牌好?内行分享权威电视盒子品牌排行榜

因工作关系每天都会接触到各种类型的电视盒子&#xff0c;对整个行业可以说了如指掌&#xff0c;身边朋友们在挑选电视盒子时也会问我电视盒子什么品牌好&#xff0c;哪些电视盒子值得入手&#xff0c;今天我来分享业内公认最权威的电视盒子品牌排行榜&#xff1a; TOP 1.泰捷超…

使用 labelImg 制作YOLO系列目标检测数据集(.xml文件)

文章转载自K同学&#xff0c;谨防原文失效 第一步&#xff1a; WIN键R 输入cmd 打开命令行窗口 第二步&#xff1a; 在命令行窗口中输入pip3 install labelImg&#xff0c;安装 labelImg 第三步&#xff1a; 输入labelImg 打开labelImg窗口 第四步&#xff1a; ✨ 标注小技巧…

Edge浏览器无法下载RP插件问题解决方案

1、进入本地C:\Windows\System32\drivers\etc 2、编辑hosts文件&#xff0c;在最后结尾加入以下内容 131.253.33.219 edge.microsoft.com 131.253.33.219 msedgeextensions.sf.tlu.dl.delivery.mp.microsoft.com3、进入 https://microsoftedge.microsoft.com/addons/search/RP…

背靠背 HVDC-MMC模块化多电平转换器输电系统-用于无源网络系统的电能质量调节(Simulink仿真实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

网络安全——黑客自学(笔记)

想自学网络安全&#xff08;黑客技术&#xff09;首先你得了解什么是网络安全&#xff01;什么是黑客&#xff01;&#xff01;&#xff01; 网络安全可以基于攻击和防御视角来分类&#xff0c;我们经常听到的 “红队”、“渗透测试” 等就是研究攻击技术&#xff0c;而“蓝队…

【技术干货】如何通过 DP 实现支持经典蓝牙的联网单品设备与 App 配对

经典蓝牙模块&#xff08;Classic Bluetooth&#xff09;主要用于呼叫和音频传输&#xff0c;所以经典蓝牙最主要的特点就是功耗大&#xff0c;传输数据量大。蓝牙耳机、蓝牙音箱等场景大多采用经典蓝牙&#xff0c;因为蓝牙是为传输声音而设计的&#xff0c;是短距离音频传输的…

【ORM】浅聊C#和Java的ORM底层框架

给自己一个目标&#xff0c;然后坚持一段时间&#xff0c;总会有收获和感悟&#xff01; 国庆假期马上结束&#xff0c;闲暇时间&#xff0c;突然对Ado.Net这个词的由来感兴趣&#xff0c;然后就一顿复习了一遍&#xff0c;顺便也了解了下java关于ORM框架的底层是什么&#xff…

隐式转换导致慢sql引起的性能问题

背景: 环境上有个接口压测吞读量一直上不去,该接口的逻辑大概是查询我方数据库2个表,然后调用外围2个接口 分析过程: 1.问题1(gap时间) a. 查看调用链发现调用链存在大量gap时间,这种gap时间一般就是资源没了,比如等待获取连接池,或者gc回收等待,归根接底都是…

数据结构----结构--非线性结构--图

数据结构----结构–非线性结构–图 一.图&#xff08;Graph&#xff09; 1.图的结构 图是多对多的结构 2.图的基本概念 图的基本概念为G(V,E) V是顶点的集合 E是边的集合 G是图 一个图其实是顶点和边的二元组合 观察下图,思考V和E集合中的元素分别都是什么 V{V1,V2,V…

一篇理解http协议

一、http协议。 HTTP&#xff08;Hypertext Transfer Protocol&#xff0c;超文本传输协议&#xff09;是一种在Web中广泛使用的应用层协议&#xff0c;它定义了客户端和服务器之间的通信规则&#xff0c;简化了Web应用程序的开发和交互过程。其实传输是由TCP协议完成的。 HT…