Skip to content

Commit 2e535f7

Browse files
authored
Merge pull request #19 from CppBaddy/CppBaddy-osDelayUntil-patch
Fixes to osDelayUntil
2 parents d9d2e73 + ae9e4aa commit 2e535f7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ osStatus_t osDelay (uint32_t ticks) {
831831
}
832832

833833
osStatus_t osDelayUntil (uint32_t ticks) {
834-
TickType_t tcnt;
834+
TickType_t tcnt, delay;
835835
osStatus_t stat;
836836

837837
if (IS_IRQ()) {
@@ -840,8 +840,17 @@ osStatus_t osDelayUntil (uint32_t ticks) {
840840
else {
841841
stat = osOK;
842842
tcnt = xTaskGetTickCount();
843+
delay = (TickType_t)ticks - tcnt;
843844

844-
vTaskDelayUntil (&tcnt, (TickType_t)(ticks - tcnt));
845+
/* check if target tick has not expired */
846+
if(delay && 0 == (delay >> (8 * sizeof(TickType_t) - 1))){
847+
vTaskDelayUntil (&tcnt, delay));
848+
}
849+
else
850+
{
851+
/* No delay or already expired */
852+
stat = osErrorParameter;
853+
}
845854
}
846855

847856
return (stat);

0 commit comments

Comments
 (0)