Skip to content

Commit 85ce51d

Browse files
Add wait to timer_settime (#17)
1 parent 3b33c34 commit 85ce51d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ int timer_settime( timer_t timerid,
196196
TimerHandle_t xTimerHandle = timerid;
197197
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle );
198198
TickType_t xNextTimerExpiration = 0, xTimerExpirationPeriod = 0;
199+
BaseType_t xTimerCommandSent = pdFAIL;
199200

200201
/* Validate the value argument, but only if the timer isn't being disarmed. */
201202
if( TIMESPEC_IS_NOT_ZERO( value->it_value ) )
@@ -283,7 +284,13 @@ int timer_settime( timer_t timerid,
283284
{
284285
/* Set the timer to expire at the it_value, then start it. */
285286
( void ) xTimerChangePeriod( xTimerHandle, xNextTimerExpiration, portMAX_DELAY );
286-
( void ) xTimerStart( xTimerHandle, xNextTimerExpiration );
287+
xTimerCommandSent = xTimerStart( xTimerHandle, xNextTimerExpiration );
288+
289+
/* Wait until the timer start command is processed. */
290+
while( ( xTimerCommandSent != pdFAIL ) && ( xTimerIsTimerActive( xTimerHandle ) == pdFALSE ) )
291+
{
292+
vTaskDelay( 1 );
293+
}
287294
}
288295
}
289296

0 commit comments

Comments
 (0)