| 303 | #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) |
| 304 | |
| 305 | TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ |
| 306 | const TickType_t xTimerPeriodInTicks, |
| 307 | const UBaseType_t uxAutoReload, |
| 308 | void * const pvTimerID, |
| 309 | TimerCallbackFunction_t pxCallbackFunction, |
| 310 | StaticTimer_t * pxTimerBuffer ) |
| 311 | { |
| 312 | Timer_t * pxNewTimer; |
| 313 | |
| 314 | #if ( configASSERT_DEFINED == 1 ) |
| 315 | { |
| 316 | /* Sanity check that the size of the structure used to declare a |
| 317 | * variable of type StaticTimer_t equals the size of the real timer |
| 318 | * structure. */ |
| 319 | volatile size_t xSize = sizeof( StaticTimer_t ); |
| 320 | configASSERT( xSize == sizeof( Timer_t ) ); |
| 321 | ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ |
| 322 | } |
| 323 | #endif /* configASSERT_DEFINED */ |
| 324 | |
| 325 | /* A pointer to a StaticTimer_t structure MUST be provided, use it. */ |
| 326 | configASSERT( pxTimerBuffer ); |
| 327 | pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 !e9087 StaticTimer_t is a pointer to a Timer_t, so guaranteed to be aligned and sized correctly (checked by an assert()), so this is safe. */ |
| 328 | |
| 329 | if( pxNewTimer != NULL ) |
| 330 | { |
| 331 | /* Timers can be created statically or dynamically so note this |
| 332 | * timer was created statically in case it is later deleted. The |
| 333 | * auto-reload bit may get set in prvInitialiseNewTimer(). */ |
| 334 | pxNewTimer->ucStatus = tmrSTATUS_IS_STATICALLY_ALLOCATED; |
| 335 | |
| 336 | prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer ); |
| 337 | } |
| 338 | |
| 339 | return pxNewTimer; |
| 340 | } |
| 341 | |
| 342 | #endif /* configSUPPORT_STATIC_ALLOCATION */ |
| 343 | /*-----------------------------------------------------------*/ |
no test coverage detected