Add wait to timer_settime (#17)

This commit is contained in:
Muneeb Ahmed 2022-02-08 15:57:54 -07:00 committed by GitHub
parent 3b33c3467d
commit 85ce51dad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,6 +196,7 @@ int timer_settime( timer_t timerid,
TimerHandle_t xTimerHandle = timerid; TimerHandle_t xTimerHandle = timerid;
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle ); timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle );
TickType_t xNextTimerExpiration = 0, xTimerExpirationPeriod = 0; TickType_t xNextTimerExpiration = 0, xTimerExpirationPeriod = 0;
BaseType_t xTimerCommandSent = pdFAIL;
/* Validate the value argument, but only if the timer isn't being disarmed. */ /* Validate the value argument, but only if the timer isn't being disarmed. */
if( TIMESPEC_IS_NOT_ZERO( value->it_value ) ) if( TIMESPEC_IS_NOT_ZERO( value->it_value ) )
@ -283,7 +284,13 @@ int timer_settime( timer_t timerid,
{ {
/* Set the timer to expire at the it_value, then start it. */ /* Set the timer to expire at the it_value, then start it. */
( void ) xTimerChangePeriod( xTimerHandle, xNextTimerExpiration, portMAX_DELAY ); ( void ) xTimerChangePeriod( xTimerHandle, xNextTimerExpiration, portMAX_DELAY );
( void ) xTimerStart( xTimerHandle, xNextTimerExpiration ); xTimerCommandSent = xTimerStart( xTimerHandle, xNextTimerExpiration );
/* Wait until the timer start command is processed. */
while( ( xTimerCommandSent != pdFAIL ) && ( xTimerIsTimerActive( xTimerHandle ) == pdFALSE ) )
{
vTaskDelay( 1 );
}
} }
} }