1 /**************************************************************************//**
\r
3 * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Source File
\r
5 * @date 18. February 2010
\r
8 * Copyright (C) 2009-2010 ARM Limited. All rights reserved.
\r
11 * ARM Limited (ARM) is supplying this software for use with Cortex-M
\r
12 * processor based microcontrollers. This file can be freely distributed
\r
13 * within development tools that are supporting such ARM based processors.
\r
16 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
17 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
19 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
20 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
22 ******************************************************************************/
\r
26 /* define compiler specific symbols */
\r
27 #if defined ( __CC_ARM )
\r
28 #define __ASM __asm /*!< asm keyword for ARM Compiler */
\r
29 #define __INLINE __inline /*!< inline keyword for ARM Compiler */
\r
31 #elif defined ( __ICCARM__ )
\r
32 #define __ASM __asm /*!< asm keyword for IAR Compiler */
\r
33 #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
\r
35 #elif defined ( __GNUC__ )
\r
36 #define __ASM __asm /*!< asm keyword for GNU Compiler */
\r
37 #define __INLINE inline /*!< inline keyword for GNU Compiler */
\r
39 #elif defined ( __TASKING__ )
\r
40 #define __ASM __asm /*!< asm keyword for TASKING Compiler */
\r
41 #define __INLINE inline /*!< inline keyword for TASKING Compiler */
\r
46 /* ########################## Core Instruction Access ######################### */
\r
48 #if defined ( __CC_ARM ) /*------------------ RealView Compiler ----------------*/
\r
51 * @brief Reverse byte order (16 bit)
\r
53 * @param value value to reverse
\r
54 * @return reversed value
\r
56 * Reverse byte order in unsigned short value
\r
58 #if (__ARMCC_VERSION < 400677)
\r
59 __ASM uint32_t __REV16(uint16_t value)
\r
64 #endif /* __ARMCC_VERSION */
\r
67 * @brief Reverse byte order in signed short value with sign extension to integer
\r
69 * @param value value to reverse
\r
70 * @return reversed value
\r
72 * Reverse byte order in signed short value with sign extension to integer
\r
74 #if (__ARMCC_VERSION < 400677)
\r
75 __ASM int32_t __REVSH(int16_t value)
\r
80 #endif /* __ARMCC_VERSION */
\r
83 * @brief Remove the exclusive lock created by ldrex
\r
85 * Removes the exclusive lock which is created by ldrex.
\r
87 #if (__ARMCC_VERSION < 400000)
\r
88 __ASM void __CLREX(void)
\r
92 #endif /* __ARMCC_VERSION */
\r
95 #elif (defined (__ICCARM__)) /*---------------- ICC Compiler ---------------------*/
\r
97 #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
\r
99 #elif (defined (__TASKING__)) /*--------------- TASKING Compiler -----------------*/
\r
104 /* ########################### Core Function Access ########################### */
\r
106 #if defined ( __CC_ARM ) /*------------------ RealView Compiler ----------------*/
\r
109 * @brief Return the Control Register value
\r
111 * @return Control value
\r
113 * Return the content of the control register
\r
115 #if (__ARMCC_VERSION < 400000)
\r
116 __ASM uint32_t __get_CONTROL(void)
\r
121 #endif /* __ARMCC_VERSION */
\r
124 * @brief Set the Control Register value
\r
126 * @param control Control value
\r
128 * Set the control register
\r
130 #if (__ARMCC_VERSION < 400000)
\r
131 __ASM void __set_CONTROL(uint32_t control)
\r
136 #endif /* __ARMCC_VERSION */
\r
139 * @brief Get IPSR Register value
\r
141 * @return uint32_t IPSR value
\r
143 * return the content of the IPSR register
\r
145 #if (__ARMCC_VERSION < 400000)
\r
146 __ASM uint32_t __get_IPSR(void)
\r
151 #endif /* __ARMCC_VERSION */
\r
154 * @brief Get APSR Register value
\r
156 * @return uint32_t APSR value
\r
158 * return the content of the APSR register
\r
160 #if (__ARMCC_VERSION < 400000)
\r
161 __ASM uint32_t __get_APSR(void)
\r
166 #endif /* __ARMCC_VERSION */
\r
169 * @brief Get xPSR Register value
\r
171 * @return uint32_t xPSR value
\r
173 * return the content of the xPSR register
\r
175 #if (__ARMCC_VERSION < 400000)
\r
176 __ASM uint32_t __get_xPSR(void)
\r
181 #endif /* __ARMCC_VERSION */
\r
184 * @brief Return the Process Stack Pointer
\r
186 * @return ProcessStackPointer
\r
188 * Return the actual process stack pointer
\r
190 #if (__ARMCC_VERSION < 400000)
\r
191 __ASM uint32_t __get_PSP(void)
\r
196 #endif /* __ARMCC_VERSION */
\r
199 * @brief Set the Process Stack Pointer
\r
201 * @param topOfProcStack Process Stack Pointer
\r
203 * Assign the value ProcessStackPointer to the MSP
\r
204 * (process stack pointer) Cortex processor register
\r
206 #if (__ARMCC_VERSION < 400000)
\r
207 __ASM void __set_PSP(uint32_t topOfProcStack)
\r
212 #endif /* __ARMCC_VERSION */
\r
215 * @brief Return the Main Stack Pointer
\r
217 * @return Main Stack Pointer
\r
219 * Return the current value of the MSP (main stack pointer)
\r
220 * Cortex processor register
\r
222 #if (__ARMCC_VERSION < 400000)
\r
223 __ASM uint32_t __get_MSP(void)
\r
228 #endif /* __ARMCC_VERSION */
\r
231 * @brief Set the Main Stack Pointer
\r
233 * @param topOfMainStack Main Stack Pointer
\r
235 * Assign the value mainStackPointer to the MSP
\r
236 * (main stack pointer) Cortex processor register
\r
238 #if (__ARMCC_VERSION < 400000)
\r
239 __ASM void __set_MSP(uint32_t mainStackPointer)
\r
244 #endif /* __ARMCC_VERSION */
\r
247 * @brief Return the Base Priority value
\r
249 * @return BasePriority
\r
251 * Return the content of the base priority register
\r
253 #if (__ARMCC_VERSION < 400000)
\r
254 __ASM uint32_t __get_BASEPRI(void)
\r
259 #endif /* __ARMCC_VERSION */
\r
262 * @brief Set the Base Priority value
\r
264 * @param basePri BasePriority
\r
266 * Set the base priority register
\r
268 #if (__ARMCC_VERSION < 400000)
\r
269 __ASM void __set_BASEPRI(uint32_t basePri)
\r
274 #endif /* __ARMCC_VERSION */
\r
277 * @brief Return the Priority Mask value
\r
281 * Return state of the priority mask bit from the priority mask register
\r
283 #if (__ARMCC_VERSION < 400000)
\r
284 __ASM uint32_t __get_PRIMASK(void)
\r
289 #endif /* __ARMCC_VERSION */
\r
292 * @brief Set the Priority Mask value
\r
294 * @param priMask PriMask
\r
296 * Set the priority mask bit in the priority mask register
\r
298 #if (__ARMCC_VERSION < 400000)
\r
299 __ASM void __set_PRIMASK(uint32_t priMask)
\r
304 #endif /* __ARMCC_VERSION */
\r
307 * @brief Return the Fault Mask value
\r
309 * @return FaultMask
\r
311 * Return the content of the fault mask register
\r
313 #if (__ARMCC_VERSION < 400000)
\r
314 __ASM uint32_t __get_FAULTMASK(void)
\r
319 #endif /* __ARMCC_VERSION */
\r
322 * @brief Set the Fault Mask value
\r
324 * @param faultMask faultMask value
\r
326 * Set the fault mask register
\r
328 #if (__ARMCC_VERSION < 400000)
\r
329 __ASM void __set_FAULTMASK(uint32_t faultMask)
\r
334 #endif /* __ARMCC_VERSION */
\r
337 * @brief Return the FPSCR value
\r
339 * @return FloatingPointStatusControlRegister
\r
341 * Return the content of the FPSCR register
\r
345 * @brief Set the FPSCR value
\r
347 * @param fpscr FloatingPointStatusControlRegister
\r
349 * Set the FPSCR register
\r
353 #elif (defined (__ICCARM__)) /*---------------- ICC Compiler ---------------------*/
\r
355 #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
\r
357 #elif (defined (__TASKING__)) /*--------------- TASKING Compiler -----------------*/
\r