CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
smph.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: smph.h
3 * Revised: 2015-01-14 12:12:44 +0100 (on, 14 jan 2015)
4 * Revision: 42373
5 *
6 * Description: Defines and prototypes for the MCU Semaphore.
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38
39 //*****************************************************************************
40 //
43 //
44 //*****************************************************************************
45
46 #ifndef __SMPH_H__
47 #define __SMPH_H__
48
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include <inc/hw_types.h>
63 #include <inc/hw_smph.h>
64 #include <inc/hw_memmap.h>
65 #include <driverlib/debug.h>
66
67 //*****************************************************************************
68 //
69 // Support for DriverLib in ROM:
70 // This section renames all functions that are not "static inline", so that
71 // calling these functions will default to implementation in flash. At the end
72 // of this file a second renaming will change the defaults to implementation in
73 // ROM for available functions.
74 //
75 // To force use of the implementation in flash, e.g. for debugging:
76 // - Globally: Define DRIVERLIB_NOROM at project level
77 // - Per function: Use prefix "NOROM_" when calling the function
78 //
79 // Do not define DRIVERLIB_GENERATE_ROM!
80 //
81 //*****************************************************************************
82 #ifndef DRIVERLIB_GENERATE_ROM
83 #define SMPHAcquire NOROM_SMPHAcquire
84 #endif
85
86 //*****************************************************************************
87 //
88 // General constants and defines
89 //
90 //*****************************************************************************
91 #define SMPH_FREE 0x00000001 // MCU Semaphore has not been claimed
92 #define SMPH_CLAIMED 0x00000000 // MCU Semaphore has been claimed
93
94 //*****************************************************************************
95 //
96 // Values that can be passed to SMPHAcquire, SMPHTryAcquire and SMPHRelease
97 // as the ui32Semaphore parameter.
98 //
99 //*****************************************************************************
100 #define SMPH_0 0 // MCU Semaphore 0
101 #define SMPH_1 1 // MCU Semaphore 1
102 #define SMPH_2 2 // MCU Semaphore 2
103 #define SMPH_3 3 // MCU Semaphore 3
104 #define SMPH_4 4 // MCU Semaphore 4
105 #define SMPH_5 5 // MCU Semaphore 5
106 #define SMPH_6 6 // MCU Semaphore 6
107 #define SMPH_7 7 // MCU Semaphore 7
108 #define SMPH_8 8 // MCU Semaphore 8
109 #define SMPH_9 9 // MCU Semaphore 9
110 #define SMPH_10 10 // MCU Semaphore 10
111 #define SMPH_11 11 // MCU Semaphore 11
112 #define SMPH_12 12 // MCU Semaphore 12
113 #define SMPH_13 13 // MCU Semaphore 13
114 #define SMPH_14 14 // MCU Semaphore 14
115 #define SMPH_15 15 // MCU Semaphore 15
116 #define SMPH_16 16 // MCU Semaphore 16
117 #define SMPH_17 17 // MCU Semaphore 17
118 #define SMPH_18 18 // MCU Semaphore 18
119 #define SMPH_19 19 // MCU Semaphore 19
120 #define SMPH_20 20 // MCU Semaphore 20
121 #define SMPH_21 21 // MCU Semaphore 21
122 #define SMPH_22 22 // MCU Semaphore 22
123 #define SMPH_23 23 // MCU Semaphore 23
124 #define SMPH_24 24 // MCU Semaphore 24
125 #define SMPH_25 25 // MCU Semaphore 25
126 #define SMPH_26 26 // MCU Semaphore 26
127 #define SMPH_27 27 // MCU Semaphore 27
128 #define SMPH_28 28 // MCU Semaphore 28
129 #define SMPH_29 29 // MCU Semaphore 29
130 #define SMPH_30 30 // MCU Semaphore 30
131 #define SMPH_31 31 // MCU Semaphore 31
132
133 //*****************************************************************************
134 //
135 // API Functions and prototypes
136 //
137 //*****************************************************************************
138
139 //*****************************************************************************
140 //
153 //
154 //*****************************************************************************
155 extern void SMPHAcquire(uint32_t ui32Semaphore);
156
157 //*****************************************************************************
158 //
173 //
174 //*****************************************************************************
175 __STATIC_INLINE bool
176 SMPHTryAcquire(uint32_t ui32Semaphore)
177 {
178 uint32_t ui32SemaReg;
179
180 //
181 // Check the arguments.
182 //
183 ASSERT((ui32Semaphore == SMPH_0) ||
184 (ui32Semaphore == SMPH_1) ||
185 (ui32Semaphore == SMPH_2) ||
186 (ui32Semaphore == SMPH_3) ||
187 (ui32Semaphore == SMPH_4) ||
188 (ui32Semaphore == SMPH_5) ||
189 (ui32Semaphore == SMPH_6) ||
190 (ui32Semaphore == SMPH_7) ||
191 (ui32Semaphore == SMPH_8) ||
192 (ui32Semaphore == SMPH_9) ||
193 (ui32Semaphore == SMPH_10) ||
194 (ui32Semaphore == SMPH_11) ||
195 (ui32Semaphore == SMPH_12) ||
196 (ui32Semaphore == SMPH_13) ||
197 (ui32Semaphore == SMPH_14) ||
198 (ui32Semaphore == SMPH_15) ||
199 (ui32Semaphore == SMPH_16) ||
200 (ui32Semaphore == SMPH_17) ||
201 (ui32Semaphore == SMPH_18) ||
202 (ui32Semaphore == SMPH_19) ||
203 (ui32Semaphore == SMPH_20) ||
204 (ui32Semaphore == SMPH_21) ||
205 (ui32Semaphore == SMPH_22) ||
206 (ui32Semaphore == SMPH_23) ||
207 (ui32Semaphore == SMPH_24) ||
208 (ui32Semaphore == SMPH_25) ||
209 (ui32Semaphore == SMPH_26) ||
210 (ui32Semaphore == SMPH_27) ||
211 (ui32Semaphore == SMPH_28) ||
212 (ui32Semaphore == SMPH_29) ||
213 (ui32Semaphore == SMPH_30) ||
214 (ui32Semaphore == SMPH_31));
215
216 //
217 // Semaphore register reads 1 if lock was acquired
218 // (i.e. SMPH_FREE).
219 //
220 ui32SemaReg = HWREG(SMPH_BASE + SMPH_O_SMPH0 + 4 * ui32Semaphore);
221
222 return (ui32SemaReg == SMPH_FREE);
223 }
224
225 //*****************************************************************************
226 //
241 //
242 //*****************************************************************************
243 __STATIC_INLINE void
244 SMPHRelease(uint32_t ui32Semaphore)
245 {
246 //
247 // Check the arguments.
248 //
249 ASSERT((ui32Semaphore == SMPH_0) ||
250 (ui32Semaphore == SMPH_1) ||
251 (ui32Semaphore == SMPH_2) ||
252 (ui32Semaphore == SMPH_3) ||
253 (ui32Semaphore == SMPH_4) ||
254 (ui32Semaphore == SMPH_5) ||
255 (ui32Semaphore == SMPH_6) ||
256 (ui32Semaphore == SMPH_7) ||
257 (ui32Semaphore == SMPH_8) ||
258 (ui32Semaphore == SMPH_9) ||
259 (ui32Semaphore == SMPH_10) ||
260 (ui32Semaphore == SMPH_11) ||
261 (ui32Semaphore == SMPH_12) ||
262 (ui32Semaphore == SMPH_13) ||
263 (ui32Semaphore == SMPH_14) ||
264 (ui32Semaphore == SMPH_15) ||
265 (ui32Semaphore == SMPH_16) ||
266 (ui32Semaphore == SMPH_17) ||
267 (ui32Semaphore == SMPH_18) ||
268 (ui32Semaphore == SMPH_19) ||
269 (ui32Semaphore == SMPH_20) ||
270 (ui32Semaphore == SMPH_21) ||
271 (ui32Semaphore == SMPH_22) ||
272 (ui32Semaphore == SMPH_23) ||
273 (ui32Semaphore == SMPH_24) ||
274 (ui32Semaphore == SMPH_25) ||
275 (ui32Semaphore == SMPH_26) ||
276 (ui32Semaphore == SMPH_27) ||
277 (ui32Semaphore == SMPH_28) ||
278 (ui32Semaphore == SMPH_29) ||
279 (ui32Semaphore == SMPH_30) ||
280 (ui32Semaphore == SMPH_31));
281
282 //
283 // No check before release, it is up to the application to provide the
284 // conventions for who and when a semaphore can be released.
285 //
286 HWREG(SMPH_BASE + SMPH_O_SMPH0 + 4 * ui32Semaphore) = SMPH_FREE;
287 }
288
289 //*****************************************************************************
290 //
291 // Support for DriverLib in ROM:
292 // Redirect to implementation in ROM when available.
293 //
294 //*****************************************************************************
295 #ifndef DRIVERLIB_NOROM
296 #include <driverlib/rom.h>
297 #ifdef ROM_SMPHAcquire
298 #undef SMPHAcquire
299 #define SMPHAcquire ROM_SMPHAcquire
300 #endif
301 #endif
302
303 //*****************************************************************************
304 //
305 // Mark the end of the C bindings section for C++ compilers.
306 //
307 //*****************************************************************************
308 #ifdef __cplusplus
309 }
310 #endif
311
312 #endif // __SMPH_H__
313
314 //*****************************************************************************
315 //
318 //
319 //*****************************************************************************
SMPH_28
#define SMPH_28
Definition: smph.h:128
SMPH_8
#define SMPH_8
Definition: smph.h:108
SMPHAcquire
void SMPHAcquire(uint32_t ui32Semaphore)
Acquire a semaphore.
Definition: smph.c:58
SMPH_4
#define SMPH_4
Definition: smph.h:104
debug.h
SMPH_18
#define SMPH_18
Definition: smph.h:118
SMPH_1
#define SMPH_1
Definition: smph.h:101
SMPH_FREE
#define SMPH_FREE
Definition: smph.h:91
SMPH_11
#define SMPH_11
Definition: smph.h:111
SMPH_31
#define SMPH_31
Definition: smph.h:131
SMPHRelease
__STATIC_INLINE void SMPHRelease(uint32_t ui32Semaphore)
Release a semaphore.
Definition: smph.h:244
ASSERT
#define ASSERT(expr)
Definition: debug.h:65
SMPH_6
#define SMPH_6
Definition: smph.h:106
SMPH_25
#define SMPH_25
Definition: smph.h:125
SMPH_21
#define SMPH_21
Definition: smph.h:121
SMPH_24
#define SMPH_24
Definition: smph.h:124
SMPH_19
#define SMPH_19
Definition: smph.h:119
SMPH_12
#define SMPH_12
Definition: smph.h:112
SMPH_9
#define SMPH_9
Definition: smph.h:109
SMPH_29
#define SMPH_29
Definition: smph.h:129
SMPH_23
#define SMPH_23
Definition: smph.h:123
SMPH_17
#define SMPH_17
Definition: smph.h:117
SMPH_13
#define SMPH_13
Definition: smph.h:113
SMPH_0
#define SMPH_0
Definition: smph.h:100
SMPH_26
#define SMPH_26
Definition: smph.h:126
SMPH_2
#define SMPH_2
Definition: smph.h:102
SMPH_14
#define SMPH_14
Definition: smph.h:114
SMPH_30
#define SMPH_30
Definition: smph.h:130
SMPH_5
#define SMPH_5
Definition: smph.h:105
SMPH_10
#define SMPH_10
Definition: smph.h:110
SMPH_27
#define SMPH_27
Definition: smph.h:127
SMPH_15
#define SMPH_15
Definition: smph.h:115
rom.h
SMPH_16
#define SMPH_16
Definition: smph.h:116
SMPH_7
#define SMPH_7
Definition: smph.h:107
SMPHTryAcquire
__STATIC_INLINE bool SMPHTryAcquire(uint32_t ui32Semaphore)
Try to Acquire a semaphore.
Definition: smph.h:176
SMPH_20
#define SMPH_20
Definition: smph.h:120
SMPH_3
#define SMPH_3
Definition: smph.h:103
SMPH_22
#define SMPH_22
Definition: smph.h:122