0

I'm using cmsis_os.c and cmsis_os.h provided in STMCubeMX. I found at least two place were cmsis_os.c should be fixed.

The first one:

#elif( configSUPPORT_STATIC_ALLOCATION == 1 )
  return xTimerCreateStatic((const char *)"",
                      1, // period should be filled when starting the Timer using osTimerStart
                      (type == osTimerPeriodic) ? pdTRUE : pdFALSE,
                      (void *) argument,
                      (TaskFunction_t)timer_def->ptimer,
                      (StaticTimer_t *)timer_def->controlblock);  
#else
  return xTimerCreate((const char *)"",
                      1, // period should be filled when starting the Timer using osTimerStart
                      (type == osTimerPeriodic) ? pdTRUE : pdFALSE,
                      (void *) argument,
                      (TaskFunction_t)timer_def->ptimer);
#endif

Should TaskFunction_t be replaced with TimerCallbackFunction_t?

The second one:

osEvent osSignalWait (int32_t signals, uint32_t millisec)
{
  osEvent ret;

#if( configUSE_TASK_NOTIFICATIONS == 1 )

  TickType_t ticks;

  ret.value.signals = 0;  
  ticks = 0;
  if (millisec == osWaitForever) {
    ticks = portMAX_DELAY;
  }

I think it has to be:

osEvent osSignalWait (int32_t signals, uint32_t millisec)
{
  osEvent ret;

#if( configUSE_TASK_NOTIFICATIONS == 1 )

  TickType_t ticks;

  if (signals == 0)
    signals = ~0x80000000;

  ret.value.signals = 0;  
  ticks = 0;
  if (millisec == osWaitForever) {
    ticks = portMAX_DELAY;
  }

What do you think?

Is there a way to make STMCubeMX generating the patched file instead of the original one?

Thanks, Alberto

Alb
  • 73
  • 3
  • Don't understand your second modification. Is `signals`used later on in the function ? – Guillaume Petitjean Dec 04 '19 at 15:41
  • Yes, it is used later, in xTaskNotifyWait that is not shown here. When signals is 0, osSignalWait should wait for (and return) on any single signal. In order to wait for any signal we need to pass ~0x80000000 to xTaskNotifyWait. – Alb Dec 04 '19 at 20:48
  • Anyway, even if it's always possible to find a bug in a well established library, most of the time, it's more a misunderstanding of the developper using it... Before fixing it, why not contacting the developpers of CMSIS-RTOS ? – Guillaume Petitjean Dec 05 '19 at 07:11
  • This is not a problem of CMSIS RTOS, but of the implementation of the API (cmsis_os.c and cmsis_os.h) provided in STMCubeMX by ST. If someone has used it before, probably he can tell how it is possible to wait for any single signal flag without doing the fix (provided that "signals" has to be 0). – Alb Dec 05 '19 at 09:58

0 Answers0