2 * -------------------------------------------
3 * CC3220 SDK - v0.10.00.00
4 * -------------------------------------------
6 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
20 * Neither the name of Texas Instruments Incorporated nor the names of
21 * its contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //*****************************************************************************
41 // Instruction wrappers for special CPU instructions needed by the
44 //*****************************************************************************
47 //*****************************************************************************
49 // Wrapper function for the CPSID instruction. Returns the state of PRIMASK
52 //*****************************************************************************
54 unsigned long __attribute__((naked))
60 // Read PRIMASK and disable interrupts.
62 __asm(" mrs r0, PRIMASK\n"
70 // The return is handled in the inline assembly, but the compiler will
71 // still complain if there is not an explicit return here (despite the fact
72 // that this does not result in any code being produced because of the
83 // Read PRIMASK and disable interrupts.
85 __asm(" mrs r0, PRIMASK\n"
91 // "Warning[Pe940]: missing return statement at end of non-void function"
92 // is suppressed here to avoid putting a "bx lr" in the inline assembly
93 // above and a superfluous return statement here.
95 #pragma diag_suppress=Pe940
97 #pragma diag_default=Pe940
104 // Read PRIMASK and disable interrupts.
106 __asm(" mrs r0, PRIMASK\n"
113 // The following keeps the compiler happy, because it wants to see a
114 // return value from this function. It will generate code to return
115 // a zero. However, the real return is the "bx lr" above, so the
116 // return(0) is never executed and the function returns with the value
123 //*****************************************************************************
125 // Wrapper function returning the state of PRIMASK (indicating whether
126 // interrupts are enabled or disabled).
128 //*****************************************************************************
130 unsigned long __attribute__((naked))
136 // Read PRIMASK and disable interrupts.
138 __asm(" mrs r0, PRIMASK\n"
143 // The return is handled in the inline assembly, but the compiler will
144 // still complain if there is not an explicit return here (despite the fact
145 // that this does not result in any code being produced because of the
156 // Read PRIMASK and disable interrupts.
158 __asm(" mrs r0, PRIMASK\n");
161 // "Warning[Pe940]: missing return statement at end of non-void function"
162 // is suppressed here to avoid putting a "bx lr" in the inline assembly
163 // above and a superfluous return statement here.
165 #pragma diag_suppress=Pe940
167 #pragma diag_default=Pe940
174 // Read PRIMASK and disable interrupts.
176 __asm(" mrs r0, PRIMASK\n"
180 // The following keeps the compiler happy, because it wants to see a
181 // return value from this function. It will generate code to return
182 // a zero. However, the real return is the "bx lr" above, so the
183 // return(0) is never executed and the function returns with the value
190 //*****************************************************************************
192 // Wrapper function for the CPSIE instruction. Returns the state of PRIMASK
195 //*****************************************************************************
197 unsigned long __attribute__((naked))
203 // Read PRIMASK and enable interrupts.
205 __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
226 // Read PRIMASK and enable interrupts.
228 __asm(" mrs r0, PRIMASK\n"
234 // "Warning[Pe940]: missing return statement at end of non-void function"
235 // is suppressed here to avoid putting a "bx lr" in the inline assembly
236 // above and a superfluous return statement here.
238 #pragma diag_suppress=Pe940
240 #pragma diag_default=Pe940
247 // Read PRIMASK and enable interrupts.
249 __asm(" mrs r0, PRIMASK\n"
256 // The following keeps the compiler happy, because it wants to see a
257 // return value from this function. It will generate code to return
258 // a zero. However, the real return is the "bx lr" above, so the
259 // return(0) is never executed and the function returns with the value
266 //*****************************************************************************
268 // Wrapper function for the WFI instruction.
270 //*****************************************************************************
272 void __attribute__((naked))
276 // Wait for the next interrupt.
289 // Wait for the next interrupt.
301 // Wait for the next interrupt.
309 //*****************************************************************************
311 // Wrapper function for writing the BASEPRI register.
313 //*****************************************************************************
315 void __attribute__((naked))
316 CPUbasepriSet(unsigned long ulNewBasepri)
320 // Set the BASEPRI register
322 __asm(" msr BASEPRI, r0\n"
330 CPUbasepriSet(unsigned long ulNewBasepri)
333 // Set the BASEPRI register
335 __asm(" msr BASEPRI, r0\n"
342 CPUbasepriSet(unsigned long ulNewBasepri)
345 // Set the BASEPRI register
347 __asm(" msr BASEPRI, r0\n"
353 //*****************************************************************************
355 // Wrapper function for reading the BASEPRI register.
357 //*****************************************************************************
359 unsigned long __attribute__((naked))
367 __asm(" mrs r0, BASEPRI\n"
372 // The return is handled in the inline assembly, but the compiler will
373 // still complain if there is not an explicit return here (despite the fact
374 // that this does not result in any code being produced because of the
387 __asm(" mrs r0, BASEPRI\n");
390 // "Warning[Pe940]: missing return statement at end of non-void function"
391 // is suppressed here to avoid putting a "bx lr" in the inline assembly
392 // above and a superfluous return statement here.
394 #pragma diag_suppress=Pe940
396 #pragma diag_default=Pe940
405 __asm(" mrs r0, BASEPRI\n"
409 // The following keeps the compiler happy, because it wants to see a
410 // return value from this function. It will generate code to return
411 // a zero. However, the real return is the "bx lr" above, so the
412 // return(0) is never executed and the function returns with the value