We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using CMSIS OS wrapper on FreeRTOS running on STM32F4. It seems like the CMSIS OS documentation (www.keil.com/.../group__CMSIS__RTOS__TimerMgmt.html) is wrong about timer callback argument. Or the wrapper is buggy.
It is written that last argument for osTimerCreate will be passed to the timer callback function as "void const * argument". But my tests show it's not like that, argument pointer is actually the timer pointer. FreeRTOS manual (www.freertos.org/FreeRTOS-timers-pvTimerGetTimerID.html) confirms it and says that pvTimerGetTimerID function must be used to get the pointer value which was passed on timer creation.
To put it into code:
uint32_t value_to_pass = 123U; osTimerDef(MyTimer, TimerCallback); timer_id = osTimerCreate(osTimer(MyTimer), osTimerPeriodic, &value_to_pass); void TimerCallback(void const * argument) { // How to get value based on CMSIS OS manual. // Does not work. The "argument" is actually the "timer_id" uint32_t value = *((uint32_t *)argument); // Working solution based on the FreeRTOS documentation: uint32_t value = *((uint32_t *)pvTimerGetTimerID((const TimerHandle_t *)argument)); }
you'd better discussing this issue directly in github.com/.../CMSIS_5