According to statistics from a research institution, currently FreeRTOS has the highest market share in the global RTOS market. Of course, we do not know the specific methods of this statistic, but FreeRTOS is indeed very active.
Here, I would like to ask everyone, do you have many friends or colleagues around you who use FreeRTOS?
Next, I will share the coding standards and specifications for FreeRTOS.
FreeRTOS Coding Standards
The kernel versions before FreeRTOS V11.0 conform to the MISRA C:2004 coding standards. However, the latest FreeRTOS kernel follows the MISRA C:2012 coding standards.
What is the MISRA C:2012 coding standard? You can refer to my previous article: “MISRA C: 2012 What Standard Is It?“.
MISRA C is a C language development standard proposed by the Motor Industry Software Reliability Association (MISRA). Its purpose is to enhance the safety and portability of embedded systems, and there are corresponding standards for C++ called MISRA C++.
Since FreeRTOS is built using various compilers, many of which are relatively advanced, FreeRTOS does not use C99 or other standards but adopts the more stringent MISRA C coding standards.
Due to the use of the MISRA C:2004 coding standards in the kernel versions before FreeRTOS V11.0, there may be some deviations from the MISRA standards when performing static code analysis using the PC-Lint tool.
FreeRTOS Coding Specifications
Different RTOS have different naming conventions, and generally speaking, if a company has higher requirements for code quality, there will be internal coding specifications.
Here are some common coding specifications for FreeRTOS.
1. Variables
uint8_t type variables should have a prefix of uc, where “u” stands for “unsigned” and “c” stands for “char”.
uint16_t type variables should have a prefix of us, where “u” stands for “unsigned” and “s” stands for “short”.
uint32_t type variables should have a prefix of ul, where “u” stands for “unsigned” and “l” stands for “long”.
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
static uint32_t ulTotalRunTime = 0UL;
size_t type variables should have a prefix of x, for example:
static size_t xFreeBytesRemaining = 0U;
However, size_t is actually mostly defined as “unsigned int”, so size_t type variables can also have a prefix of ux.
Enumeration variables should have a prefix of e.
Pointer variables should have an additional prefix of p.
2. Functions
Static or private functions should have a prefix of prv.
static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
API functions that return void should have a prefix of v.
void vApplicationTickHook( void );
3. Macro Definitions
Macro definitions should generally have the prefix of the file defining the macro, and the prefix should be in lowercase.
For example, defined in FreeRTOSConfig.h.
#define configUSE_PREEMPTION 1
Other than the prefix, macro definitions should be written in uppercase letters, with underscores used to separate words.
4. Data Types
The primary types used are from stdint.h and typedefs provided by RTOS, but there are a few exceptions.
5. Indentation
Use four space characters for indentation.
6. Comments
Comments should generally be made using /* */ format, and comments should never exceed the 80th column.
Due to time constraints, I can only share some major content here. For more coding specifications, you still need to read the source code yourself to understand.
In fact, you will find that although the coding specifications differ between different RTOS, each RTOS strictly adheres to its own coding specifications, which not only facilitates its own upgrades and maintenance but also makes it easier for users to read the source code.
Apply for Free Development Board

For submissions/promotion/collaboration/joining the group, please scan the QR code to add WeChat.
(Please note your intention, if joining the group, please note your city-name-industry position information)

