Skip to main content
Graduate
February 28, 2020
Question

overriding osDelay function

  • February 28, 2020
  • 1 reply
  • 1287 views

Hello,

stm32F4

FreeRTOS

Cube 1.4.2

My code sometimes run pretty long osDelay. In fact "long" means "longer than watchdog"..

I thought about cutting the delay in smaller delays and call a watchdog kick after each delay. Something like this:

osStatus delay(uint32_t delay) {
#if INCLUDE_vTaskDelay
 
 uint32_t remainingDelay = delay;
 while (remainingDelay > WATCHDOG_DELAY / 2) {
 TickType_t ticks = (WATCHDOG_DELAY / 2) / portTICK_PERIOD_MS;
 vTaskDelay(ticks ? ticks : 1); /* Minimum delay = 1 tick */
 remainingDelay -= WATCHDOG_DELAY / 2;
 watchdogSignal(testTaskId);
 }
 
 TickType_t ticks = remainingDelay / portTICK_PERIOD_MS;
 vTaskDelay(ticks ? ticks : 1); /* Minimum delay = 1 tick */
 watchdogSignal(testTaskId);
 return osOK;
#else
 (void) millisec;
 
 return osErrorResource;
 
#endif
}

But the thing is, I would like all the code to use this snippet, ie replacing osDelay.

BUT osDelay is not declared weak.

Do you know a way to do this without having to :

  • modify the cmsis_os.c file
  • replacing all calls to osDelay to the above function.

?

Or maybe, is there a better way to do this?

Thanks

Julien

    This topic has been closed for replies.

    1 reply

    Graduate II
    February 29, 2020

    Suggest reading this: https://stackoverflow.com/questions/13217959/how-to-use-the-watchdog-timer-in-a-rtos

    I would put a watchdog reset in a software timer and make timer task the second lowest priority task next to idle task. Or that is not enough in your case?