FreeRTOS 数据类型和代码风格

FreeRTOS数据类型和代码风格

数据类型

TickType_t

TickType_t作为tick count的数据类型,他可以是unsigned 16/32的值(通过configUSE_16_BIT_TICKS宏定义配置),在8/16位单片机上,16bit的类型能很大程度上提高性能,但是在32位处理器上,一般不建议使用16位。

BaseType_t

BaseType_t一般用于boolean返回值(pdTRUE/pdFALSE),16位处理器对应16位,32位处理器对应32位的值。

注意

由于不同编译器对未指明的char的编译可能是unsigned也可能是signed,所以在FreeRTOS都会显式声明字符的类型为signed/unsigned,ASCII字符或者指针除外。

直接用int类型的情况不存在,都会指明是有无符号数。

命名

变量

命名 符号
c char
s int16_t(short)
l int32_t(long)
x BaseType_t and any other non-standard types (structures, task handles, queue handles, etc.

对于无符号数,前缀加u; 对于指针,前缀加p。
For example, a variable of type uint8_t will be prefixed with ‘uc’, and a variable of type pointer to char will be prefixed with ‘pc’.

函数

函数名前缀是他的返回值类型
例如:
在这里插入图片描述
如果不是全局函数,函数作用域仅在本文件中,即private function, 那么前缀加prv

宏定义

大多数宏定义是前缀小写名称大写的,前缀代表宏定义的定义位置。
在这里插入图片描述
在这里插入图片描述

发布了85 篇原创文章 · 获赞 17 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/lun55423/article/details/105653384