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