FreeRTOS Reference Manual v10 1.1笔记

一些手册中的关键信息。

  1. API函数被分为五类

    1. task and scheduler related functions
    2. queue related functions
    3. semaphore related functions
    4. software timer related functions
    5. event group related functions
  2. 各类简写

    API → Application Programming Interface ISR → Interrupt Service Routine MPU → Memory Protection Unit RTOS → Real-time Operating System

  3. Data Types (Appendix 1)

    每个FreeRTOS的发行版都会带一个专有的portmacro.h头文件,其中会定义TickType_t以及BaseType_t

    1. TickType_t:用于存储tick count 基于configUSE_16_BIT_TICKS的配置,这个类型可以是16位或32位。官方建议尽可能用一个较大的类型去存储。

    2. BaseType_t:基于架构位数而变化,8/16/32位。

      通用类型,用于存储有限范围值或布尔值。

    3. 除了以上两个类型外,C语言标准类型都不使用,除了char可以仅用于存储ASCII字符串。

      其他类型改用stdint.h中的定长类型,如uint8_t

  4. Variable Names (Appendix 1)

    FreeRTOS中的变量名都带有前缀。

    1. c for char
    2. l for long
    3. x for BaseType_t and any other types (structures, task handles, queue handles, etc.)
    4. u for unsigned
    5. p for pointer

    如:unsigned char → uc, pointer to char → pc

  5. Function Names (Appendix 1)

    函数前缀代表其返回值的类型。

    File scope (private) functions are prefixed with ‘prv’.

  6. Macro Names (Appendix 1)

    大多数宏(macro)使用全大写字母书写,并且在宏名前加上小写字母前缀,用来表明该宏是在哪个文件或模块中定义的。

    port → portable.h

    task → task.h

    pd → projdefs.h

    config → FreeRTOSConfig.h

    err → projdefs.h

  7. 过多类型转换的理由

    FreeRTOS 源代码可以使用许多不同的编译器进行编译,而这些编译器在何时以及如何产生警告信息方面各不相同。

    尤其是,不同的编译器对于类型转换(casting)的使用方式要求不同。

    因此,FreeRTOS 的源代码中包含了比通常情况下更多的类型转换。

  8. 未使用FromISR标注的函数不可用于ISR中。

    部分FreeRTOS移植会进一步限制FromISR标注的函数也不可用于优先级高于configMAX_SYSCALL_INTERRUPT_PRIORITY/configMAX_API_CALL_INTERRUPT_PRIORITY的ISR。

  9. 在调度器被挂起(suspended)期间,不能调用那些可能导致上下文切换(context switch)的API 函数。

  10. 在临界区(critical section)内,不能调用那些可能导致上下文切换(context switch)的 API 函数。

卡片 ID: freertos-reference-namual-1-1