Skip to content

Commit

Permalink
uxAutoReload replaced with xAutoReload to improve MISRA compliance (#429
Browse files Browse the repository at this point in the history
)

* Created xTimerGetReloadMode and uxTimerGetReloadMode.

* Changed the use of uxAutoReload to xAutoReload

* updated history.txt

* Update History.txt

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>

* Update timers.c

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>

* Added xTimerGetReloadMode to lexicon.txt

* uncrustified timers.c

* Fix formatting check

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
  • Loading branch information
3 people authored Dec 27, 2021
1 parent 53b9a80 commit 455df7a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,6 @@ utf
utilised
utilises
uxarraysize
uxautoreload
uxbasepriority
uxbits
uxbitstoclear
Expand Down Expand Up @@ -2674,6 +2673,7 @@ xabab
xabac
xactivetimerlist
xaltregions
xautoreload
xavailableheapspaceinbytes
xb
xbacklighttimer
Expand Down Expand Up @@ -3070,6 +3070,7 @@ xtimercreatestatic
xtimerdelete
xtimergetexpirytime
xtimergetperiod
xtimergetreloadmode
xtimergettimerdaemontaskhandle
xtimeristimeractive
xtimerlistitem
Expand Down
7 changes: 7 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ Changes between FreeRTOS V10.4.5 and TBD

Documentation and download available at https://www.FreeRTOS.org/

+ Changed uxAutoReload parameter in timer functions to xAutoReload. The
type is now BaseType_t. This matches the type of pdTRUE and pdFALSE.
The new function xTimerGetAutoReload() provides the auto-reload state as
a BaseType_t. The legacy function uxTimerGetAutoReload is retained with the
original UBaseType_t return value.


Changes between FreeRTOS V10.4.4 and FreeRTOS V10.4.5 released September 10 2021

See https://www.FreeRTOS.org/FreeRTOS-V10.4.5.html
Expand Down
38 changes: 26 additions & 12 deletions include/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ typedef void (* PendedFunction_t)( void *,
/**
* TimerHandle_t xTimerCreate( const char * const pcTimerName,
* TickType_t xTimerPeriodInTicks,
* UBaseType_t uxAutoReload,
* BaseType_t xAutoReload,
* void * pvTimerID,
* TimerCallbackFunction_t pxCallbackFunction );
*
Expand Down Expand Up @@ -127,9 +127,9 @@ typedef void (* PendedFunction_t)( void *,
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
* equal to 1000. Time timer period must be greater than 0.
*
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* @param xAutoReload If xAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
* If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* If xAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* enter the dormant state after it expires.
*
* @param pvTimerID An identifier that is assigned to the timer being created.
Expand Down Expand Up @@ -231,15 +231,15 @@ typedef void (* PendedFunction_t)( void *,
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION;
#endif

/**
* TimerHandle_t xTimerCreateStatic(const char * const pcTimerName,
* TickType_t xTimerPeriodInTicks,
* UBaseType_t uxAutoReload,
* BaseType_t xAutoReload,
* void * pvTimerID,
* TimerCallbackFunction_t pxCallbackFunction,
* StaticTimer_t *pxTimerBuffer );
Expand Down Expand Up @@ -273,9 +273,9 @@ typedef void (* PendedFunction_t)( void *,
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
* equal to 1000. The timer period must be greater than 0.
*
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* @param xAutoReload If xAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
* If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* If xAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* enter the dormant state after it expires.
*
* @param pvTimerID An identifier that is assigned to the timer being created.
Expand Down Expand Up @@ -361,7 +361,7 @@ typedef void (* PendedFunction_t)( void *,
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION;
Expand Down Expand Up @@ -1252,22 +1252,36 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */

/**
* void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload );
* void vTimerSetReloadMode( TimerHandle_t xTimer, const BaseType_t xAutoReload );
*
* Updates a timer to be either an auto-reload timer, in which case the timer
* automatically resets itself each time it expires, or a one-shot timer, in
* which case the timer will only expire once unless it is manually restarted.
*
* @param xTimer The handle of the timer being updated.
*
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* @param xAutoReload If xAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the timer's period (see the
* xTimerPeriodInTicks parameter of the xTimerCreate() API function). If
* uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* xAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* enter the dormant state after it expires.
*/
void vTimerSetReloadMode( TimerHandle_t xTimer,
const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION;
const BaseType_t xAutoReload ) PRIVILEGED_FUNCTION;

/**
* BaseType_t xTimerGetReloadMode( TimerHandle_t xTimer );
*
* Queries a timer to determine if it is an auto-reload timer, in which case the timer
* automatically resets itself each time it expires, or a one-shot timer, in
* which case the timer will only expire once unless it is manually restarted.
*
* @param xTimer The handle of the timer being queried.
*
* @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise
* pdFALSE is returned.
*/
BaseType_t xTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;

/**
* UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer );
Expand Down
33 changes: 19 additions & 14 deletions timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
*/
static void prvInitialiseNewTimer( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
Timer_t * pxNewTimer ) PRIVILEGED_FUNCTION;
Expand Down Expand Up @@ -287,7 +287,7 @@

TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction )
{
Expand All @@ -301,7 +301,7 @@
* and has not been started. The auto-reload bit may get set in
* prvInitialiseNewTimer. */
pxNewTimer->ucStatus = 0x00;
prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, xAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
}

return pxNewTimer;
Expand All @@ -314,7 +314,7 @@

TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t * pxTimerBuffer )
Expand Down Expand Up @@ -343,7 +343,7 @@
* auto-reload bit may get set in prvInitialiseNewTimer(). */
pxNewTimer->ucStatus = tmrSTATUS_IS_STATICALLY_ALLOCATED;

prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, xAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
}

return pxNewTimer;
Expand All @@ -354,7 +354,7 @@

static void prvInitialiseNewTimer( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
const BaseType_t xAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
Timer_t * pxNewTimer )
Expand All @@ -374,7 +374,7 @@
pxNewTimer->pxCallbackFunction = pxCallbackFunction;
vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );

if( uxAutoReload != pdFALSE )
if( xAutoReload != pdFALSE )
{
pxNewTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD;
}
Expand Down Expand Up @@ -449,14 +449,14 @@
/*-----------------------------------------------------------*/

void vTimerSetReloadMode( TimerHandle_t xTimer,
const UBaseType_t uxAutoReload )
const BaseType_t xAutoReload )
{
Timer_t * pxTimer = xTimer;

configASSERT( xTimer );
taskENTER_CRITICAL();
{
if( uxAutoReload != pdFALSE )
if( xAutoReload != pdFALSE )
{
pxTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD;
}
Expand All @@ -469,28 +469,33 @@
}
/*-----------------------------------------------------------*/

UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer )
BaseType_t xTimerGetReloadMode( TimerHandle_t xTimer )
{
Timer_t * pxTimer = xTimer;
UBaseType_t uxReturn;
BaseType_t xReturn;

configASSERT( xTimer );
taskENTER_CRITICAL();
{
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0 )
{
/* Not an auto-reload timer. */
uxReturn = ( UBaseType_t ) pdFALSE;
xReturn = pdFALSE;
}
else
{
/* Is an auto-reload timer. */
uxReturn = ( UBaseType_t ) pdTRUE;
xReturn = pdTRUE;
}
}
taskEXIT_CRITICAL();

return uxReturn;
return xReturn;
}

UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer )
{
return ( UBaseType_t ) xTimerGetReloadMode( xTimer );
}
/*-----------------------------------------------------------*/

Expand Down

0 comments on commit 455df7a

Please sign in to comment.