Espressif ESP32-S2 Programming Manual page 936

Table of Contents

Advertisement

Chapter 2. API Reference
xTimerReset(xTimer, xTicksToWait)
BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
Timer functionality is provided by a timer service/daemon task. Many of the public FreeRTOS timer API
functions send commands to the timer service task through a queue called the timer command queue. The
timer command queue is private to the kernel itself and is not directly accessible to application code. The
length of the timer command queue is set by the configTIMER_QUEUE_LENGTH configuration constant.
xTimerReset() re-starts a timer that was previously created using the xTimerCreate() API function. If the
timer had already been started and was already in the active state, then xTimerReset() will cause the timer
to re-evaluate its expiry time so that it is relative to when xTimerReset() was called. If the timer was in the
dormant state then xTimerReset() has equivalent functionality to the xTimerStart() API function.
Resetting a timer ensures the timer is in the active state. If the timer is not stopped, deleted, or reset in the
mean time, the callback function associated with the timer will get called 'n'ticks after xTimerReset() was
called, where 'n'is the timers defined period.
It is valid to call xTimerReset() before the scheduler has been started, but when this is done the timer will not
actually start until the scheduler is started, and the timers expiry time will be relative to when the scheduler is
started, not relative to when xTimerReset() was called.
The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset() to be available.
Example usage:
* //
When a key
pass
* //
without a key being pressed, then the LCD back-light
* //
this case, the timer
*
*
TimerHandle_t xBacklightTimer
*
* //
The callback function assigned to the one-shot
* //
parameter
*
void vBacklightTimerCallback( TimerHandle_t pxTimer )
*
{
*
//
The timer expired, therefore
*
//
was
pressed.
*
vSetBacklightState( BACKLIGHT_OFF );
*
}
*
* //
The key press event
*
void vKeyPressEventHandler( char cKey )
*
{
*
//
Ensure the LCD back-light
*
//
responsible
*
//
key
inactivity.
*
//
if
it cannot be sent
*
vSetBacklightState( BACKLIGHT_ON );
*
if( xTimerReset( xBacklightTimer,
*
{
*
//
The reset command was
*
//
action
*
}
*
*
//
Perform the rest of the key processing
*
}
*
*
void main( void )
*
{
*
int32_t x;
*
*
//
Create then start the one-shot timer that
*
//
the back-light off
Espressif Systems
is
pressed, an LCD back-light
is
a one-shot
=
NULL;
is not
used.
Switch off the LCD
handler.
for
turning the back-light off after
Wait
10
ticks
immediately.
here.
if
no keys are pressed within a
Submit Document Feedback
is
switched
timer.
timer.
5
seconds must have passed since a key
back-light.
is
on, then reset the timer that
for
the command to be successfully sent
100
)
!=
pdPASS )
not
executed
successfully.
here.
is
responsible
925
on.
If
5
seconds␣
is
switched
off.
In
In this case the
is
5
seconds of
Take appropriate
for
turning
5
second
period.
(continues on next page)
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Table of Contents

Save PDF