1 /******************************************************************************
2 * Filename: smph.c
3 * Revised: 2015-01-13 16:59:55 +0100 (Tue, 13 Jan 2015)
4 * Revision: 42365
5 *
6 * Description: Driver 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 #include <driverlib/smph.h>
40
41 //*****************************************************************************
42 //
43 // Handle support for DriverLib in ROM:
44 // This section will undo prototype renaming made in the header file
45 //
46 //*****************************************************************************
47 #if !defined(DOXYGEN)
48 #undef SMPHAcquire
49 #define SMPHAcquire NOROM_SMPHAcquire
50 #endif
51
52 //*****************************************************************************
53 //
54 //! Acquire a semaphore
55 //
56 //*****************************************************************************
57 void
SMPHAcquire(uint32_t ui32Semaphore)58 SMPHAcquire(uint32_t ui32Semaphore)
59 {
60 //
61 // Check the arguments.
62 //
63 ASSERT((ui32Semaphore == SMPH_0) ||
64 (ui32Semaphore == SMPH_1) ||
65 (ui32Semaphore == SMPH_2) ||
66 (ui32Semaphore == SMPH_3) ||
67 (ui32Semaphore == SMPH_4) ||
68 (ui32Semaphore == SMPH_5) ||
69 (ui32Semaphore == SMPH_6) ||
70 (ui32Semaphore == SMPH_7) ||
71 (ui32Semaphore == SMPH_8) ||
72 (ui32Semaphore == SMPH_9) ||
73 (ui32Semaphore == SMPH_10) ||
74 (ui32Semaphore == SMPH_11) ||
75 (ui32Semaphore == SMPH_12) ||
76 (ui32Semaphore == SMPH_13) ||
77 (ui32Semaphore == SMPH_14) ||
78 (ui32Semaphore == SMPH_15) ||
79 (ui32Semaphore == SMPH_16) ||
80 (ui32Semaphore == SMPH_17) ||
81 (ui32Semaphore == SMPH_18) ||
82 (ui32Semaphore == SMPH_19) ||
83 (ui32Semaphore == SMPH_20) ||
84 (ui32Semaphore == SMPH_21) ||
85 (ui32Semaphore == SMPH_22) ||
86 (ui32Semaphore == SMPH_23) ||
87 (ui32Semaphore == SMPH_24) ||
88 (ui32Semaphore == SMPH_25) ||
89 (ui32Semaphore == SMPH_26) ||
90 (ui32Semaphore == SMPH_27) ||
91 (ui32Semaphore == SMPH_28) ||
92 (ui32Semaphore == SMPH_29) ||
93 (ui32Semaphore == SMPH_30) ||
94 (ui32Semaphore == SMPH_31));
95
96 //
97 // Wait for semaphore to be release such that it can be claimed
98 // Semaphore register reads 1 when lock was acquired otherwise 0
99 // (i.e. SMPH_CLAIMED).
100 //
101 while(HWREG(SMPH_BASE + SMPH_O_SMPH0 + 4 * ui32Semaphore) ==
102 SMPH_CLAIMED)
103 {
104 }
105 }
106