The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Fri May 26 12:30:20 2017 +0100
Revision:
143:86740a56073b
Parent:
122:f9eeca106725
Release 143 of the mbed library.

Who changed what in which revision?

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