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:
<>
Date:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
124:2241e3a39974
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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