timers.h
Go to the documentation of this file.
/*
* FreeRTOS Kernel V10.0.0
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software. If you wish to use our Amazon
* FreeRTOS name, please do so in a fair use way that does not cause confusion.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
#ifndef TIMERS_H
#define TIMERS_H
#ifndef INC_FREERTOS_H
#error "include FreeRTOS.h must appear in source files before include timers.h"
#endif
/*lint -save -e537 This headers are only multiply included if the application code
happens to also be including task.h. */
#include "task.h"
/*lint -restore */
#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------
* MACROS AND DEFINITIONS
*----------------------------------------------------------*/
/* IDs for commands that can be sent/received on the timer queue. These are to
be used solely through the macros that make up the public software timer API,
as defined below. The commands that are sent from interrupts must use the
highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task
or interrupt version of the queue send function should be used. */
#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 )
#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 )
#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 )
#define tmrCOMMAND_START ( ( BaseType_t ) 1 )
#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 )
#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 )
#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 )
#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 )
#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 )
#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 )
#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 )
#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 )
#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 )
typedef void * TimerHandle_t;
/*
* Defines the prototype to which timer callback functions must conform.
*/
typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );
/*
* Defines the prototype to which functions used with the
* xTimerPendFunctionCallFromISR() function must conform.
*/
typedef void (*PendedFunction_t)( void *, uint32_t );
#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,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION;
#endif
#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,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */
void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
#define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
/*
* Functions beyond this part are not part of the public API and are intended
* for use by the kernel only.
*/
BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;
BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
#if( configUSE_TRACE_FACILITY == 1 )
void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION;
UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
#endif
#ifdef __cplusplus
}
#endif
#endif /* TIMERS_H */
configTIMER_TASK_PRIORITY
#define configTIMER_TASK_PRIORITY
Definition: FreeRTOSConfig.h:31
xTimerGetExpiryTime
TickType_t xTimerGetExpiryTime(TimerHandle_t xTimer) PRIVILEGED_FUNCTION
listSET_LIST_ITEM_OWNER
#define listSET_LIST_ITEM_OWNER(pxListItem, pxOwner)
Definition: list.h:180
task.h
xTimerGenericCommand
BaseType_t xTimerGenericCommand(TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t *const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait) PRIVILEGED_FUNCTION
TimerCallbackFunction_t
void(* TimerCallbackFunction_t)(TimerHandle_t xTimer)
Definition: timers.h:82
xLIST
Definition: list.h:165
traceTIMER_COMMAND_SEND
#define traceTIMER_COMMAND_SEND(xTimer, xMessageID, xMessageValueValue, xReturn)
Definition: FreeRTOS.h:537
vPortFree
void vPortFree(void *pv)
Definition: heap_1.c:123
xQueueReceive
BaseType_t xQueueReceive(QueueHandle_t xQueue, void *const pvBuffer, TickType_t xTicksToWait)
Definition: queue.c:1240
PendedFunction_t
void(* PendedFunction_t)(void *, uint32_t)
Definition: timers.h:88
tmrCOMMAND_RESET
#define tmrCOMMAND_RESET
Definition: timers.h:59
tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR
#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR
Definition: timers.h:55
tracePEND_FUNC_CALL
#define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret)
Definition: FreeRTOS.h:601
portPRIVILEGE_BIT
#define portPRIVILEGE_BIT
Definition: FreeRTOS.h:719
tmrCOMMAND_EXECUTE_CALLBACK
#define tmrCOMMAND_EXECUTE_CALLBACK
Definition: timers.h:56
vListInitialise
void vListInitialise(List_t *const pxList)
Definition: list.c:38
tracePEND_FUNC_CALL_FROM_ISR
#define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret)
Definition: FreeRTOS.h:605
xLIST_ITEM
Definition: list.h:141
PRIVILEGED_DATA
#define PRIVILEGED_DATA
Definition: mpu_wrappers.h:175
configTIMER_QUEUE_LENGTH
#define configTIMER_QUEUE_LENGTH
Definition: FreeRTOSConfig.h:30
xTimerGetPeriod
TickType_t xTimerGetPeriod(TimerHandle_t xTimer) PRIVILEGED_FUNCTION
pdFAIL
#define pdFAIL
Definition: projdefs.h:49
listIS_CONTAINED_WITHIN
#define listIS_CONTAINED_WITHIN(pxList, pxListItem)
Definition: list.h:318
xQueueSendToBackFromISR
#define xQueueSendToBackFromISR(xQueue, pvItemToQueue, pxHigherPriorityTaskWoken)
Definition: queue.h:1054
uxListRemove
UBaseType_t uxListRemove(ListItem_t *const pxItemToRemove)
Definition: list.c:171
xQueueSendFromISR
#define xQueueSendFromISR(xQueue, pvItemToQueue, pxHigherPriorityTaskWoken)
Definition: queue.h:1215
xQueueSendToBack
#define xQueueSendToBack(xQueue, pvItemToQueue, xTicksToWait)
Definition: queue.h:394
listGET_OWNER_OF_HEAD_ENTRY
#define listGET_OWNER_OF_HEAD_ENTRY(pxList)
Definition: list.h:307
vTaskSuspendAll
void vTaskSuspendAll(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2031
xTimerCreateTimerTask
BaseType_t xTimerCreateTimerTask(void) PRIVILEGED_FUNCTION
tmrCOMMAND_START_DONT_TRACE
#define tmrCOMMAND_START_DONT_TRACE
Definition: timers.h:57
xTimerIsTimerActive
BaseType_t xTimerIsTimerActive(TimerHandle_t xTimer) PRIVILEGED_FUNCTION
pdPASS
#define pdPASS
Definition: projdefs.h:48
PRIVILEGED_FUNCTION
#define PRIVILEGED_FUNCTION
Definition: mpu_wrappers.h:174
xTimerPendFunctionCall
BaseType_t xTimerPendFunctionCall(PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
xSTATIC_QUEUE
Definition: FreeRTOS.h:1048
TickType_t
uint32_t TickType_t
Definition: portmacro.h:64
configTIMER_TASK_STACK_DEPTH
#define configTIMER_TASK_STACK_DEPTH
Definition: FreeRTOSConfig.h:32
vQueueWaitForMessageRestricted
void vQueueWaitForMessageRestricted(QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely) PRIVILEGED_FUNCTION
pcTimerGetName
const char * pcTimerGetName(TimerHandle_t xTimer) PRIVILEGED_FUNCTION
listGET_LIST_ITEM_VALUE
#define listGET_LIST_ITEM_VALUE(pxListItem)
Definition: list.h:208
listSET_LIST_ITEM_VALUE
#define listSET_LIST_ITEM_VALUE(pxListItem, xValue)
Definition: list.h:198
listGET_ITEM_VALUE_OF_HEAD_ENTRY
#define listGET_ITEM_VALUE_OF_HEAD_ENTRY(pxList)
Definition: list.h:217
taskENTER_CRITICAL
#define taskENTER_CRITICAL()
Definition: task.h:179
TaskHandle_t
void * TaskHandle_t
Definition: task.h:62
pdFALSE
#define pdFALSE
Definition: projdefs.h:45
traceTIMER_EXPIRED
#define traceTIMER_EXPIRED(pxTimer)
Definition: FreeRTOS.h:541
UBaseType_t
unsigned long UBaseType_t
Definition: portmacro.h:58
xSTATIC_TIMER
Definition: FreeRTOS.h:1121
tmrCOMMAND_STOP
#define tmrCOMMAND_STOP
Definition: timers.h:60
tmrCOMMAND_RESET_FROM_ISR
#define tmrCOMMAND_RESET_FROM_ISR
Definition: timers.h:66
StackType_t
portSTACK_TYPE StackType_t
Definition: portmacro.h:56
queue.h
listLIST_IS_EMPTY
#define listLIST_IS_EMPTY(pxList)
Definition: list.h:250
xTimerGetTimerDaemonTaskHandle
TaskHandle_t xTimerGetTimerDaemonTaskHandle(void) PRIVILEGED_FUNCTION
vListInsert
void vListInsert(List_t *const pxList, ListItem_t *const pxNewListItem)
Definition: list.c:104
xSTATIC_TCB
Definition: FreeRTOS.h:986
pvTimerGetTimerID
void * pvTimerGetTimerID(const TimerHandle_t xTimer) PRIVILEGED_FUNCTION
tmrCOMMAND_CHANGE_PERIOD
#define tmrCOMMAND_CHANGE_PERIOD
Definition: timers.h:61
FreeRTOS.h
vTimerSetTimerID
void vTimerSetTimerID(TimerHandle_t xTimer, void *pvNewID) PRIVILEGED_FUNCTION
timers.h
traceTIMER_CREATE
#define traceTIMER_CREATE(pxNewTimer)
Definition: FreeRTOS.h:529
portYIELD_WITHIN_API
#define portYIELD_WITHIN_API
Definition: FreeRTOS.h:723
traceTIMER_COMMAND_RECEIVED
#define traceTIMER_COMMAND_RECEIVED(pxTimer, xMessageID, xMessageValue)
Definition: FreeRTOS.h:545
TimerHandle_t
void * TimerHandle_t
Definition: timers.h:77
BaseType_t
long BaseType_t
Definition: portmacro.h:57
pdTRUE
#define pdTRUE
Definition: projdefs.h:46
xTaskGetTickCount
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2214
QueueHandle_t
void * QueueHandle_t
Definition: queue.h:47
vQueueAddToRegistry
#define vQueueAddToRegistry(xQueue, pcName)
Definition: FreeRTOS.h:283
tmrCOMMAND_CHANGE_PERIOD_FROM_ISR
#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR
Definition: timers.h:68
tmrCOMMAND_DELETE
#define tmrCOMMAND_DELETE
Definition: timers.h:62
taskEXIT_CRITICAL
#define taskEXIT_CRITICAL()
Definition: task.h:194
xTimerPendFunctionCallFromISR
BaseType_t xTimerPendFunctionCallFromISR(PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
xTaskResumeAll
BaseType_t xTaskResumeAll(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2104
xTaskGetSchedulerState
BaseType_t xTaskGetSchedulerState(void) PRIVILEGED_FUNCTION
configASSERT
#define configASSERT(x)
Definition: FreeRTOS.h:235
StaticTimer_t
struct xSTATIC_TIMER StaticTimer_t
taskSCHEDULER_RUNNING
#define taskSCHEDULER_RUNNING
Definition: task.h:221
tmrFIRST_FROM_ISR_COMMAND
#define tmrFIRST_FROM_ISR_COMMAND
Definition: timers.h:64
tmrCOMMAND_STOP_FROM_ISR
#define tmrCOMMAND_STOP_FROM_ISR
Definition: timers.h:67
tmrCOMMAND_START
#define tmrCOMMAND_START
Definition: timers.h:58
vListInitialiseItem
void vListInitialiseItem(ListItem_t *const pxItem)
Definition: list.c:63
tmrCOMMAND_START_FROM_ISR
#define tmrCOMMAND_START_FROM_ISR
Definition: timers.h:65
mtCOVERAGE_TEST_MARKER
#define mtCOVERAGE_TEST_MARKER()
Definition: FreeRTOS.h:787
pvPortMalloc
void * pvPortMalloc(size_t xWantedSize)
Definition: heap_1.c:71