CC26xx Driver Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aux_smph.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_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 AUX 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 __AUX_SMPH_H__
47 #define __AUX_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_aux_smph.h>
64 #include <inc/hw_memmap.h>
65 #include <driverlib/debug.h>
66 
67 //*****************************************************************************
68 //
69 // General constants and defines
70 //
71 //*****************************************************************************
72 #define AUX_SMPH_FREE 0x00000001 // MCU Semaphore has not been claimed
73 #define AUX_SMPH_CLAIMED 0x00000000 // MCU Semaphore has been claimed
74 
75 //*****************************************************************************
76 //
77 // Values that can be passed to AUXSMPHAcquire and AUXSMPHRelease
78 // as the ui32Semaphore parameter.
79 //
80 //*****************************************************************************
81 #define AUX_SMPH_0 0 // AUX Semaphore 0
82 #define AUX_SMPH_1 1 // AUX Semaphore 1
83 #define AUX_SMPH_2 2 // AUX Semaphore 2
84 #define AUX_SMPH_3 3 // AUX Semaphore 3
85 #define AUX_SMPH_4 4 // AUX Semaphore 4
86 #define AUX_SMPH_5 5 // AUX Semaphore 5
87 #define AUX_SMPH_6 6 // AUX Semaphore 6
88 #define AUX_SMPH_7 7 // AUX Semaphore 7
89 
90 //*****************************************************************************
91 //
92 // API Functions and prototypes
93 //
94 //*****************************************************************************
95 
96 //*****************************************************************************
97 //
120 //
121 //*****************************************************************************
122 __STATIC_INLINE void
123 AUXSMPHAcquire(uint32_t ui32Semaphore)
124 {
125  //
126  // Check the arguments.
127  //
128  ASSERT((ui32Semaphore == AUX_SMPH_0) ||
129  (ui32Semaphore == AUX_SMPH_1) ||
130  (ui32Semaphore == AUX_SMPH_2) ||
131  (ui32Semaphore == AUX_SMPH_3) ||
132  (ui32Semaphore == AUX_SMPH_4) ||
133  (ui32Semaphore == AUX_SMPH_5) ||
134  (ui32Semaphore == AUX_SMPH_6) ||
135  (ui32Semaphore == AUX_SMPH_7));
136 
137  //
138  // Wait for semaphore to be released such that it can be claimed
139  // Semaphore register reads 1 when lock was acquired otherwise 0
140  // (i.e. AUX_SMPH_CLAIMED).
141  //
142  while(HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 + 4 * ui32Semaphore) ==
144  {
145  }
146 }
147 
148 //*****************************************************************************
149 //
172 //
173 //*****************************************************************************
174 __STATIC_INLINE bool
175 AUXSMPHTryAcquire(uint32_t ui32Semaphore)
176 {
177  uint32_t ui32SemaReg;
178 
179  //
180  // Check the arguments.
181  //
182  ASSERT((ui32Semaphore == AUX_SMPH_0) ||
183  (ui32Semaphore == AUX_SMPH_1) ||
184  (ui32Semaphore == AUX_SMPH_2) ||
185  (ui32Semaphore == AUX_SMPH_3) ||
186  (ui32Semaphore == AUX_SMPH_4) ||
187  (ui32Semaphore == AUX_SMPH_5) ||
188  (ui32Semaphore == AUX_SMPH_6) ||
189  (ui32Semaphore == AUX_SMPH_7));
190 
191  //
192  // AUX Semaphore register reads 1 if lock was acquired
193  // (i.e. SMPH_FREE when read) but subsequent reads will read 0.
194  //
195  ui32SemaReg = HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 + 4 * ui32Semaphore);
196 
197  return (ui32SemaReg == AUX_SMPH_FREE);
198 }
199 
200 //*****************************************************************************
201 //
226 //
227 //*****************************************************************************
228 __STATIC_INLINE void
229 AUXSMPHRelease(uint32_t ui32Semaphore)
230 {
231  //
232  // Check the arguments.
233  //
234  ASSERT((ui32Semaphore == AUX_SMPH_0) ||
235  (ui32Semaphore == AUX_SMPH_1) ||
236  (ui32Semaphore == AUX_SMPH_2) ||
237  (ui32Semaphore == AUX_SMPH_3) ||
238  (ui32Semaphore == AUX_SMPH_4) ||
239  (ui32Semaphore == AUX_SMPH_5) ||
240  (ui32Semaphore == AUX_SMPH_6) ||
241  (ui32Semaphore == AUX_SMPH_7));
242 
243  //
244  // No check before release. It is up to the application to provide the
245  // conventions for who and when a semaphore can be released.
246  //
247  HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 + 4 * ui32Semaphore) =
249 }
250 
251 //*****************************************************************************
252 //
253 // Mark the end of the C bindings section for C++ compilers.
254 //
255 //*****************************************************************************
256 #ifdef __cplusplus
257 }
258 #endif
259 
260 #endif // __AUX_SMPH_H__
261 
262 //*****************************************************************************
263 //
266 //
267 //*****************************************************************************
#define AUX_SMPH_2
Definition: aux_smph.h:83
#define AUX_SMPH_3
Definition: aux_smph.h:84
__STATIC_INLINE void AUXSMPHAcquire(uint32_t ui32Semaphore)
Acquire an AUX semaphore.
Definition: aux_smph.h:123
#define AUX_SMPH_6
Definition: aux_smph.h:87
__STATIC_INLINE bool AUXSMPHTryAcquire(uint32_t ui32Semaphore)
Try to acquire an AUX semaphore.
Definition: aux_smph.h:175
#define ASSERT(expr)
Definition: debug.h:65
#define AUX_SMPH_1
Definition: aux_smph.h:82
#define AUX_SMPH_CLAIMED
Definition: aux_smph.h:73
#define AUX_SMPH_FREE
Definition: aux_smph.h:72
#define AUX_SMPH_7
Definition: aux_smph.h:88
#define AUX_SMPH_0
Definition: aux_smph.h:81
__STATIC_INLINE void AUXSMPHRelease(uint32_t ui32Semaphore)
Release an AUX semaphore by CM3 master.
Definition: aux_smph.h:229
#define AUX_SMPH_4
Definition: aux_smph.h:85
#define AUX_SMPH_5
Definition: aux_smph.h:86