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:
Tue Mar 14 16:20:51 2017 +0000
Revision:
138:093f2bd7b9eb
Parent:
113:f141b2784e32
Release 138 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3716: fix for issue #3715: correction in startup files for ARM and IAR, alignment of system_stm32f429xx.c files https://github.com/ARMmbed/mbed-os/pull/3716
3741: STM32 remove warning in hal_tick_32b.c file https://github.com/ARMmbed/mbed-os/pull/3741
3780: STM32L4 : Fix GPIO G port compatibility https://github.com/ARMmbed/mbed-os/pull/3780
3831: NCS36510: SPISLAVE enabled (Conflict resolved) https://github.com/ARMmbed/mbed-os/pull/3831
3836: Allow to redefine nRF's PSTORAGE_NUM_OF_PAGES outside of the mbed-os https://github.com/ARMmbed/mbed-os/pull/3836
3840: STM32: gpio SPEED - always set High Speed by default https://github.com/ARMmbed/mbed-os/pull/3840
3844: STM32 GPIO: Typo correction. Update comment (GPIO_IP_WITHOUT_BRR) https://github.com/ARMmbed/mbed-os/pull/3844
3850: STM32: change spi error to debug warning https://github.com/ARMmbed/mbed-os/pull/3850
3860: Define GPIO_IP_WITHOUT_BRR for xDot platform https://github.com/ARMmbed/mbed-os/pull/3860
3880: DISCO_F469NI: allow the use of CAN2 instance when CAN1 is not activated https://github.com/ARMmbed/mbed-os/pull/3880
3795: Fix pwm period calc https://github.com/ARMmbed/mbed-os/pull/3795
3828: STM32 CAN API: correct format and type https://github.com/ARMmbed/mbed-os/pull/3828
3842: TARGET_NRF: corrected spi_init() to properly handle re-initialization https://github.com/ARMmbed/mbed-os/pull/3842
3843: STM32L476xG: set APB2 clock to 80MHz (instead of 40MHz) https://github.com/ARMmbed/mbed-os/pull/3843
3879: NUCLEO_F446ZE: Add missing AnalogIn pins on PF_3, PF_5 and PF_10. https://github.com/ARMmbed/mbed-os/pull/3879
3902: Fix heap and stack size for NUCLEO_F746ZG https://github.com/ARMmbed/mbed-os/pull/3902
3829: can_write(): return error code when no tx mailboxes are available https://github.com/ARMmbed/mbed-os/pull/3829

Who changed what in which revision?

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