...

Dependents:   2doejemplo Labo_TRSE_Drone

Fork of mbed by mbed official

Committer:
jalp89
Date:
Fri Nov 29 09:39:46 2013 +0000
Revision:
71:7ec3cb6bbcc4
Parent:
70:673126e12c73
...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 70:673126e12c73 1 /**************************************************************************//**
bogdanm 70:673126e12c73 2 * @file core_cmFunc.h
bogdanm 70:673126e12c73 3 * @brief CMSIS Cortex-M Core Function Access Header File
bogdanm 70:673126e12c73 4 * @version V3.20
bogdanm 70:673126e12c73 5 * @date 25. February 2013
bogdanm 70:673126e12c73 6 *
bogdanm 70:673126e12c73 7 * @note
bogdanm 70:673126e12c73 8 *
bogdanm 70:673126e12c73 9 ******************************************************************************/
bogdanm 70:673126e12c73 10 /* Copyright (c) 2009 - 2013 ARM LIMITED
bogdanm 70:673126e12c73 11
bogdanm 70:673126e12c73 12 All rights reserved.
bogdanm 70:673126e12c73 13 Redistribution and use in source and binary forms, with or without
bogdanm 70:673126e12c73 14 modification, are permitted provided that the following conditions are met:
bogdanm 70:673126e12c73 15 - Redistributions of source code must retain the above copyright
bogdanm 70:673126e12c73 16 notice, this list of conditions and the following disclaimer.
bogdanm 70:673126e12c73 17 - Redistributions in binary form must reproduce the above copyright
bogdanm 70:673126e12c73 18 notice, this list of conditions and the following disclaimer in the
bogdanm 70:673126e12c73 19 documentation and/or other materials provided with the distribution.
bogdanm 70:673126e12c73 20 - Neither the name of ARM nor the names of its contributors may be used
bogdanm 70:673126e12c73 21 to endorse or promote products derived from this software without
bogdanm 70:673126e12c73 22 specific prior written permission.
bogdanm 70:673126e12c73 23 *
bogdanm 70:673126e12c73 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 70:673126e12c73 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 70:673126e12c73 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
bogdanm 70:673126e12c73 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
bogdanm 70:673126e12c73 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
bogdanm 70:673126e12c73 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
bogdanm 70:673126e12c73 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
bogdanm 70:673126e12c73 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
bogdanm 70:673126e12c73 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
bogdanm 70:673126e12c73 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
bogdanm 70:673126e12c73 34 POSSIBILITY OF SUCH DAMAGE.
bogdanm 70:673126e12c73 35 ---------------------------------------------------------------------------*/
bogdanm 70:673126e12c73 36
bogdanm 70:673126e12c73 37
bogdanm 70:673126e12c73 38 #ifndef __CORE_CMFUNC_H
bogdanm 70:673126e12c73 39 #define __CORE_CMFUNC_H
bogdanm 70:673126e12c73 40
bogdanm 70:673126e12c73 41
bogdanm 70:673126e12c73 42 /* ########################### Core Function Access ########################### */
bogdanm 70:673126e12c73 43 /** \ingroup CMSIS_Core_FunctionInterface
bogdanm 70:673126e12c73 44 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
bogdanm 70:673126e12c73 45 @{
bogdanm 70:673126e12c73 46 */
bogdanm 70:673126e12c73 47
bogdanm 70:673126e12c73 48 #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
bogdanm 70:673126e12c73 49 /* ARM armcc specific functions */
bogdanm 70:673126e12c73 50
bogdanm 70:673126e12c73 51 #if (__ARMCC_VERSION < 400677)
bogdanm 70:673126e12c73 52 #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
bogdanm 70:673126e12c73 53 #endif
bogdanm 70:673126e12c73 54
bogdanm 70:673126e12c73 55 /* intrinsic void __enable_irq(); */
bogdanm 70:673126e12c73 56 /* intrinsic void __disable_irq(); */
bogdanm 70:673126e12c73 57
bogdanm 70:673126e12c73 58 /** \brief Get Control Register
bogdanm 70:673126e12c73 59
bogdanm 70:673126e12c73 60 This function returns the content of the Control Register.
bogdanm 70:673126e12c73 61
bogdanm 70:673126e12c73 62 \return Control Register value
bogdanm 70:673126e12c73 63 */
bogdanm 70:673126e12c73 64 __STATIC_INLINE uint32_t __get_CONTROL(void)
bogdanm 70:673126e12c73 65 {
bogdanm 70:673126e12c73 66 register uint32_t __regControl __ASM("control");
bogdanm 70:673126e12c73 67 return(__regControl);
bogdanm 70:673126e12c73 68 }
bogdanm 70:673126e12c73 69
bogdanm 70:673126e12c73 70
bogdanm 70:673126e12c73 71 /** \brief Set Control Register
bogdanm 70:673126e12c73 72
bogdanm 70:673126e12c73 73 This function writes the given value to the Control Register.
bogdanm 70:673126e12c73 74
bogdanm 70:673126e12c73 75 \param [in] control Control Register value to set
bogdanm 70:673126e12c73 76 */
bogdanm 70:673126e12c73 77 __STATIC_INLINE void __set_CONTROL(uint32_t control)
bogdanm 70:673126e12c73 78 {
bogdanm 70:673126e12c73 79 register uint32_t __regControl __ASM("control");
bogdanm 70:673126e12c73 80 __regControl = control;
bogdanm 70:673126e12c73 81 }
bogdanm 70:673126e12c73 82
bogdanm 70:673126e12c73 83
bogdanm 70:673126e12c73 84 /** \brief Get IPSR Register
bogdanm 70:673126e12c73 85
bogdanm 70:673126e12c73 86 This function returns the content of the IPSR Register.
bogdanm 70:673126e12c73 87
bogdanm 70:673126e12c73 88 \return IPSR Register value
bogdanm 70:673126e12c73 89 */
bogdanm 70:673126e12c73 90 __STATIC_INLINE uint32_t __get_IPSR(void)
bogdanm 70:673126e12c73 91 {
bogdanm 70:673126e12c73 92 register uint32_t __regIPSR __ASM("ipsr");
bogdanm 70:673126e12c73 93 return(__regIPSR);
bogdanm 70:673126e12c73 94 }
bogdanm 70:673126e12c73 95
bogdanm 70:673126e12c73 96
bogdanm 70:673126e12c73 97 /** \brief Get APSR Register
bogdanm 70:673126e12c73 98
bogdanm 70:673126e12c73 99 This function returns the content of the APSR Register.
bogdanm 70:673126e12c73 100
bogdanm 70:673126e12c73 101 \return APSR Register value
bogdanm 70:673126e12c73 102 */
bogdanm 70:673126e12c73 103 __STATIC_INLINE uint32_t __get_APSR(void)
bogdanm 70:673126e12c73 104 {
bogdanm 70:673126e12c73 105 register uint32_t __regAPSR __ASM("apsr");
bogdanm 70:673126e12c73 106 return(__regAPSR);
bogdanm 70:673126e12c73 107 }
bogdanm 70:673126e12c73 108
bogdanm 70:673126e12c73 109
bogdanm 70:673126e12c73 110 /** \brief Get xPSR Register
bogdanm 70:673126e12c73 111
bogdanm 70:673126e12c73 112 This function returns the content of the xPSR Register.
bogdanm 70:673126e12c73 113
bogdanm 70:673126e12c73 114 \return xPSR Register value
bogdanm 70:673126e12c73 115 */
bogdanm 70:673126e12c73 116 __STATIC_INLINE uint32_t __get_xPSR(void)
bogdanm 70:673126e12c73 117 {
bogdanm 70:673126e12c73 118 register uint32_t __regXPSR __ASM("xpsr");
bogdanm 70:673126e12c73 119 return(__regXPSR);
bogdanm 70:673126e12c73 120 }
bogdanm 70:673126e12c73 121
bogdanm 70:673126e12c73 122
bogdanm 70:673126e12c73 123 /** \brief Get Process Stack Pointer
bogdanm 70:673126e12c73 124
bogdanm 70:673126e12c73 125 This function returns the current value of the Process Stack Pointer (PSP).
bogdanm 70:673126e12c73 126
bogdanm 70:673126e12c73 127 \return PSP Register value
bogdanm 70:673126e12c73 128 */
bogdanm 70:673126e12c73 129 __STATIC_INLINE uint32_t __get_PSP(void)
bogdanm 70:673126e12c73 130 {
bogdanm 70:673126e12c73 131 register uint32_t __regProcessStackPointer __ASM("psp");
bogdanm 70:673126e12c73 132 return(__regProcessStackPointer);
bogdanm 70:673126e12c73 133 }
bogdanm 70:673126e12c73 134
bogdanm 70:673126e12c73 135
bogdanm 70:673126e12c73 136 /** \brief Set Process Stack Pointer
bogdanm 70:673126e12c73 137
bogdanm 70:673126e12c73 138 This function assigns the given value to the Process Stack Pointer (PSP).
bogdanm 70:673126e12c73 139
bogdanm 70:673126e12c73 140 \param [in] topOfProcStack Process Stack Pointer value to set
bogdanm 70:673126e12c73 141 */
bogdanm 70:673126e12c73 142 __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
bogdanm 70:673126e12c73 143 {
bogdanm 70:673126e12c73 144 register uint32_t __regProcessStackPointer __ASM("psp");
bogdanm 70:673126e12c73 145 __regProcessStackPointer = topOfProcStack;
bogdanm 70:673126e12c73 146 }
bogdanm 70:673126e12c73 147
bogdanm 70:673126e12c73 148
bogdanm 70:673126e12c73 149 /** \brief Get Main Stack Pointer
bogdanm 70:673126e12c73 150
bogdanm 70:673126e12c73 151 This function returns the current value of the Main Stack Pointer (MSP).
bogdanm 70:673126e12c73 152
bogdanm 70:673126e12c73 153 \return MSP Register value
bogdanm 70:673126e12c73 154 */
bogdanm 70:673126e12c73 155 __STATIC_INLINE uint32_t __get_MSP(void)
bogdanm 70:673126e12c73 156 {
bogdanm 70:673126e12c73 157 register uint32_t __regMainStackPointer __ASM("msp");
bogdanm 70:673126e12c73 158 return(__regMainStackPointer);
bogdanm 70:673126e12c73 159 }
bogdanm 70:673126e12c73 160
bogdanm 70:673126e12c73 161
bogdanm 70:673126e12c73 162 /** \brief Set Main Stack Pointer
bogdanm 70:673126e12c73 163
bogdanm 70:673126e12c73 164 This function assigns the given value to the Main Stack Pointer (MSP).
bogdanm 70:673126e12c73 165
bogdanm 70:673126e12c73 166 \param [in] topOfMainStack Main Stack Pointer value to set
bogdanm 70:673126e12c73 167 */
bogdanm 70:673126e12c73 168 __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
bogdanm 70:673126e12c73 169 {
bogdanm 70:673126e12c73 170 register uint32_t __regMainStackPointer __ASM("msp");
bogdanm 70:673126e12c73 171 __regMainStackPointer = topOfMainStack;
bogdanm 70:673126e12c73 172 }
bogdanm 70:673126e12c73 173
bogdanm 70:673126e12c73 174
bogdanm 70:673126e12c73 175 /** \brief Get Priority Mask
bogdanm 70:673126e12c73 176
bogdanm 70:673126e12c73 177 This function returns the current state of the priority mask bit from the Priority Mask Register.
bogdanm 70:673126e12c73 178
bogdanm 70:673126e12c73 179 \return Priority Mask value
bogdanm 70:673126e12c73 180 */
bogdanm 70:673126e12c73 181 __STATIC_INLINE uint32_t __get_PRIMASK(void)
bogdanm 70:673126e12c73 182 {
bogdanm 70:673126e12c73 183 register uint32_t __regPriMask __ASM("primask");
bogdanm 70:673126e12c73 184 return(__regPriMask);
bogdanm 70:673126e12c73 185 }
bogdanm 70:673126e12c73 186
bogdanm 70:673126e12c73 187
bogdanm 70:673126e12c73 188 /** \brief Set Priority Mask
bogdanm 70:673126e12c73 189
bogdanm 70:673126e12c73 190 This function assigns the given value to the Priority Mask Register.
bogdanm 70:673126e12c73 191
bogdanm 70:673126e12c73 192 \param [in] priMask Priority Mask
bogdanm 70:673126e12c73 193 */
bogdanm 70:673126e12c73 194 __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
bogdanm 70:673126e12c73 195 {
bogdanm 70:673126e12c73 196 register uint32_t __regPriMask __ASM("primask");
bogdanm 70:673126e12c73 197 __regPriMask = (priMask);
bogdanm 70:673126e12c73 198 }
bogdanm 70:673126e12c73 199
bogdanm 70:673126e12c73 200
bogdanm 70:673126e12c73 201 #if (__CORTEX_M >= 0x03)
bogdanm 70:673126e12c73 202
bogdanm 70:673126e12c73 203 /** \brief Enable FIQ
bogdanm 70:673126e12c73 204
bogdanm 70:673126e12c73 205 This function enables FIQ interrupts by clearing the F-bit in the CPSR.
bogdanm 70:673126e12c73 206 Can only be executed in Privileged modes.
bogdanm 70:673126e12c73 207 */
bogdanm 70:673126e12c73 208 #define __enable_fault_irq __enable_fiq
bogdanm 70:673126e12c73 209
bogdanm 70:673126e12c73 210
bogdanm 70:673126e12c73 211 /** \brief Disable FIQ
bogdanm 70:673126e12c73 212
bogdanm 70:673126e12c73 213 This function disables FIQ interrupts by setting the F-bit in the CPSR.
bogdanm 70:673126e12c73 214 Can only be executed in Privileged modes.
bogdanm 70:673126e12c73 215 */
bogdanm 70:673126e12c73 216 #define __disable_fault_irq __disable_fiq
bogdanm 70:673126e12c73 217
bogdanm 70:673126e12c73 218
bogdanm 70:673126e12c73 219 /** \brief Get Base Priority
bogdanm 70:673126e12c73 220
bogdanm 70:673126e12c73 221 This function returns the current value of the Base Priority register.
bogdanm 70:673126e12c73 222
bogdanm 70:673126e12c73 223 \return Base Priority register value
bogdanm 70:673126e12c73 224 */
bogdanm 70:673126e12c73 225 __STATIC_INLINE uint32_t __get_BASEPRI(void)
bogdanm 70:673126e12c73 226 {
bogdanm 70:673126e12c73 227 register uint32_t __regBasePri __ASM("basepri");
bogdanm 70:673126e12c73 228 return(__regBasePri);
bogdanm 70:673126e12c73 229 }
bogdanm 70:673126e12c73 230
bogdanm 70:673126e12c73 231
bogdanm 70:673126e12c73 232 /** \brief Set Base Priority
bogdanm 70:673126e12c73 233
bogdanm 70:673126e12c73 234 This function assigns the given value to the Base Priority register.
bogdanm 70:673126e12c73 235
bogdanm 70:673126e12c73 236 \param [in] basePri Base Priority value to set
bogdanm 70:673126e12c73 237 */
bogdanm 70:673126e12c73 238 __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
bogdanm 70:673126e12c73 239 {
bogdanm 70:673126e12c73 240 register uint32_t __regBasePri __ASM("basepri");
bogdanm 70:673126e12c73 241 __regBasePri = (basePri & 0xff);
bogdanm 70:673126e12c73 242 }
bogdanm 70:673126e12c73 243
bogdanm 70:673126e12c73 244
bogdanm 70:673126e12c73 245 /** \brief Get Fault Mask
bogdanm 70:673126e12c73 246
bogdanm 70:673126e12c73 247 This function returns the current value of the Fault Mask register.
bogdanm 70:673126e12c73 248
bogdanm 70:673126e12c73 249 \return Fault Mask register value
bogdanm 70:673126e12c73 250 */
bogdanm 70:673126e12c73 251 __STATIC_INLINE uint32_t __get_FAULTMASK(void)
bogdanm 70:673126e12c73 252 {
bogdanm 70:673126e12c73 253 register uint32_t __regFaultMask __ASM("faultmask");
bogdanm 70:673126e12c73 254 return(__regFaultMask);
bogdanm 70:673126e12c73 255 }
bogdanm 70:673126e12c73 256
bogdanm 70:673126e12c73 257
bogdanm 70:673126e12c73 258 /** \brief Set Fault Mask
bogdanm 70:673126e12c73 259
bogdanm 70:673126e12c73 260 This function assigns the given value to the Fault Mask register.
bogdanm 70:673126e12c73 261
bogdanm 70:673126e12c73 262 \param [in] faultMask Fault Mask value to set
bogdanm 70:673126e12c73 263 */
bogdanm 70:673126e12c73 264 __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
bogdanm 70:673126e12c73 265 {
bogdanm 70:673126e12c73 266 register uint32_t __regFaultMask __ASM("faultmask");
bogdanm 70:673126e12c73 267 __regFaultMask = (faultMask & (uint32_t)1);
bogdanm 70:673126e12c73 268 }
bogdanm 70:673126e12c73 269
bogdanm 70:673126e12c73 270 #endif /* (__CORTEX_M >= 0x03) */
bogdanm 70:673126e12c73 271
bogdanm 70:673126e12c73 272
bogdanm 70:673126e12c73 273 #if (__CORTEX_M == 0x04)
bogdanm 70:673126e12c73 274
bogdanm 70:673126e12c73 275 /** \brief Get FPSCR
bogdanm 70:673126e12c73 276
bogdanm 70:673126e12c73 277 This function returns the current value of the Floating Point Status/Control register.
bogdanm 70:673126e12c73 278
bogdanm 70:673126e12c73 279 \return Floating Point Status/Control register value
bogdanm 70:673126e12c73 280 */
bogdanm 70:673126e12c73 281 __STATIC_INLINE uint32_t __get_FPSCR(void)
bogdanm 70:673126e12c73 282 {
bogdanm 70:673126e12c73 283 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
bogdanm 70:673126e12c73 284 register uint32_t __regfpscr __ASM("fpscr");
bogdanm 70:673126e12c73 285 return(__regfpscr);
bogdanm 70:673126e12c73 286 #else
bogdanm 70:673126e12c73 287 return(0);
bogdanm 70:673126e12c73 288 #endif
bogdanm 70:673126e12c73 289 }
bogdanm 70:673126e12c73 290
bogdanm 70:673126e12c73 291
bogdanm 70:673126e12c73 292 /** \brief Set FPSCR
bogdanm 70:673126e12c73 293
bogdanm 70:673126e12c73 294 This function assigns the given value to the Floating Point Status/Control register.
bogdanm 70:673126e12c73 295
bogdanm 70:673126e12c73 296 \param [in] fpscr Floating Point Status/Control value to set
bogdanm 70:673126e12c73 297 */
bogdanm 70:673126e12c73 298 __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
bogdanm 70:673126e12c73 299 {
bogdanm 70:673126e12c73 300 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
bogdanm 70:673126e12c73 301 register uint32_t __regfpscr __ASM("fpscr");
bogdanm 70:673126e12c73 302 __regfpscr = (fpscr);
bogdanm 70:673126e12c73 303 #endif
bogdanm 70:673126e12c73 304 }
bogdanm 70:673126e12c73 305
bogdanm 70:673126e12c73 306 #endif /* (__CORTEX_M == 0x04) */
bogdanm 70:673126e12c73 307
bogdanm 70:673126e12c73 308
bogdanm 70:673126e12c73 309 #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
bogdanm 70:673126e12c73 310 /* IAR iccarm specific functions */
bogdanm 70:673126e12c73 311
bogdanm 70:673126e12c73 312 #include <cmsis_iar.h>
bogdanm 70:673126e12c73 313
bogdanm 70:673126e12c73 314
bogdanm 70:673126e12c73 315 #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
bogdanm 70:673126e12c73 316 /* TI CCS specific functions */
bogdanm 70:673126e12c73 317
bogdanm 70:673126e12c73 318 #include <cmsis_ccs.h>
bogdanm 70:673126e12c73 319
bogdanm 70:673126e12c73 320
bogdanm 70:673126e12c73 321 #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
bogdanm 70:673126e12c73 322 /* GNU gcc specific functions */
bogdanm 70:673126e12c73 323
bogdanm 70:673126e12c73 324 /** \brief Enable IRQ Interrupts
bogdanm 70:673126e12c73 325
bogdanm 70:673126e12c73 326 This function enables IRQ interrupts by clearing the I-bit in the CPSR.
bogdanm 70:673126e12c73 327 Can only be executed in Privileged modes.
bogdanm 70:673126e12c73 328 */
bogdanm 70:673126e12c73 329 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
bogdanm 70:673126e12c73 330 {
bogdanm 70:673126e12c73 331 __ASM volatile ("cpsie i" : : : "memory");
bogdanm 70:673126e12c73 332 }
bogdanm 70:673126e12c73 333
bogdanm 70:673126e12c73 334
bogdanm 70:673126e12c73 335 /** \brief Disable IRQ Interrupts
bogdanm 70:673126e12c73 336
bogdanm 70:673126e12c73 337 This function disables IRQ interrupts by setting the I-bit in the CPSR.
bogdanm 70:673126e12c73 338 Can only be executed in Privileged modes.
bogdanm 70:673126e12c73 339 */
bogdanm 70:673126e12c73 340 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
bogdanm 70:673126e12c73 341 {
bogdanm 70:673126e12c73 342 __ASM volatile ("cpsid i" : : : "memory");
bogdanm 70:673126e12c73 343 }
bogdanm 70:673126e12c73 344
bogdanm 70:673126e12c73 345
bogdanm 70:673126e12c73 346 /** \brief Get Control Register
bogdanm 70:673126e12c73 347
bogdanm 70:673126e12c73 348 This function returns the content of the Control Register.
bogdanm 70:673126e12c73 349
bogdanm 70:673126e12c73 350 \return Control Register value
bogdanm 70:673126e12c73 351 */
bogdanm 70:673126e12c73 352 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
bogdanm 70:673126e12c73 353 {
bogdanm 70:673126e12c73 354 uint32_t result;
bogdanm 70:673126e12c73 355
bogdanm 70:673126e12c73 356 __ASM volatile ("MRS %0, control" : "=r" (result) );
bogdanm 70:673126e12c73 357 return(result);
bogdanm 70:673126e12c73 358 }
bogdanm 70:673126e12c73 359
bogdanm 70:673126e12c73 360
bogdanm 70:673126e12c73 361 /** \brief Set Control Register
bogdanm 70:673126e12c73 362
bogdanm 70:673126e12c73 363 This function writes the given value to the Control Register.
bogdanm 70:673126e12c73 364
bogdanm 70:673126e12c73 365 \param [in] control Control Register value to set
bogdanm 70:673126e12c73 366 */
bogdanm 70:673126e12c73 367 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
bogdanm 70:673126e12c73 368 {
bogdanm 70:673126e12c73 369 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
bogdanm 70:673126e12c73 370 }
bogdanm 70:673126e12c73 371
bogdanm 70:673126e12c73 372
bogdanm 70:673126e12c73 373 /** \brief Get IPSR Register
bogdanm 70:673126e12c73 374
bogdanm 70:673126e12c73 375 This function returns the content of the IPSR Register.
bogdanm 70:673126e12c73 376
bogdanm 70:673126e12c73 377 \return IPSR Register value
bogdanm 70:673126e12c73 378 */
bogdanm 70:673126e12c73 379 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
bogdanm 70:673126e12c73 380 {
bogdanm 70:673126e12c73 381 uint32_t result;
bogdanm 70:673126e12c73 382
bogdanm 70:673126e12c73 383 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
bogdanm 70:673126e12c73 384 return(result);
bogdanm 70:673126e12c73 385 }
bogdanm 70:673126e12c73 386
bogdanm 70:673126e12c73 387
bogdanm 70:673126e12c73 388 /** \brief Get APSR Register
bogdanm 70:673126e12c73 389
bogdanm 70:673126e12c73 390 This function returns the content of the APSR Register.
bogdanm 70:673126e12c73 391
bogdanm 70:673126e12c73 392 \return APSR Register value
bogdanm 70:673126e12c73 393 */
bogdanm 70:673126e12c73 394 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
bogdanm 70:673126e12c73 395 {
bogdanm 70:673126e12c73 396 uint32_t result;
bogdanm 70:673126e12c73 397
bogdanm 70:673126e12c73 398 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
bogdanm 70:673126e12c73 399 return(result);
bogdanm 70:673126e12c73 400 }
bogdanm 70:673126e12c73 401
bogdanm 70:673126e12c73 402
bogdanm 70:673126e12c73 403 /** \brief Get xPSR Register
bogdanm 70:673126e12c73 404
bogdanm 70:673126e12c73 405 This function returns the content of the xPSR Register.
bogdanm 70:673126e12c73 406
bogdanm 70:673126e12c73 407 \return xPSR Register value
bogdanm 70:673126e12c73 408 */
bogdanm 70:673126e12c73 409 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
bogdanm 70:673126e12c73 410 {
bogdanm 70:673126e12c73 411 uint32_t result;
bogdanm 70:673126e12c73 412
bogdanm 70:673126e12c73 413 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
bogdanm 70:673126e12c73 414 return(result);
bogdanm 70:673126e12c73 415 }
bogdanm 70:673126e12c73 416
bogdanm 70:673126e12c73 417
bogdanm 70:673126e12c73 418 /** \brief Get Process Stack Pointer
bogdanm 70:673126e12c73 419
bogdanm 70:673126e12c73 420 This function returns the current value of the Process Stack Pointer (PSP).
bogdanm 70:673126e12c73 421
bogdanm 70:673126e12c73 422 \return PSP Register value
bogdanm 70:673126e12c73 423 */
bogdanm 70:673126e12c73 424 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
bogdanm 70:673126e12c73 425 {
bogdanm 70:673126e12c73 426 register uint32_t result;
bogdanm 70:673126e12c73 427
bogdanm 70:673126e12c73 428 __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
bogdanm 70:673126e12c73 429 return(result);
bogdanm 70:673126e12c73 430 }
bogdanm 70:673126e12c73 431
bogdanm 70:673126e12c73 432
bogdanm 70:673126e12c73 433 /** \brief Set Process Stack Pointer
bogdanm 70:673126e12c73 434
bogdanm 70:673126e12c73 435 This function assigns the given value to the Process Stack Pointer (PSP).
bogdanm 70:673126e12c73 436
bogdanm 70:673126e12c73 437 \param [in] topOfProcStack Process Stack Pointer value to set
bogdanm 70:673126e12c73 438 */
bogdanm 70:673126e12c73 439 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
bogdanm 70:673126e12c73 440 {
bogdanm 70:673126e12c73 441 __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
bogdanm 70:673126e12c73 442 }
bogdanm 70:673126e12c73 443
bogdanm 70:673126e12c73 444
bogdanm 70:673126e12c73 445 /** \brief Get Main Stack Pointer
bogdanm 70:673126e12c73 446
bogdanm 70:673126e12c73 447 This function returns the current value of the Main Stack Pointer (MSP).
bogdanm 70:673126e12c73 448
bogdanm 70:673126e12c73 449 \return MSP Register value
bogdanm 70:673126e12c73 450 */
bogdanm 70:673126e12c73 451 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
bogdanm 70:673126e12c73 452 {
bogdanm 70:673126e12c73 453 register uint32_t result;
bogdanm 70:673126e12c73 454
bogdanm 70:673126e12c73 455 __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
bogdanm 70:673126e12c73 456 return(result);
bogdanm 70:673126e12c73 457 }
bogdanm 70:673126e12c73 458
bogdanm 70:673126e12c73 459
bogdanm 70:673126e12c73 460 /** \brief Set Main Stack Pointer
bogdanm 70:673126e12c73 461
bogdanm 70:673126e12c73 462 This function assigns the given value to the Main Stack Pointer (MSP).
bogdanm 70:673126e12c73 463
bogdanm 70:673126e12c73 464 \param [in] topOfMainStack Main Stack Pointer value to set
bogdanm 70:673126e12c73 465 */
bogdanm 70:673126e12c73 466 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
bogdanm 70:673126e12c73 467 {
bogdanm 70:673126e12c73 468 __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
bogdanm 70:673126e12c73 469 }
bogdanm 70:673126e12c73 470
bogdanm 70:673126e12c73 471
bogdanm 70:673126e12c73 472 /** \brief Get Priority Mask
bogdanm 70:673126e12c73 473
bogdanm 70:673126e12c73 474 This function returns the current state of the priority mask bit from the Priority Mask Register.
bogdanm 70:673126e12c73 475
bogdanm 70:673126e12c73 476 \return Priority Mask value
bogdanm 70:673126e12c73 477 */
bogdanm 70:673126e12c73 478 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
bogdanm 70:673126e12c73 479 {
bogdanm 70:673126e12c73 480 uint32_t result;
bogdanm 70:673126e12c73 481
bogdanm 70:673126e12c73 482 __ASM volatile ("MRS %0, primask" : "=r" (result) );
bogdanm 70:673126e12c73 483 return(result);
bogdanm 70:673126e12c73 484 }
bogdanm 70:673126e12c73 485
bogdanm 70:673126e12c73 486
bogdanm 70:673126e12c73 487 /** \brief Set Priority Mask
bogdanm 70:673126e12c73 488
bogdanm 70:673126e12c73 489 This function assigns the given value to the Priority Mask Register.
bogdanm 70:673126e12c73 490
bogdanm 70:673126e12c73 491 \param [in] priMask Priority Mask
bogdanm 70:673126e12c73 492 */
bogdanm 70:673126e12c73 493 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
bogdanm 70:673126e12c73 494 {
bogdanm 70:673126e12c73 495 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
bogdanm 70:673126e12c73 496 }
bogdanm 70:673126e12c73 497
bogdanm 70:673126e12c73 498
bogdanm 70:673126e12c73 499 #if (__CORTEX_M >= 0x03)
bogdanm 70:673126e12c73 500
bogdanm 70:673126e12c73 501 /** \brief Enable FIQ
bogdanm 70:673126e12c73 502
bogdanm 70:673126e12c73 503 This function enables FIQ interrupts by clearing the F-bit in the CPSR.
bogdanm 70:673126e12c73 504 Can only be executed in Privileged modes.
bogdanm 70:673126e12c73 505 */
bogdanm 70:673126e12c73 506 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
bogdanm 70:673126e12c73 507 {
bogdanm 70:673126e12c73 508 __ASM volatile ("cpsie f" : : : "memory");
bogdanm 70:673126e12c73 509 }
bogdanm 70:673126e12c73 510
bogdanm 70:673126e12c73 511
bogdanm 70:673126e12c73 512 /** \brief Disable FIQ
bogdanm 70:673126e12c73 513
bogdanm 70:673126e12c73 514 This function disables FIQ interrupts by setting the F-bit in the CPSR.
bogdanm 70:673126e12c73 515 Can only be executed in Privileged modes.
bogdanm 70:673126e12c73 516 */
bogdanm 70:673126e12c73 517 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
bogdanm 70:673126e12c73 518 {
bogdanm 70:673126e12c73 519 __ASM volatile ("cpsid f" : : : "memory");
bogdanm 70:673126e12c73 520 }
bogdanm 70:673126e12c73 521
bogdanm 70:673126e12c73 522
bogdanm 70:673126e12c73 523 /** \brief Get Base Priority
bogdanm 70:673126e12c73 524
bogdanm 70:673126e12c73 525 This function returns the current value of the Base Priority register.
bogdanm 70:673126e12c73 526
bogdanm 70:673126e12c73 527 \return Base Priority register value
bogdanm 70:673126e12c73 528 */
bogdanm 70:673126e12c73 529 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
bogdanm 70:673126e12c73 530 {
bogdanm 70:673126e12c73 531 uint32_t result;
bogdanm 70:673126e12c73 532
bogdanm 70:673126e12c73 533 __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
bogdanm 70:673126e12c73 534 return(result);
bogdanm 70:673126e12c73 535 }
bogdanm 70:673126e12c73 536
bogdanm 70:673126e12c73 537
bogdanm 70:673126e12c73 538 /** \brief Set Base Priority
bogdanm 70:673126e12c73 539
bogdanm 70:673126e12c73 540 This function assigns the given value to the Base Priority register.
bogdanm 70:673126e12c73 541
bogdanm 70:673126e12c73 542 \param [in] basePri Base Priority value to set
bogdanm 70:673126e12c73 543 */
bogdanm 70:673126e12c73 544 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
bogdanm 70:673126e12c73 545 {
bogdanm 70:673126e12c73 546 __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
bogdanm 70:673126e12c73 547 }
bogdanm 70:673126e12c73 548
bogdanm 70:673126e12c73 549
bogdanm 70:673126e12c73 550 /** \brief Get Fault Mask
bogdanm 70:673126e12c73 551
bogdanm 70:673126e12c73 552 This function returns the current value of the Fault Mask register.
bogdanm 70:673126e12c73 553
bogdanm 70:673126e12c73 554 \return Fault Mask register value
bogdanm 70:673126e12c73 555 */
bogdanm 70:673126e12c73 556 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
bogdanm 70:673126e12c73 557 {
bogdanm 70:673126e12c73 558 uint32_t result;
bogdanm 70:673126e12c73 559
bogdanm 70:673126e12c73 560 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
bogdanm 70:673126e12c73 561 return(result);
bogdanm 70:673126e12c73 562 }
bogdanm 70:673126e12c73 563
bogdanm 70:673126e12c73 564
bogdanm 70:673126e12c73 565 /** \brief Set Fault Mask
bogdanm 70:673126e12c73 566
bogdanm 70:673126e12c73 567 This function assigns the given value to the Fault Mask register.
bogdanm 70:673126e12c73 568
bogdanm 70:673126e12c73 569 \param [in] faultMask Fault Mask value to set
bogdanm 70:673126e12c73 570 */
bogdanm 70:673126e12c73 571 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
bogdanm 70:673126e12c73 572 {
bogdanm 70:673126e12c73 573 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
bogdanm 70:673126e12c73 574 }
bogdanm 70:673126e12c73 575
bogdanm 70:673126e12c73 576 #endif /* (__CORTEX_M >= 0x03) */
bogdanm 70:673126e12c73 577
bogdanm 70:673126e12c73 578
bogdanm 70:673126e12c73 579 #if (__CORTEX_M == 0x04)
bogdanm 70:673126e12c73 580
bogdanm 70:673126e12c73 581 /** \brief Get FPSCR
bogdanm 70:673126e12c73 582
bogdanm 70:673126e12c73 583 This function returns the current value of the Floating Point Status/Control register.
bogdanm 70:673126e12c73 584
bogdanm 70:673126e12c73 585 \return Floating Point Status/Control register value
bogdanm 70:673126e12c73 586 */
bogdanm 70:673126e12c73 587 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
bogdanm 70:673126e12c73 588 {
bogdanm 70:673126e12c73 589 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
bogdanm 70:673126e12c73 590 uint32_t result;
bogdanm 70:673126e12c73 591
bogdanm 70:673126e12c73 592 /* Empty asm statement works as a scheduling barrier */
bogdanm 70:673126e12c73 593 __ASM volatile ("");
bogdanm 70:673126e12c73 594 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
bogdanm 70:673126e12c73 595 __ASM volatile ("");
bogdanm 70:673126e12c73 596 return(result);
bogdanm 70:673126e12c73 597 #else
bogdanm 70:673126e12c73 598 return(0);
bogdanm 70:673126e12c73 599 #endif
bogdanm 70:673126e12c73 600 }
bogdanm 70:673126e12c73 601
bogdanm 70:673126e12c73 602
bogdanm 70:673126e12c73 603 /** \brief Set FPSCR
bogdanm 70:673126e12c73 604
bogdanm 70:673126e12c73 605 This function assigns the given value to the Floating Point Status/Control register.
bogdanm 70:673126e12c73 606
bogdanm 70:673126e12c73 607 \param [in] fpscr Floating Point Status/Control value to set
bogdanm 70:673126e12c73 608 */
bogdanm 70:673126e12c73 609 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
bogdanm 70:673126e12c73 610 {
bogdanm 70:673126e12c73 611 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
bogdanm 70:673126e12c73 612 /* Empty asm statement works as a scheduling barrier */
bogdanm 70:673126e12c73 613 __ASM volatile ("");
bogdanm 70:673126e12c73 614 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
bogdanm 70:673126e12c73 615 __ASM volatile ("");
bogdanm 70:673126e12c73 616 #endif
bogdanm 70:673126e12c73 617 }
bogdanm 70:673126e12c73 618
bogdanm 70:673126e12c73 619 #endif /* (__CORTEX_M == 0x04) */
bogdanm 70:673126e12c73 620
bogdanm 70:673126e12c73 621
bogdanm 70:673126e12c73 622 #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
bogdanm 70:673126e12c73 623 /* TASKING carm specific functions */
bogdanm 70:673126e12c73 624
bogdanm 70:673126e12c73 625 /*
bogdanm 70:673126e12c73 626 * The CMSIS functions have been implemented as intrinsics in the compiler.
bogdanm 70:673126e12c73 627 * Please use "carm -?i" to get an up to date list of all instrinsics,
bogdanm 70:673126e12c73 628 * Including the CMSIS ones.
bogdanm 70:673126e12c73 629 */
bogdanm 70:673126e12c73 630
bogdanm 70:673126e12c73 631 #endif
bogdanm 70:673126e12c73 632
bogdanm 70:673126e12c73 633 /*@} end of CMSIS_Core_RegAccFunctions */
bogdanm 70:673126e12c73 634
bogdanm 70:673126e12c73 635
bogdanm 70:673126e12c73 636 #endif /* __CORE_CMFUNC_H */