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