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:
Kojto
Date:
Tue Feb 14 11:24:20 2017 +0000
Revision:
136:ef9c61f8c49f
Parent:
112:6f327212ef96
Release 136 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3432: Target STM USBHOST support https://github.com/ARMmbed/mbed-os/pull/3432
3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now https://github.com/ARMmbed/mbed-os/pull/3181
3626: NUCLEO_F412ZG : Add USB Device +Host https://github.com/ARMmbed/mbed-os/pull/3626
3628: Fix warnings https://github.com/ARMmbed/mbed-os/pull/3628
3629: STM32: L0 LL layer https://github.com/ARMmbed/mbed-os/pull/3629
3632: IDE Export support for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3632
3642: Missing IRQ pin fix for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3642
3664: Fix ncs36510 sleep definitions https://github.com/ARMmbed/mbed-os/pull/3664
3655: [STM32F4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3655
3657: [STM32L4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3657
3658: [STM32F3] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3658
3685: STM32: I2C: reset state machine https://github.com/ARMmbed/mbed-os/pull/3685
3692: uVisor: Standardize available legacy heap and stack https://github.com/ARMmbed/mbed-os/pull/3692
3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron https://github.com/ARMmbed/mbed-os/pull/3621
3649: [STM32F7] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3649
3695: Enforce device_name is valid in targets.json https://github.com/ARMmbed/mbed-os/pull/3695
3723: NCS36510: spi_format function bug fix https://github.com/ARMmbed/mbed-os/pull/3723

Who changed what in which revision?

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