当前位置:网站首页>Naming rules for FreeRTOS
Naming rules for FreeRTOS
2022-07-05 08:06:00 【Car chezi】
List of articles
If it's just touching FreeRTOS, See its name , It's ridiculous , Like a heavenly book . therefore , It is still necessary to understand its naming rules .
Variable
uint32_t The defined variables are prefixed ul. u representative unsigned Unsigned ,l representative long Long integer .
for example :
static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pulDestination, uint32_t ulExchange, uint32_t ulComparand )ulExchange,ulComparand this is it
uint16_t The defined variables are prefixed us. u representative unsigned Unsigned ,s representative short Short .
for example :
const uint16_t usStackDepthuint8_t The defined variables are prefixed uc. u representative unsigned Unsigned ,c representative char Character .
for example :
#if ( configUSE_TASK_NOTIFICATIONS == 1 ) uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; #endif #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) uint8_t uxDummy20; #endifucDummy19 this is it ;
But I don't understand ,uxDiummy20 Why is it used ux Well ?
int The defined variables are prefixed i.i representative int
for example :
int iTaskErrno;stdint.h Variable types not defined in the file , When defining variables, you need to prefix x.
for example :
BaseType_t xCoRoutinePreviouslyWokenMiniListItem_t xListEndstdint.h Unsigned variable type not defined in the file , When defining variables, prefix them u, such as UBaseType_t Definition
The variable of should be prefixed ux.for example :
typedef unsigned long UBaseType_t;UBaseType_t uxPriority;Enumerating variables will be prefixed e.
for example :
typedef enum { eRunning = 0, /* A task is querying the state of itself, so must be running. */ eReady, /* The task being queried is in a ready or pending ready list. */ eBlocked, /* The task being queried is in the Blocked state. */ eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */ eInvalid /* Used as an 'invalid state' value. */ } eTaskState; eTaskState eState;Pointer variables are prefixed p.
for example :
TCB_t * pxTCB;uint8_t * pucQueueStorage; // Because it's unsigned , So it is puaccording to MISRA (The Motor Industry Software Reliability Association, The Chinese name is Automobile Industry Software Reliability Association ) Code rules ,char Defined variables can only be used for ASCII character , Prefix usage c.
for example :
char cRxedChar;according to MISRA Code rules ,**char *** The defined pointer variable can only be used for ASCII character string , Prefix usage pc.
for example :
char *pcStringToSend;
function
Combined with the static Declared function , Prefix the definition prv( word private Abbreviation ).
for example :
static void prvInitialiseCoRoutineLists( void );Function with return value , According to the data type of the return value , Add the corresponding prefix , If there is no return value , namely void type , Prefix functions with letters v.
for example :
BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ); #define configRUN_TIME_COUNTER_TYPE uint32_t configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ); StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, StackType_t * pxEndOfStack, TaskFunction_t pxCode, void * pvParameters, BaseType_t xRunPrivileged ); const char * pcQueueGetName( QueueHandle_t xQueue );According to the file name , When defining the corresponding function in the file, the file name may be added to the function name , such as tasks.c Functions in the file
vTaskDelete, Function task Is in the file name task.
Macro definition
According to the file where the macro definition is located , The file name is also added to the macro definition when the macro definition in the file is declared , For example, macro definition
configUSE_PREEMPTION Is defined in the file FreeRTOSConfig.h Inside . In the macro definition config It's Wen
In the piece name config. Also note , Prefix should be lowercase .Except for the prefix , The rest is capitalized , At the same time, separate with underline .
for example :
// include\queue.h #define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) // include\list.h #define listINSERT_END( pxList, pxNewListItem ) \ { \ ListItem_t * const pxIndex = ( pxList )->pxIndex; \ ... // include\timers.h #define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) // include\croutine.h #define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) \ xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )
Conclusion
If you study it carefully FreeRTOS The name of , You will also see that some places do not conform to the above rules .
I don't know what the author thinks , Anyway, I don't like such a name .
Reference material
边栏推荐
- C WinForm [realize the previous and next selection pictures] - practice 7
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
- UEFI development learning series
- 如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
- Soem EtherCAT source code analysis I (data type definition)
- Hardware 3 -- function of voltage follower
- Wifi-802.11 negotiation rate table
- Programming knowledge -- assembly knowledge
- Some tips for using source insight (solve the problem of selecting all)
- Communication standard -- communication protocol
猜你喜欢

Cadence simulation encountered "input.scs": can not open input file change path problem

STM32 tutorial triple ADC interleaved sampling

Altium designer 19.1.18 - clear information generated by measuring distance

C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
![[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication](/img/08/7f28008a4aa999650998ba8dee5d8e.jpg)
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
![[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc](/img/9e/2524cbb9b90135c54669ba8d5338b7.jpg)
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc

Improve lighting C program

C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
![C WinForm [view status bar -- statusstrip] - Practice 2](/img/40/63065e6c4dc4e9fcb3e898981f518a.jpg)
C WinForm [view status bar -- statusstrip] - Practice 2

UEFI development learning 6 - creation of protocol
随机推荐
Factors affecting the quality of slip rings in production
【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
生产中影响滑环质量的因素
Soem EtherCAT source code analysis attachment 1 (establishment of communication operation environment)
Programming knowledge -- basis of C language
C # joint configuration with Halcon
Hardware 1 -- relationship between gain and magnification
Live555 push RTSP audio and video stream summary (I) cross compilation
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
Altium designer 19.1.18 - hide the fly line of a network
C WinForm [help interface - send email] - practice five
Reasons for rapid wear of conductive slip rings
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
Altium designer 19.1.18 - Import frame
Programming knowledge -- assembly knowledge
Arduino uses nrf24l01+ communication
Define in and define out
Wifi-802.11 negotiation rate table
Communication standard -- communication protocol
OLED 0.96 inch test