meh

Fork of mbed by mbed official

Committer:
ricardobtez
Date:
Tue Apr 05 23:51:21 2016 +0000
Revision:
118:16969dd821af
Parent:
89:552587b429a1
Child:
110:165afa46840b
dgdgr

Who changed what in which revision?

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