Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ typedef struct timer_internal
StaticTimer_t xTimerBuffer; /**< Memory that holds the FreeRTOS timer. */
struct sigevent xTimerEvent; /**< What to do when this timer expires. */
TickType_t xTimerPeriod; /**< Period of this timer. */
UBaseType_t uxTimerCallbackInvocations; /**< Number of times the timer callback has been invoked. */
} timer_internal_t;

/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -94,6 +95,7 @@ void prvTimerCallback( TimerHandle_t xTimer )
pxTimer->xTimerEvent.sigev_value.sival_ptr );
}
}
pxTimer->uxTimerCallbackInvocations++;
}

/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -273,6 +275,9 @@ int timer_settime( timer_t timerid,
}
}

/* Set uxTimerCallbackInvocations before timer start. */
pxTimer->uxTimerCallbackInvocations = 0

/* If xNextTimerExpiration is still 0, that means that it_value specified
* an absolute timeout in the past. Per POSIX spec, a notification should be
* triggered immediately. */
Expand All @@ -286,7 +291,9 @@ int timer_settime( timer_t timerid,
xTimerCommandSent = xTimerChangePeriod( xTimer, xNextTimerExpiration, xNextTimerExpiration );

/* Wait until the timer start command is processed. */
while( ( xTimerCommandSent != pdFAIL ) && ( xTimerIsTimerActive( xTimer ) == pdFALSE ) )
while( ( xTimerCommandSent != pdFAIL ) &&
( xTimerIsTimerActive( xTimer ) == pdFALSE ) &&
( pxTimer->uxTimerCallbackInvocations == 0 ) )
{
vTaskDelay( 1 );
}
Expand Down