器件型号: CC2340R2
您好的团队、
xTimerCreateStatic() 的第 4 个参数是 PVTimerID、还是应该是我们将在定时器回调函数中递增的变量的地址?
此文件夹中的 Timers.h:C:\ti\simplelink_lowpower_f3_SDK_9_11_00_18\source\third_party\freertos\include
在 Timers.h 中,函数 xTimerCreateStatic () 是这样定义的。
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */
但上面的函数描述有以下内容:
* xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS.
* xTimerPeriod, // The period of the timer in ticks.
* pdTRUE, // This is an auto-reload timer.
* ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function
* prvTimerCallback, // The function to execute when the timer expires.
* &xTimerBuffer ); // The buffer that will hold the software timer structure.
当客户尝试创建在声明为 volatile 的回调函数中递增的变量时、发现了此差异。客户遇到了编译器错误。
通过查看同一目录中的 timer.c、调用了函数 traceTIMER_create()、但它们没有用于此目的的代码。
他们要做的是只将 ID 值发送到 xTimerCreateStatic、然后将其递增的变量设置为 volatile。 我们真的不明白为什么 xTimerCreateStatic () 需要它们在递增的变量,因为它们在回调函数中是这样做的。 这有道理吗?
此致、
Luke