BLE-Stack APIs  3.00.00
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @defgroup Util Util
34  * @brief This module implements Utility function
35  * @{
36  * @file util.h
37  * @brief Util layer interface
38  */
39 
40 #ifndef UTIL_H
41 #define UTIL_H
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*********************************************************************
48  * INCLUDES
49  */
50 #include <ti/sysbios/knl/Clock.h>
51 #include <ti/sysbios/knl/Queue.h>
52 #ifdef ICALL_EVENTS
53 #include <ti/sysbios/knl/Event.h>
54 #else
55 #include <ti/sysbios/knl/Semaphore.h>
56 #endif //ICALL_EVENTS
57 
58 /*********************************************************************
59 * EXTERNAL VARIABLES
60 */
61 
62 /*********************************************************************
63  * CONSTANTS
64  */
65 
66 #ifdef ICALL_EVENTS
67 
74 #define UTIL_QUEUE_EVENT_ID Event_Id_30
75 #endif //ICALL_EVENTS
76 /*********************************************************************
77  * TYPEDEFS
78  */
79 
80 typedef struct
81 {
82  uint16_t event; // Event type.
83  uint8_t state; // Event state;
84 }appEvtHdr_t;
85 
86 /*********************************************************************
87  * MACROS
88  */
89 
90 /*********************************************************************
91  * API FUNCTIONS
92  */
93 
107 extern Clock_Handle Util_constructClock(Clock_Struct *pClock,
108  Clock_FuncPtr clockCB,
109  uint32_t clockDuration,
110  uint32_t clockPeriod,
111  uint8_t startFlag,
112  UArg arg);
113 
119 extern void Util_startClock(Clock_Struct *pClock);
120 
127 extern void Util_restartClock(Clock_Struct *pClock, uint32_t clockTimeout);
128 
137 extern bool Util_isActive(Clock_Struct *pClock);
138 
144 extern void Util_stopClock(Clock_Struct *pClock);
145 
152 extern void Util_rescheduleClock(Clock_Struct *pClock, uint32_t clockPeriod);
153 
162 extern Queue_Handle Util_constructQueue(Queue_Struct *pQueue);
163 
177 extern uint8_t Util_enqueueMsg(Queue_Handle msgQueue,
178  Event_Handle event,
179  uint8_t *pMsg);
180 
189 extern uint8_t *Util_dequeueMsg(Queue_Handle msgQueue);
190 
191 /*********************************************************************
192 *********************************************************************/
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* UTIL_H */
199 
uint8_t * Util_dequeueMsg(Queue_Handle msgQueue)
Dequeue the message from the RTOS queue.
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.
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 2016, Texas Instruments Incorporated