Skip to content

Commit c173123

Browse files
committed
osKernelGetSysTimerCount updated with more robust solution
1 parent 15faeca commit c173123

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,11 @@ uint32_t osKernelGetTickFreq (void) {
329329
}
330330

331331
uint32_t osKernelGetSysTimerCount (void) {
332+
uint32_t primask = __get_PRIMASK();
332333
TickType_t ticks;
333334
uint32_t val;
334335

335-
portENTER_CRITICAL();
336+
__disable_irq();
336337

337338
ticks = xTaskGetTickCount();
338339
val = OS_Tick_GetCount();
@@ -343,7 +344,9 @@ uint32_t osKernelGetSysTimerCount (void) {
343344
}
344345
val += ticks * OS_Tick_GetInterval();
345346

346-
portEXIT_CRITICAL();
347+
if (primask == 0U) {
348+
__enable_irq();
349+
}
347350

348351
return (val);
349352
}

0 commit comments

Comments
 (0)