CC13xx Driver Library
aux_smph.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_smph.h
3 * Revised: 2015-07-16 12:12:04 +0200 (Thu, 16 Jul 2015)
4 * Revision: 44151
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 //
45 //
46 //*****************************************************************************
47 
48 #ifndef __AUX_SMPH_H__
49 #define __AUX_SMPH_H__
50 
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 #include <stdbool.h>
63 #include <stdint.h>
64 #include <inc/hw_types.h>
65 #include <inc/hw_aux_smph.h>
66 #include <inc/hw_memmap.h>
67 #include <driverlib/debug.h>
68 
69 //*****************************************************************************
70 //
71 // General constants and defines
72 //
73 //*****************************************************************************
74 #define AUX_SMPH_FREE 0x00000001 // MCU Semaphore has not been claimed
75 #define AUX_SMPH_CLAIMED 0x00000000 // MCU Semaphore has been claimed
76 
77 //*****************************************************************************
78 //
79 // Values that can be passed to AUXSMPHAcquire and AUXSMPHRelease
80 // as the ui32Semaphore parameter.
81 //
82 //*****************************************************************************
83 #define AUX_SMPH_0 0 // AUX Semaphore 0
84 #define AUX_SMPH_1 1 // AUX Semaphore 1
85 #define AUX_SMPH_2 2 // AUX Semaphore 2
86 #define AUX_SMPH_3 3 // AUX Semaphore 3
87 #define AUX_SMPH_4 4 // AUX Semaphore 4
88 #define AUX_SMPH_5 5 // AUX Semaphore 5
89 #define AUX_SMPH_6 6 // AUX Semaphore 6
90 #define AUX_SMPH_7 7 // AUX Semaphore 7
91 
92 //*****************************************************************************
93 //
94 // API Functions and prototypes
95 //
96 //*****************************************************************************
97 
98 //*****************************************************************************
99 //
122 //
123 //*****************************************************************************
124 __STATIC_INLINE void
125 AUXSMPHAcquire(uint32_t ui32Semaphore)
126 {
127  //
128  // Check the arguments.
129  //
130  ASSERT((ui32Semaphore == AUX_SMPH_0) ||
131  (ui32Semaphore == AUX_SMPH_1) ||
132  (ui32Semaphore == AUX_SMPH_2) ||
133  (ui32Semaphore == AUX_SMPH_3) ||
134  (ui32Semaphore == AUX_SMPH_4) ||
135  (ui32Semaphore == AUX_SMPH_5) ||
136  (ui32Semaphore == AUX_SMPH_6) ||
137  (ui32Semaphore == AUX_SMPH_7));
138 
139  //
140  // Wait for semaphore to be released such that it can be claimed
141  // Semaphore register reads 1 when lock was acquired otherwise 0
142  // (i.e. AUX_SMPH_CLAIMED).
143  //
144  while(HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 + 4 * ui32Semaphore) ==
146  {
147  }
148 }
149 
150 //*****************************************************************************
151 //
174 //
175 //*****************************************************************************
176 __STATIC_INLINE bool
177 AUXSMPHTryAcquire(uint32_t ui32Semaphore)
178 {
179  uint32_t ui32SemaReg;
180 
181  //
182  // Check the arguments.
183  //
184  ASSERT((ui32Semaphore == AUX_SMPH_0) ||
185  (ui32Semaphore == AUX_SMPH_1) ||
186  (ui32Semaphore == AUX_SMPH_2) ||
187  (ui32Semaphore == AUX_SMPH_3) ||
188  (ui32Semaphore == AUX_SMPH_4) ||
189  (ui32Semaphore == AUX_SMPH_5) ||
190  (ui32Semaphore == AUX_SMPH_6) ||
191  (ui32Semaphore == AUX_SMPH_7));
192 
193  //
194  // AUX Semaphore register reads 1 if lock was acquired
195  // (i.e. SMPH_FREE when read) but subsequent reads will read 0.
196  //
197  ui32SemaReg = HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 + 4 * ui32Semaphore);
198 
199  return (ui32SemaReg == AUX_SMPH_FREE);
200 }
201 
202 //*****************************************************************************
203 //
228 //
229 //*****************************************************************************
230 __STATIC_INLINE void
231 AUXSMPHRelease(uint32_t ui32Semaphore)
232 {
233  //
234  // Check the arguments.
235  //
236  ASSERT((ui32Semaphore == AUX_SMPH_0) ||
237  (ui32Semaphore == AUX_SMPH_1) ||
238  (ui32Semaphore == AUX_SMPH_2) ||
239  (ui32Semaphore == AUX_SMPH_3) ||
240  (ui32Semaphore == AUX_SMPH_4) ||
241  (ui32Semaphore == AUX_SMPH_5) ||
242  (ui32Semaphore == AUX_SMPH_6) ||
243  (ui32Semaphore == AUX_SMPH_7));
244 
245  //
246  // No check before release. It is up to the application to provide the
247  // conventions for who and when a semaphore can be released.
248  //
249  HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0 + 4 * ui32Semaphore) =
251 }
252 
253 //*****************************************************************************
254 //
255 // Mark the end of the C bindings section for C++ compilers.
256 //
257 //*****************************************************************************
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif // __AUX_SMPH_H__
263 
264 //*****************************************************************************
265 //
269 //
270 //*****************************************************************************
#define AUX_SMPH_2
Definition: aux_smph.h:85
#define AUX_SMPH_3
Definition: aux_smph.h:86
#define AUX_SMPH_6
Definition: aux_smph.h:89
static bool AUXSMPHTryAcquire(uint32_t ui32Semaphore)
Try to acquire an AUX semaphore.
Definition: aux_smph.h:177
static void AUXSMPHAcquire(uint32_t ui32Semaphore)
Acquire an AUX semaphore.
Definition: aux_smph.h:125
#define AUX_SMPH_1
Definition: aux_smph.h:84
static void AUXSMPHRelease(uint32_t ui32Semaphore)
Release an AUX semaphore by System CPU master.
Definition: aux_smph.h:231
#define AUX_SMPH_CLAIMED
Definition: aux_smph.h:75
#define AUX_SMPH_FREE
Definition: aux_smph.h:74
#define AUX_SMPH_7
Definition: aux_smph.h:90
#define ASSERT(expr)
Definition: debug.h:74
#define AUX_SMPH_0
Definition: aux_smph.h:83
#define AUX_SMPH_4
Definition: aux_smph.h:87
#define AUX_SMPH_5
Definition: aux_smph.h:88