Chapter 2. API Reference
(continued from previous page)
* }
*
* void main( void )
* {
* int32_t x;
*
* // Create then start some timers. Starting the timers before the␣
,→scheduler
* // has been started means the timers will start running immediately that
* // the scheduler starts.
* for( x = 0; x < NUM_TIMERS; x++ )
* {
* xTimers[ x ] = xTimerCreate( "Timer", // Just a text name,␣
,→not used by the kernel.
* ( 100 * x ), // The timer period␣
,→in ticks.
* pdTRUE, // The timers will␣
,→auto-reload themselves when they expire.
* ( void * ) x, // Assign each timer␣
,→a unique id equal to its array index.
* vTimerCallback // Each timer calls␣
,→the same callback when it expires.
* );
*
* if( xTimers[ x ] == NULL )
* {
* // The timer was not created.
* }
* else
* {
* // Start the timer. No block time is specified, and even if one␣
,→was
* // it would be ignored because the scheduler has not yet been
* // started.
* if( xTimerStart( xTimers[ x ], 0 ) != pdPASS )
* {
* // The timer could not be set into the Active state.
* }
* }
* }
*
* // ...
* // Create tasks here.
* // ...
*
* // Starting the scheduler will start the timers running as they have␣
,→already
* // been set into the active state.
* vTaskStartScheduler();
*
* // Should not reach here.
* for( ;; );
* }
*
Return If the timer is successfully created then a handle to the newly created timer is returned. If the timer
cannot be created (because either there is insufficient FreeRTOS heap remaining to allocate the timer
structures, or the timer period was set to 0) then NULL is returned.
Parameters
• pcTimerName: A text name that is assigned to the timer. This is done purely to assist debugging.
The kernel itself only ever references a timer by its handle, and never by its name.
Espressif Systems 915
Submit Document Feedback
Release v4.4