This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2340R2:xTimerCreateStatic() 参数

Guru**** 2763585 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1613464/cc2340r2-xtimercreatestatic-parameters

器件型号: 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

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Luke、

    由于 xTimerCreateStatic () 是一个 FreeRTOS 函数、因此我将引用 xTimerCreateStatic - freeertosTM

    另外、在 ClockP 函数中、还使用了以下功能:  

    tHandle = xTimerCreateStatic(NULL,
                                     initialTimeout,
                                     autoReload,
                                     (void *)pObj,
                                     (TimerCallbackFunction_t)ClockP_callbackFxn,
                                     staticTimer);

    谢谢、
    Alex F