Skip to content

Commit 8339845

Browse files
authored
Rename xTimerHandle to xTimer (#36)
If configENABLE_BACKWARD_COMPATIBILITY is defined, then xTimerHandle is defined to TimerHandle_t which would result in conflict. Fixes #35. Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent 21d0639 commit 8339845

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_timer.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ typedef struct timer_internal
5858

5959
/*-----------------------------------------------------------*/
6060

61-
void prvTimerCallback( TimerHandle_t xTimerHandle )
61+
void prvTimerCallback( TimerHandle_t xTimer )
6262
{
63-
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle );
63+
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimer );
6464
pthread_t xTimerNotificationThread;
6565

6666
/* The value of the timer ID, set in timer_create, should not be NULL. */
@@ -74,7 +74,7 @@ void prvTimerCallback( TimerHandle_t xTimerHandle )
7474
* argument. This call should not block. */
7575
if( pxTimer->xTimerPeriod > 0 )
7676
{
77-
xTimerChangePeriod( xTimerHandle, pxTimer->xTimerPeriod, 0 );
77+
xTimerChangePeriod( xTimer, pxTimer->xTimerPeriod, 0 );
7878
}
7979

8080
/* Create the timer notification thread if requested. */
@@ -152,19 +152,19 @@ int timer_create( clockid_t clockid,
152152

153153
int timer_delete( timer_t timerid )
154154
{
155-
TimerHandle_t xTimerHandle = timerid;
156-
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle );
155+
TimerHandle_t xTimer = timerid;
156+
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimer );
157157

158158
/* The value of the timer ID, set in timer_create, should not be NULL. */
159159
configASSERT( pxTimer != NULL );
160160

161161
/* Stop the FreeRTOS timer. Because the timer is statically allocated, no call
162162
* to xTimerDelete is necessary. The timer is stopped so that it's not referenced
163163
* anywhere. xTimerStop will not fail when it has unlimited block time. */
164-
( void ) xTimerStop( xTimerHandle, portMAX_DELAY );
164+
( void ) xTimerStop( xTimer, portMAX_DELAY );
165165

166166
/* Wait until the timer stop command is processed. */
167-
while( xTimerIsTimerActive( xTimerHandle ) == pdTRUE )
167+
while( xTimerIsTimerActive( xTimer ) == pdTRUE )
168168
{
169169
vTaskDelay( 1 );
170170
}
@@ -193,8 +193,8 @@ int timer_settime( timer_t timerid,
193193
struct itimerspec * ovalue )
194194
{
195195
int iStatus = 0;
196-
TimerHandle_t xTimerHandle = timerid;
197-
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle );
196+
TimerHandle_t xTimer = timerid;
197+
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimer );
198198
TickType_t xNextTimerExpiration = 0, xTimerExpirationPeriod = 0;
199199
BaseType_t xTimerCommandSent = pdFAIL;
200200

@@ -216,9 +216,9 @@ int timer_settime( timer_t timerid,
216216
}
217217

218218
/* Stop the timer if it's currently active. */
219-
if( ( iStatus == 0 ) && xTimerIsTimerActive( xTimerHandle ) )
219+
if( ( iStatus == 0 ) && xTimerIsTimerActive( xTimer ) )
220220
{
221-
( void ) xTimerStop( xTimerHandle, portMAX_DELAY );
221+
( void ) xTimerStop( xTimer, portMAX_DELAY );
222222
}
223223

224224
/* Only restart the timer if it_value is not zero. */
@@ -278,16 +278,16 @@ int timer_settime( timer_t timerid,
278278
* triggered immediately. */
279279
if( xNextTimerExpiration == 0 )
280280
{
281-
prvTimerCallback( xTimerHandle );
281+
prvTimerCallback( xTimer );
282282
}
283283
else
284284
{
285285
/* Set the timer to expire at the it_value, then start it. */
286-
( void ) xTimerChangePeriod( xTimerHandle, xNextTimerExpiration, portMAX_DELAY );
287-
xTimerCommandSent = xTimerStart( xTimerHandle, xNextTimerExpiration );
286+
( void ) xTimerChangePeriod( xTimer, xNextTimerExpiration, portMAX_DELAY );
287+
xTimerCommandSent = xTimerStart( xTimer, xNextTimerExpiration );
288288

289289
/* Wait until the timer start command is processed. */
290-
while( ( xTimerCommandSent != pdFAIL ) && ( xTimerIsTimerActive( xTimerHandle ) == pdFALSE ) )
290+
while( ( xTimerCommandSent != pdFAIL ) && ( xTimerIsTimerActive( xTimer ) == pdFALSE ) )
291291
{
292292
vTaskDelay( 1 );
293293
}
@@ -302,13 +302,13 @@ int timer_settime( timer_t timerid,
302302
int timer_gettime( timer_t timerid,
303303
struct itimerspec * value )
304304
{
305-
TimerHandle_t xTimerHandle = timerid;
306-
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimerHandle );
307-
TickType_t xNextExpirationTime = xTimerGetExpiryTime( xTimerHandle ) - xTaskGetTickCount(),
305+
TimerHandle_t xTimer = timerid;
306+
timer_internal_t * pxTimer = ( timer_internal_t * ) pvTimerGetTimerID( xTimer );
307+
TickType_t xNextExpirationTime = xTimerGetExpiryTime( xTimer ) - xTaskGetTickCount(),
308308
xTimerExpirationPeriod = pxTimer->xTimerPeriod;
309309

310310
/* Set it_value only if the timer is armed. Otherwise, set it to 0. */
311-
if( xTimerIsTimerActive( xTimerHandle ) != pdFALSE )
311+
if( xTimerIsTimerActive( xTimer ) != pdFALSE )
312312
{
313313
value->it_value.tv_sec = ( time_t ) ( xNextExpirationTime / configTICK_RATE_HZ );
314314
value->it_value.tv_nsec = ( long ) ( ( xNextExpirationTime % configTICK_RATE_HZ ) * NANOSECONDS_PER_TICK );

0 commit comments

Comments
 (0)