Skip to content

Commit 9cdbe17

Browse files
committed
Fix RTOS2 priority value mapping (#96)
- FreeRTOS handles priorities from 0 to configMAX_PRIORITIES-1 - RTOS2 defines priorities from 1(osPriorityIdle) to osPriorityISR(56) - Till now RTOS2 passed priorities 1:1 to FreeRTOS, i.e. FreeRTOS priority matched osPriority_t. This commit changes priority mapping: FreeRTOS priority is now (osPriority_t - 1).
1 parent d0b0b50 commit 9cdbe17

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

ARM.CMSIS-FreeRTOS.pdsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Active development...
1414
- Add support for processor affinity to CMSIS-RTOS2 wrapper
1515
- Add memory allocation configuration options to FreeRTOSConfig.h
16+
- Corrected task priority mapping, FreeRTOS priority is now osPriority_t-1
1617
- CMSIS-RTOS2 requires CMSIS:OS Tick component
1718
- Drop support for Arm Compiler 5
1819
- Drop support for CMSIS-RTOS1 API

CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,15 @@ osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAtt
582582
name,
583583
stack,
584584
argument,
585-
prio,
585+
prio - 1U,
586586
(StackType_t *)attr->stack_mem,
587587
(StaticTask_t *)attr->cb_mem);
588588
#else
589589
hTask = xTaskCreateStaticAffinitySet ((TaskFunction_t)func,
590590
name,
591591
stack,
592592
argument,
593-
prio,
593+
prio - 1U,
594594
(StackType_t *)attr->stack_mem,
595595
(StaticTask_t *)attr->cb_mem,
596596
core_aff);
@@ -605,7 +605,7 @@ osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAtt
605605
name,
606606
(configSTACK_DEPTH_TYPE)stack,
607607
argument,
608-
prio,
608+
prio - 1U,
609609
&hTask) != pdPASS) {
610610
hTask = NULL;
611611
}
@@ -614,7 +614,7 @@ osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAtt
614614
name,
615615
(configSTACK_DEPTH_TYPE)stack,
616616
argument,
617-
prio,
617+
prio - 1U,
618618
core_aff,
619619
&hTask) != pdPASS) {
620620
hTask = NULL;
@@ -722,7 +722,7 @@ osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) {
722722
}
723723
else {
724724
stat = osOK;
725-
vTaskPrioritySet (hTask, (UBaseType_t)priority);
725+
vTaskPrioritySet (hTask, (UBaseType_t)priority - 1U);
726726
}
727727

728728
/* Return execution status */
@@ -739,7 +739,7 @@ osPriority_t osThreadGetPriority (osThreadId_t thread_id) {
739739
if ((IRQ_Context() != 0U) || (hTask == NULL)) {
740740
prio = osPriorityError;
741741
} else {
742-
prio = (osPriority_t)((int32_t)uxTaskPriorityGet (hTask));
742+
prio = (osPriority_t)(uxTaskPriorityGet (hTask) + 1U);
743743
}
744744

745745
/* Return current thread priority */

0 commit comments

Comments
 (0)