ZestCode
 
Loading...
Searching...
No Matches
timers.h
1/*
2 * FreeRTOS Kernel V10.0.1
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
24 *
25 * 1 tab == 4 spaces!
26 */
27
28
29#ifndef TIMERS_H
30#define TIMERS_H
31
32#ifndef INC_FREERTOS_H
33 #error "include FreeRTOS.h must appear in source files before include timers.h"
34#endif
35
36/*lint -save -e537 This headers are only multiply included if the application code
37happens to also be including task.h. */
38#include "task.h"
39/*lint -restore */
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/*-----------------------------------------------------------
46 * MACROS AND DEFINITIONS
47 *----------------------------------------------------------*/
48
49/* IDs for commands that can be sent/received on the timer queue. These are to
50be used solely through the macros that make up the public software timer API,
51as defined below. The commands that are sent from interrupts must use the
52highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task
53or interrupt version of the queue send function should be used. */
54#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( int32_t ) -2 )
55#define tmrCOMMAND_EXECUTE_CALLBACK ( ( int32_t ) -1 )
56#define tmrCOMMAND_START_DONT_TRACE ( ( int32_t ) 0 )
57#define tmrCOMMAND_START ( ( int32_t ) 1 )
58#define tmrCOMMAND_RESET ( ( int32_t ) 2 )
59#define tmrCOMMAND_STOP ( ( int32_t ) 3 )
60#define tmrCOMMAND_CHANGE_PERIOD ( ( int32_t ) 4 )
61#define tmrCOMMAND_DELETE ( ( int32_t ) 5 )
62
63#define tmrFIRST_FROM_ISR_COMMAND ( ( int32_t ) 6 )
64#define tmrCOMMAND_START_FROM_ISR ( ( int32_t ) 6 )
65#define tmrCOMMAND_RESET_FROM_ISR ( ( int32_t ) 7 )
66#define tmrCOMMAND_STOP_FROM_ISR ( ( int32_t ) 8 )
67#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( int32_t ) 9 )
68
69
76typedef void * TimerHandle_t;
77
78/*
79 * Defines the prototype to which timer callback functions must conform.
80 */
81typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );
82
83/*
84 * Defines the prototype to which functions used with the
85 * xTimerPendFunctionCallFromISR() function must conform.
86 */
87typedef void (*PendedFunction_t)( void *, uint32_t );
88
226#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
227 TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
228 const uint32_t xTimerPeriodInTicks,
229 const uint32_t uxAutoReload,
230 void * const pvTimerID,
231 TimerCallbackFunction_t pxCallbackFunction ) ;
232#endif
233
356#if( configSUPPORT_STATIC_ALLOCATION == 1 )
357 TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
358 const uint32_t xTimerPeriodInTicks,
359 const uint32_t uxAutoReload,
360 void * const pvTimerID,
361 TimerCallbackFunction_t pxCallbackFunction,
362 StaticTimer_t *pxTimerBuffer ) ;
363#endif /* configSUPPORT_STATIC_ALLOCATION */
364
385void *pvTimerGetTimerID( const TimerHandle_t xTimer ) ;
386
406void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) ;
407
443int32_t xTimerIsTimerActive( TimerHandle_t xTimer ) ;
444
451task_t xTimerGetTimerDaemonTaskHandle( void ) ;
452
503#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( millis() ), NULL, ( xTicksToWait ) )
504
545#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
546
625 #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
626
663#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
664
787#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( millis() ), NULL, ( xTicksToWait ) )
788
873#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
874
936#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
937
1009#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
1010
1095#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
1096
1097
1186int32_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, int32_t *pxHigherPriorityTaskWoken ) ;
1187
1220int32_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, uint32_t xTicksToWait ) ;
1221
1231const char * pcTimerGetName( TimerHandle_t xTimer ) ; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1232
1242uint32_t xTimerGetPeriod( TimerHandle_t xTimer ) ;
1243
1257uint32_t xTimerGetExpiryTime( TimerHandle_t xTimer ) ;
1258
1259/*
1260 * Functions beyond this part are not part of the public API and are intended
1261 * for use by the kernel only.
1262 */
1263int32_t xTimerCreateTimerTask( void ) ;
1264int32_t xTimerGenericCommand( TimerHandle_t xTimer, const int32_t xCommandID, const uint32_t xOptionalValue, int32_t * const pxHigherPriorityTaskWoken, const uint32_t xTicksToWait ) ;
1265
1266#if( configUSE_TRACE_FACILITY == 1 )
1267 void vTimerSetTimerNumber( TimerHandle_t xTimer, uint32_t uxTimerNumber ) ;
1268 uint32_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) ;
1269#endif
1270
1271#ifdef __cplusplus
1272}
1273#endif
1274#endif /* TIMERS_H */
1275
1276
1277
void * task_t
Definition rtos.h:100