TI BLE5-Stack API Documentation  9.14.00
bleapputil_timers.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3 @file bleapputil_timers.h
4 
5 @brief This file contains the BLE App Util timers APIs.
6 
7 Group: WCS, BTS
8 $Target Device: DEVICES $
9 
10 ******************************************************************************
11 $License: BSD3 2025 $
12 ******************************************************************************
13 $Release Name: PACKAGE NAME $
14 $Release Date: PACKAGE RELEASE DATE $
15 *****************************************************************************/
16 
17 #ifndef BLEAPPUTIL_TIMERS_H
18 #define BLEAPPUTIL_TIMERS_H
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 /*********************************************************************
26  * INCLUDES
27  */
28 
29 #include <stdint.h>
30 #include <stdbool.h>
31 
32 /*********************************************************************
33  * MACROS
34  */
35 
36 #define TIMER_SEC_TO_MS(sec) sec*1000
37 #define TIMER_MINUTES_TO_MS(min) TIMER_SEC_TO_MS(min*60)
38 #define TIMER_HOURS_TO_MS(hour) TIMER_MINUTES_TO_MS(hour*60)
39 #define TIMER_DAYS_TO_MS(day) TIMER_HOURS_TO_MS(day*24)
40 
41 // Invalid Timer Handle value
42 #define BLEAPPUTIL_TIMER_INVALID_HANDLE 0xFF
43 
44 /*********************************************************************
45  * TYPEDEFS
46  */
47 
48 typedef enum
49 {
53 
54 typedef uint8_t BLEAppUtil_timerHandle;
55 
56 typedef void (*BLEAppUtil_timerCB_t)(BLEAppUtil_timerHandle timerHandle, BLEAppUtil_timerTermReason_e reason, void *pData);
57 
58 /*********************************************************************
59  * GLOBAL VARIABLES
60  */
61 
62 /*********************************************************************
63  * FUNCTIONS
64  */
65 
66 /*********************************************************************
67  * @fn BLEAppUtil_startTimer
68  *
69  * @brief Start a timer instance
70  *
71  * @param timerCB - callback function that will be called when the timer expired
72  * @param timeInMS - the time to set in the timer
73  * @param isPeriodic - a flag that indicates if the timer is periodic or not
74  * @param pData - the data to pass to the timer callback
75  *
76  * @return Returns the timer handle
77  */
78 BLEAppUtil_timerHandle BLEAppUtil_startTimer(BLEAppUtil_timerCB_t timerCB, uint32_t timeInMS, bool isPeriodic, void *pData);
79 
80 /*********************************************************************
81  * @fn BLEAppUtil_abortTimer
82  *
83  * @brief Abort a timer instance
84  *
85  * @param timerHandle - the handle of the timer to abort
86  *
87  * @return None
88  */
89 int32_t BLEAppUtil_abortTimer(BLEAppUtil_timerHandle timerHandle);
90 
91 /*********************************************************************
92  * @fn BLEAppUtil_reschedulePeriodicTimer
93  *
94  * @brief Restart a timer instance
95  *
96  * @param timerHandle - the handle of the timer to reschedule
97  * @param timeInMS - the new time
98  * @param pData - the data to pass to the timer callback
99  *
100  * @return None
101  */
102 int32_t BLEAppUtil_reschedulePeriodicTimer(BLEAppUtil_timerHandle timerHandle, uint32_t time, void *pData);
103 
104 /*********************************************************************
105 *********************************************************************/
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* BLEAPPUTIL_TIMERS_H */
void(* BLEAppUtil_timerCB_t)(BLEAppUtil_timerHandle timerHandle, BLEAppUtil_timerTermReason_e reason, void *pData)
Definition: bleapputil_timers.h:56
BLEAppUtil_timerHandle BLEAppUtil_startTimer(BLEAppUtil_timerCB_t timerCB, uint32_t timeInMS, bool isPeriodic, void *pData)
Definition: bleapputil_timers.h:51
BLEAppUtil_timerTermReason_e
Definition: bleapputil_timers.h:48
int32_t BLEAppUtil_abortTimer(BLEAppUtil_timerHandle timerHandle)
uint8_t BLEAppUtil_timerHandle
Definition: bleapputil_timers.h:54
int32_t BLEAppUtil_reschedulePeriodicTimer(BLEAppUtil_timerHandle timerHandle, uint32_t time, void *pData)
Definition: bleapputil_timers.h:50
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale