FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_timer.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Common IO V1.0.0
3  * Copyright (C) 2019 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://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
26 /*******************************************************************************
27  * @file iot_timer.h
28  *
29  * @brief HAL APIs for a generic timer driver
30  *******************************************************************************
31  */
32 
38 #ifndef _IOT_TIMER_H_
39 #define _IOT_TIMER_H_
40 
49 #define IOT_TIMER_SUCCESS ( 0 )
50 #define IOT_TIMER_INVALID_VALUE ( 1 )
51 #define IOT_TIMER_FUNCTION_NOT_SUPPORTED ( 2 )
52 #define IOT_TIMER_NOT_RUNNING ( 3 )
53 #define IOT_TIMER_SET_FAILED ( 4 )
58 struct IotTimerDescriptor;
59 
65 typedef struct IotTimerDescriptor * IotTimerHandle_t;
66 
73 typedef void ( * IotTimerCallback_t)( void * pvUserContext );
74 
87 IotTimerHandle_t iot_timer_open( int32_t lTimerInstance );
88 
106 void iot_timer_set_callback( IotTimerHandle_t const pxTimerHandle,
107  IotTimerCallback_t xCallback,
108  void * pvUserContext );
109 
121 int32_t iot_timer_start( IotTimerHandle_t const pxTimerHandle );
122 
137 int32_t iot_timer_stop( IotTimerHandle_t const pxTimerHandle );
138 
151 int32_t iot_timer_get_value( IotTimerHandle_t const pxTimerHandle,
152  uint64_t * ullMicroSeconds );
153 
202 int32_t iot_timer_delay( IotTimerHandle_t const pxTimerHandle,
203  uint32_t ulDelayMicroSeconds );
204 
219 int32_t iot_timer_cancel( IotTimerHandle_t const pxTimerHandle );
220 
234 int32_t iot_timer_close( IotTimerHandle_t const pxTimerHandle );
235 
240 #endif /* ifndef _IOT_TIMER_H_ */
int32_t iot_timer_close(IotTimerHandle_t const pxTimerHandle)
iot_timer_close is used to de-initializes the timer, stops the timer if it was started and cancels th...
int32_t iot_timer_stop(IotTimerHandle_t const pxTimerHandle)
iot_timer_stop is used to stop the timer counter if the timer is running.
void(* IotTimerCallback_t)(void *pvUserContext)
timer callback notification type. This callback is used for notifying the caller when the setup timer...
Definition: iot_timer.h:73
void iot_timer_set_callback(IotTimerHandle_t const pxTimerHandle, IotTimerCallback_t xCallback, void *pvUserContext)
iot_timer_set_callback is used to set the callback to be called when the timer reaches the count (del...
int32_t iot_timer_get_value(IotTimerHandle_t const pxTimerHandle, uint64_t *ullMicroSeconds)
iot_timer_get_value is used to get the current timer value in micro seconds.
int32_t iot_timer_cancel(IotTimerHandle_t const pxTimerHandle)
iot_timer_cancel is used to cancel any existing delay call. If a call to iot_timer_delay() was made e...
IotTimerHandle_t iot_timer_open(int32_t lTimerInstance)
iot_timer_open is used to initialize the timer. This function will start the timer.
int32_t iot_timer_delay(IotTimerHandle_t const pxTimerHandle, uint32_t ulDelayMicroSeconds)
iot_timer_delay is used to set up a delay/wake-up time in microseconds. The caller can use this API t...
int32_t iot_timer_start(IotTimerHandle_t const pxTimerHandle)
iot_timer_start is used to start the timer counter. This call only makes the timer counter running...
struct IotTimerDescriptor * IotTimerHandle_t
IotTimerHandle_t type is the timer handle returned by calling iot_timer_open() this is initialized in...
Definition: iot_timer.h:65