2 * -------------------------------------------
3 * MSP432 DriverLib - v3_10_00_09
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2014, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
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,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 //*****************************************************************************
43 // Wrapper function for the CPSID instruction. Returns the state of PRIMASK
46 //*****************************************************************************
48 uint32_t __attribute__((naked)) CPU_cpsid(void)
53 // Read PRIMASK and disable interrupts.
55 __asm(" mrs r0, PRIMASK\n"
61 // The return is handled in the inline assembly, but the compiler will
62 // still complain if there is not an explicit return here (despite the fact
63 // that this does not result in any code being produced because of the
69 #if defined(__ICCARM__)
70 uint32_t CPU_cpsid(void)
73 // Read PRIMASK and disable interrupts.
75 __asm(" mrs r0, PRIMASK\n"
79 // "Warning[Pe940]: missing return statement at end of non-void function"
80 // is suppressed here to avoid putting a "bx lr" in the inline assembly
81 // above and a superfluous return statement here.
83 #pragma diag_suppress=Pe940
85 #pragma diag_default=Pe940
88 __asm uint32_t CPU_cpsid(void)
91 // Read PRIMASK and disable interrupts.
98 #if defined(__TI_ARM__)
99 uint32_t CPU_cpsid(void)
102 // Read PRIMASK and disable interrupts.
104 __asm(" mrs r0, PRIMASK\n"
109 // The following keeps the compiler happy, because it wants to see a
110 // return value from this function. It will generate code to return
111 // a zero. However, the real return is the "bx lr" above, so the
112 // return(0) is never executed and the function returns with the value
119 //*****************************************************************************
121 // Wrapper function returning the state of PRIMASK (indicating whether
122 // interrupts are enabled or disabled).
124 //*****************************************************************************
125 #if defined(__GNUC__)
126 uint32_t __attribute__((naked)) CPU_primask(void)
131 // Read PRIMASK and disable interrupts.
133 __asm(" mrs r0, PRIMASK\n"
138 // The return is handled in the inline assembly, but the compiler will
139 // still complain if there is not an explicit return here (despite the fact
140 // that this does not result in any code being produced because of the
146 #if defined(__ICCARM__)
147 uint32_t CPU_primask(void)
150 // Read PRIMASK and disable interrupts.
152 __asm(" mrs r0, PRIMASK\n");
155 // "Warning[Pe940]: missing return statement at end of non-void function"
156 // is suppressed here to avoid putting a "bx lr" in the inline assembly
157 // above and a superfluous return statement here.
159 #pragma diag_suppress=Pe940
161 #pragma diag_default=Pe940
163 #if defined(__CC_ARM)
164 __asm uint32_t CPU_primask(void)
167 // Read PRIMASK and disable interrupts.
173 #if defined(__TI_ARM__)
174 uint32_t CPU_primask(void)
177 // Read PRIMASK and disable interrupts.
179 __asm(" mrs r0, PRIMASK\n"
183 // The following keeps the compiler happy, because it wants to see a
184 // return value from this function. It will generate code to return
185 // a zero. However, the real return is the "bx lr" above, so the
186 // return(0) is never executed and the function returns with the value
193 //*****************************************************************************
195 // Wrapper function for the CPSIE instruction. Returns the state of PRIMASK
198 //*****************************************************************************
199 #if defined(__GNUC__)
200 uint32_t __attribute__((naked)) CPU_cpsie(void)
205 // Read PRIMASK and enable interrupts.
207 __asm(" mrs r0, PRIMASK\n"
213 // The return is handled in the inline assembly, but the compiler will
214 // still complain if there is not an explicit return here (despite the fact
215 // that this does not result in any code being produced because of the
221 #if defined(__ICCARM__)
222 uint32_t CPU_cpsie(void)
225 // Read PRIMASK and enable interrupts.
227 __asm(" mrs r0, PRIMASK\n"
231 // "Warning[Pe940]: missing return statement at end of non-void function"
232 // is suppressed here to avoid putting a "bx lr" in the inline assembly
233 // above and a superfluous return statement here.
235 #pragma diag_suppress=Pe940
237 #pragma diag_default=Pe940
239 #if defined(__CC_ARM)
240 __asm uint32_t CPU_cpsie(void)
243 // Read PRIMASK and enable interrupts.
250 #if defined(__TI_ARM__)
251 uint32_t CPU_cpsie(void)
254 // Read PRIMASK and enable interrupts.
256 __asm(" mrs r0, PRIMASK\n"
261 // The following keeps the compiler happy, because it wants to see a
262 // return value from this function. It will generate code to return
263 // a zero. However, the real return is the "bx lr" above, so the
264 // return(0) is never executed and the function returns with the value
271 //*****************************************************************************
273 // Wrapper function for the CPUWFI instruction.
275 //*****************************************************************************
276 #if defined(__GNUC__)
277 void __attribute__((naked)) CPU_wfi(void)
280 // Wait for the next interrupt.
286 #if defined(__ICCARM__)
290 // Wait for the next interrupt.
295 #if defined(__CC_ARM)
296 __asm void CPU_wfi(void)
299 // Wait for the next interrupt.
305 #if defined(__TI_ARM__)
309 // Wait for the next interrupt.
315 //*****************************************************************************
317 // Wrapper function for writing the BASEPRI register.
319 //*****************************************************************************
320 #if defined(__GNUC__)
321 void __attribute__((naked)) CPU_basepriSet(uint32_t newBasepri)
324 // Set the BASEPRI register
326 __asm(" msr BASEPRI, r0\n"
330 #if defined(__ICCARM__)
331 void CPU_basepriSet(uint32_t newBasepri)
334 // Set the BASEPRI register
336 __asm(" msr BASEPRI, r0\n");
339 #if defined(__CC_ARM)
340 __asm void CPU_basepriSet(uint32_t newBasepri)
343 // Set the BASEPRI register
349 #if defined(__TI_ARM__)
350 void CPU_basepriSet(uint32_t newBasepri)
353 // Set the BASEPRI register
355 __asm(" msr BASEPRI, r0\n");
359 //*****************************************************************************
361 // Wrapper function for reading the BASEPRI register.
363 //*****************************************************************************
364 #if defined(__GNUC__)
365 uint32_t __attribute__((naked)) CPU_basepriGet(void)
372 __asm(" mrs r0, BASEPRI\n"
377 // The return is handled in the inline assembly, but the compiler will
378 // still complain if there is not an explicit return here (despite the fact
379 // that this does not result in any code being produced because of the
385 #if defined(__ICCARM__)
386 uint32_t CPU_basepriGet(void)
391 __asm(" mrs r0, BASEPRI\n");
394 // "Warning[Pe940]: missing return statement at end of non-void function"
395 // is suppressed here to avoid putting a "bx lr" in the inline assembly
396 // above and a superfluous return statement here.
398 #pragma diag_suppress=Pe940
400 #pragma diag_default=Pe940
402 #if defined(__CC_ARM)
403 __asm uint32_t CPU_basepriGet(void)
412 #if defined(__TI_ARM__)
413 uint32_t CPU_basepriGet(void)
418 __asm(" mrs r0, BASEPRI\n"
422 // The following keeps the compiler happy, because it wants to see a
423 // return value from this function. It will generate code to return
424 // a zero. However, the real return is the "bx lr" above, so the
425 // return(0) is never executed and the function returns with the value