freertos.h 内容解读
1、包含两个标准头文件
stddef.h
stdint.h
https://www.cnblogs.com/zhangzhiwei122/p/15758274.html freestanding implemantion需要提供 <float.h> <limits.h> <stdargs.h> 和 <stddef.h> AMD1 标准后,再增加一个 <iso646.h> C99 标准后,增加<stdbool.h> 和 <stdint.h> C11 标准后,增加 <stdalign.h> 和 <stdnoreturn.h>
|
2、用户配置
/* Application specific configuration options. */
#include "FreeRTOSConfig.h"
3、rtos 源码内部通用定义
/* Basic FreeRTOS definitions. */
#include "projdefs.h"
4、移植重定义
/* Definitions specific to the port being used. */
#include "portable.h"
下面就是:
1、configUSE_NEWLIB_REENTRANT 宏的检查和完善,如果为1,则会include reent.h
2、根据已有的定义,做兼容性检查
/* * Check all the required application specific macros have been defined. * These macros are application specific and (as downloaded) are defined * within FreeRTOSConfig.h. */ #ifndef configMINIMAL_STACK_SIZE #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. #endif |
2、补充用户配置中没有的宏定义,定义为默认值
#ifndef configMAX_TASK_NAME_LEN #define configMAX_TASK_NAME_LEN 16 #endif
#ifndef configIDLE_SHOULD_YIELD #define configIDLE_SHOULD_YIELD 1 #endif |
3、一些dummy结构体定义
/* * In line with software engineering best practice, FreeRTOS implements a strict * data hiding policy, so the real structures used by FreeRTOS to maintain the * state of tasks, queues, semaphores, etc. are not accessible to the application * code. However, if the application writer wants to statically allocate such * an object then the size of the object needs to be know. Dummy structures * that are guaranteed to have the same size and alignment requirements of the * real objects are used for this purpose. The dummy list and list item * structures below are used for inclusion in such a dummy structure. */
根据最佳实践、rtos 源码实现了数据隐藏。 rtos 用于维护 task queues semaphores 状态的数据结构对于应用开发(使用rtos)是不可访问的。但是,有时使用rtos 时,需要静态分配一个用户维护系统状态对象,就需要用到对应的数据结构定义。下面就是一些保持了对齐和大小的假的 数据结构定义,rtos 使用者可以使用这些假的结构体定义来定义对象。
struct xSTATIC_LIST_ITEM { TickType_t xDummy1; void *pvDummy2[ 4 ]; }; typedef struct xSTATIC_LIST_ITEM StaticListItem_t; |