TI BLE5-Stack API Documentation  2.02.04.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 #ifdef FREERTOS
38 #include <mqueue.h>
39 #include <pthread.h>
40  #ifndef Event_Handle
41  #define Event_Handle void*
42  #endif
43 #else
44 #include <ti/sysbios/knl/Queue.h>
45 #include <ti/sysbios/knl/Clock.h>
46 #include <ti/sysbios/knl/Event.h>
47 #endif
48 
49 /*********************************************************************
50 * EXTERNAL VARIABLES
51 */
52 
53 /*********************************************************************
54  * CONSTANTS
55  */
56 
64 #ifdef FREERTOS
65 #define UTIL_QUEUE_EVENT_ID (0x40000000)//Event_Id_30
66 #else
67 #define UTIL_QUEUE_EVENT_ID Event_Id_30
68 #endif
69 /*********************************************************************
70  * TYPEDEFS
71  */
72 
73 #ifdef FREERTOS
74 typedef struct Clock_Struct
75 {
76  timer_t clock;
77  void *cback;
78  void *arg;
79  sigevent evnt;
80  pthread_attr_t timerThrdAttr;
81  struct itimerspec timeVal;
82  uint8_t isActive;
83 }Clock_Struct;
84 #endif
85 
86 typedef struct
87 {
88  uint16_t event; // Event type.
89  uint8_t state; // Event state;
90 }appEvtHdr_t;
91 
92 /*********************************************************************
93  * MACROS
94  */
95 
96 /*********************************************************************
97  * API FUNCTIONS
98  */
99 
113 #ifdef FREERTOS
114 void* Util_constructClock(Clock_Struct *entry, void *clockCB,
115  uint32_t clockDuration, uint32_t clockPeriod,
116  uint8_t startFlag, void *arg);
117 
118 void Clock_destruct(Clock_Struct *structP);
119 #else
120 extern Clock_Handle Util_constructClock(Clock_Struct *pClock,
121  Clock_FuncPtr clockCB,
122  uint32_t clockDuration,
123  uint32_t clockPeriod,
124  uint8_t startFlag,
125  UArg arg);
126 #endif
127 
135 extern void Util_startClock(Clock_Struct *pClock);
136 
145 extern void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout);
146 
154 extern bool Util_isActive(Clock_Struct *pClock);
155 
163 extern void Util_stopClock(Clock_Struct *pClock);
164 
172 extern void Util_rescheduleClock(Clock_Struct *pClock, uint32_t clockPeriod);
173 
182 #ifdef FREERTOS
183 extern void Util_constructQueue(mqd_t *pQueue);
184 #else
185 extern Queue_Handle Util_constructQueue(Queue_Struct *pQueue);
186 #endif
187 
200 #ifdef FREERTOS
201 uint8_t Util_enqueueMsg(mqd_t msgQueue,
202  Event_Handle event,
203  uint8_t *pMsg);
204 #else
205 
206 extern uint8_t Util_enqueueMsg(Queue_Handle msgQueue,
207  Event_Handle event,
208  uint8_t *pMsg);
209 #endif
210 
218 #ifdef FREERTOS
219 uint8_t *Util_dequeueMsg(mqd_t msgQueue);
220 #else
221 extern uint8_t *Util_dequeueMsg(Queue_Handle msgQueue);
222 #endif
223 
232 extern char *Util_convertBdAddr2Str(uint8_t *pAddr);
233 
243 extern uint8_t Util_isBufSet(uint8_t *pBuf, uint8_t pattern, uint16_t len);
244 
245 
246 /*********************************************************************
247 *********************************************************************/
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 
253 #endif /* UTIL_H */
254 
uint8_t * Util_dequeueMsg(Queue_Handle msgQueue)
Dequeues the message from the RTOS queue.
uint8_t Util_isBufSet(uint8_t *pBuf, uint8_t pattern, uint16_t len)
Check if contents of buffer matches byte pattern.
uint8_t Util_enqueueMsg(Queue_Handle msgQueue, Event_Handle event, uint8_t *pMsg)
Creates a queue node and puts the node in RTOS queue.
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.
char * Util_convertBdAddr2Str(uint8_t *pAddr)
Convert Bluetooth address to string. Only needed when LCD display is used.
void Util_stopClock(Clock_Struct *pClock)
Stop a clock.
void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout)
Restart a clock by changing the timeout.
Clock_Handle Util_constructClock(Clock_Struct *pClock, Clock_FuncPtr clockCB, uint32_t clockDuration, uint32_t clockPeriod, uint8_t startFlag, UArg arg)
Initialize a TIRTOS Clock instance.
Queue_Handle Util_constructQueue(Queue_Struct *pQueue)
Initialize an RTOS queue to hold messages from profile to be processed.
bool Util_isActive(Clock_Struct *pClock)
Determine if a clock is currently active.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale