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