FreeRTOS学习笔记

FreeRTOS学习笔记

今天在学习FreeRTOS操作系统的定时器功能时,分析源码时,发现C语言也可以进行模块参数的隐藏保护。

具体实现

源文件定义结构体,包含数据参数信息,在头文件内下声明,然后再使用。这样当源文件封装成库文件时,模块的参数被隐藏保护起来。

timer.c
/* The definition of the timers themselves. /
typedef struct tmrTimerControl /
The old naming convention is used to prevent breaking kernel aware debuggers. */
{
const char pcTimerName; /<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. /
ListItem_t xTimerListItem; /
<< Standard linked list item as used by all kernel features for event management. /
TickType_t xTimerPeriodInTicks;/
<< How quickly and often the timer expires. /
UBaseType_t uxAutoReload; /
<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one-shot timer. */
void pvTimerID; /<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. /
TimerCallbackFunction_t pxCallbackFunction; /
<< The function that will be called when the timer expires. /
#if( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxTimerNumber; /
<< An ID assigned by trace tools such as FreeRTOS+Trace */
#endif

#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
	uint8_t 			ucStaticallyAllocated; /*<< Set to pdTRUE if the timer was created statically so no attempt is made to free the memory again if the timer is later deleted. */
#endif

} xTIMER;

timer.h
struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
typedef struct tmrTimerControl * TimerHandle_t;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值