TI BLE5-Stack API Documentation  9.14.00
util.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file util.h
4 
5  @brief This file contains function declarations common to CC26xx
6  TIRTOS Applications.
7 
8  Group: WCS, BTS
9  $Target Device: DEVICES $
10 
11  ******************************************************************************
12  $License: BSD3 2014 $
13  ******************************************************************************
14  $Release Name: PACKAGE NAME $
15  $Release Date: PACKAGE RELEASE DATE $
16  *****************************************************************************/
17 
26 #ifndef UTIL_H
27 #define UTIL_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*********************************************************************
34  * INCLUDES
35  */
36 #include <stdbool.h>
37 #include <mqueue.h>
38 #include <pthread.h>
39 #include <ti/drivers/Power.h>
40 #ifndef Event_Handle
41 #define Event_Handle void*
42 #endif
43 
44 /*********************************************************************
45 * EXTERNAL VARIABLES
46 */
47 
48 /*********************************************************************
49  * CONSTANTS
50  */
51 
59 #define UTIL_EVENT_ID_NONE (0) // Event_Id_NONE
60 #define UTIL_EVENT_ID_00 (0x1) // Event_Id_00
61 #define UTIL_EVENT_ID_01 (0x2) // Event_Id_01
62 #define UTIL_EVENT_ID_02 (0x4) // Event_Id_02
63 #define UTIL_EVENT_ID_03 (0x8) // Event_Id_03
64 #define UTIL_EVENT_ID_04 (0x10)// Event_Id_04
65 #define UTIL_EVENT_ID_05 (0x20)// Event_Id_05
66 #define UTIL_EVENT_ID_06 (0x40)// Event_Id_06
67 #define UTIL_QUEUE_EVENT_ID (0x00100000)//Event_Id_30
68 #define UTIL_TL_CB_EVENT UTIL_EVENT_ID_00 // Event_Id_00
69 /*********************************************************************
70  * TYPEDEFS
71  */
72 
73 typedef void (*UtilTimerCback)(uint32_t arg);
74 
75 typedef struct Clock_Struct
76 {
77  timer_t clock;
79  uint32_t arg;
80  sigevent evnt;
81  pthread_attr_t timerThrdAttr;
82  struct itimerspec timeVal;
83  uint8_t isActive;
85 
86 typedef struct
87 {
88  uint16_t event; // Event type.
89  uint8_t state; // Event state;
91 
92 /*********************************************************************
93  * MACROS
94  */
95 
96 /* system restart */
97 #define SystemReset() Power_reset();
98 
99 /*********************************************************************
100  * API FUNCTIONS
101  */
102 
116 void* Util_constructClock(Clock_Struct *entry, UtilTimerCback clockCB,
117  uint32_t clockDuration, uint32_t clockPeriod,
118  uint8_t startFlag, uint32_t arg);
119 
120 void Clock_destruct(Clock_Struct *structP);
121 
129 extern void Util_startClock(Clock_Struct *pClock);
130 
139 extern void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout);
140 
148 extern bool Util_isActive(Clock_Struct *pClock);
149 
157 extern void Util_stopClock(Clock_Struct *pClock);
158 
166 extern void Util_rescheduleClock(Clock_Struct *pClock, uint32_t clockPeriod);
167 
176 extern void Util_constructQueue(mqd_t *pQueue);
177 
190 uint8_t Util_enqueueMsg(mqd_t msgQueue,
191  Event_Handle event,
192  uint8_t *pMsg);
193 
201 uint8_t *Util_dequeueMsg(mqd_t msgQueue);
202 
211 extern char *Util_convertBdAddr2Str(uint8_t *pAddr);
212 
222 extern uint8_t Util_isBufSet(uint8_t *pBuf, uint8_t pattern, uint16_t len);
223 
224 /*********************************************************************
225  * @fn Event_post
226  *
227  * @brief DPL that is used to signal events. If a task is waiting
228  * for the event and the event conditions are met, post()
229  * unblocks the task. If no tasks are waiting, post() simply
230  * registers the event with the event object and returns.
231  *
232  * @param eventQueue - handle of a event queue
233  * @param msg - mask of eventIds to post (must be non-zero)
234  */
235 extern void Event_post(mqd_t eventQueue, uint32_t msg);
236 
237 /*********************************************************************
238 *********************************************************************/
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif /* UTIL_H */
245 
timer_t clock
Definition: util.h:77
uint8_t Util_isBufSet(uint8_t *pBuf, uint8_t pattern, uint16_t len)
Check if contents of buffer matches byte pattern.
void * Util_constructClock(Clock_Struct *entry, UtilTimerCback clockCB, uint32_t clockDuration, uint32_t clockPeriod, uint8_t startFlag, uint32_t arg)
Initialize a TIRTOS Clock instance.
struct Clock_Struct Clock_Struct
void(* UtilTimerCback)(uint32_t arg)
Definition: util.h:73
Definition: util.h:75
void Event_post(mqd_t eventQueue, uint32_t msg)
void Util_rescheduleClock(Clock_Struct *pClock, uint32_t clockPeriod)
Reschedule a clock by changing the timeout and period values.
void Util_startClock(Clock_Struct *pClock)
Start a clock.
void Util_constructQueue(mqd_t *pQueue)
Initialize an RTOS queue to hold messages from profile to be processed.
uint16_t event
Definition: util.h:88
uint8_t state
Definition: util.h:89
uint32_t arg
Definition: util.h:79
char * Util_convertBdAddr2Str(uint8_t *pAddr)
Convert Bluetooth address to string. Only needed when LCD display is used.
uint8_t * Util_dequeueMsg(mqd_t msgQueue)
Dequeues the message from the RTOS queue.
void Util_stopClock(Clock_Struct *pClock)
Stop a clock.
sigevent evnt
Definition: util.h:80
void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout)
Restart a clock by changing the timeout.
uint8_t Util_enqueueMsg(mqd_t msgQueue, Event_Handle event, uint8_t *pMsg)
Creates a queue node and puts the node in RTOS queue.
pthread_attr_t timerThrdAttr
Definition: util.h:81
uint8_t isActive
Definition: util.h:83
struct itimerspec timeVal
Definition: util.h:82
#define Event_Handle
Definition: util.h:41
void Clock_destruct(Clock_Struct *structP)
Definition: util.h:86
UtilTimerCback cback
Definition: util.h:78
bool Util_isActive(Clock_Struct *pClock)
Determine if a clock is currently active.
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale