The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Wed May 13 08:08:21 2015 +0200
Revision:
99:dbbf35b96557
Child:
110:165afa46840b
Release 99 of the mbed library

Changes:
- new targets - MAXWSNENV, DISCO_L053C8
- STM32F4xx - ST Cube driver
- KSDK mcu - SPI timing fix
- Nordic - update to softdevice s130

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 99:dbbf35b96557 4 * @version V3.20
Kojto 99:dbbf35b96557 5 * @date 25. February 2013
Kojto 99:dbbf35b96557 6 *
Kojto 99:dbbf35b96557 7 * @note
Kojto 99:dbbf35b96557 8 *
Kojto 99:dbbf35b96557 9 ******************************************************************************/
Kojto 99:dbbf35b96557 10 /* Copyright (c) 2009 - 2013 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 99:dbbf35b96557 201 #if (__CORTEX_M >= 0x03)
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 99:dbbf35b96557 245 /** \brief Get Fault Mask
Kojto 99:dbbf35b96557 246
Kojto 99:dbbf35b96557 247 This function returns the current value of the Fault Mask register.
Kojto 99:dbbf35b96557 248
Kojto 99:dbbf35b96557 249 \return Fault Mask register value
Kojto 99:dbbf35b96557 250 */
Kojto 99:dbbf35b96557 251 __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Kojto 99:dbbf35b96557 252 {
Kojto 99:dbbf35b96557 253 register uint32_t __regFaultMask __ASM("faultmask");
Kojto 99:dbbf35b96557 254 return(__regFaultMask);
Kojto 99:dbbf35b96557 255 }
Kojto 99:dbbf35b96557 256
Kojto 99:dbbf35b96557 257
Kojto 99:dbbf35b96557 258 /** \brief Set Fault Mask
Kojto 99:dbbf35b96557 259
Kojto 99:dbbf35b96557 260 This function assigns the given value to the Fault Mask register.
Kojto 99:dbbf35b96557 261
Kojto 99:dbbf35b96557 262 \param [in] faultMask Fault Mask value to set
Kojto 99:dbbf35b96557 263 */
Kojto 99:dbbf35b96557 264 __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Kojto 99:dbbf35b96557 265 {
Kojto 99:dbbf35b96557 266 register uint32_t __regFaultMask __ASM("faultmask");
Kojto 99:dbbf35b96557 267 __regFaultMask = (faultMask & (uint32_t)1);
Kojto 99:dbbf35b96557 268 }
Kojto 99:dbbf35b96557 269
Kojto 99:dbbf35b96557 270 #endif /* (__CORTEX_M >= 0x03) */
Kojto 99:dbbf35b96557 271
Kojto 99:dbbf35b96557 272
Kojto 99:dbbf35b96557 273 #if (__CORTEX_M == 0x04)
Kojto 99:dbbf35b96557 274
Kojto 99:dbbf35b96557 275 /** \brief Get FPSCR
Kojto 99:dbbf35b96557 276
Kojto 99:dbbf35b96557 277 This function returns the current value of the Floating Point Status/Control register.
Kojto 99:dbbf35b96557 278
Kojto 99:dbbf35b96557 279 \return Floating Point Status/Control register value
Kojto 99:dbbf35b96557 280 */
Kojto 99:dbbf35b96557 281 __STATIC_INLINE uint32_t __get_FPSCR(void)
Kojto 99:dbbf35b96557 282 {
Kojto 99:dbbf35b96557 283 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 99:dbbf35b96557 284 register uint32_t __regfpscr __ASM("fpscr");
Kojto 99:dbbf35b96557 285 return(__regfpscr);
Kojto 99:dbbf35b96557 286 #else
Kojto 99:dbbf35b96557 287 return(0);
Kojto 99:dbbf35b96557 288 #endif
Kojto 99:dbbf35b96557 289 }
Kojto 99:dbbf35b96557 290
Kojto 99:dbbf35b96557 291
Kojto 99:dbbf35b96557 292 /** \brief Set FPSCR
Kojto 99:dbbf35b96557 293
Kojto 99:dbbf35b96557 294 This function assigns the given value to the Floating Point Status/Control register.
Kojto 99:dbbf35b96557 295
Kojto 99:dbbf35b96557 296 \param [in] fpscr Floating Point Status/Control value to set
Kojto 99:dbbf35b96557 297 */
Kojto 99:dbbf35b96557 298 __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Kojto 99:dbbf35b96557 299 {
Kojto 99:dbbf35b96557 300 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 99:dbbf35b96557 301 register uint32_t __regfpscr __ASM("fpscr");
Kojto 99:dbbf35b96557 302 __regfpscr = (fpscr);
Kojto 99:dbbf35b96557 303 #endif
Kojto 99:dbbf35b96557 304 }
Kojto 99:dbbf35b96557 305
Kojto 99:dbbf35b96557 306 #endif /* (__CORTEX_M == 0x04) */
Kojto 99:dbbf35b96557 307
Kojto 99:dbbf35b96557 308
Kojto 99:dbbf35b96557 309 #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
Kojto 99:dbbf35b96557 310 /* IAR iccarm specific functions */
Kojto 99:dbbf35b96557 311
Kojto 99:dbbf35b96557 312 #include <cmsis_iar.h>
Kojto 99:dbbf35b96557 313
Kojto 99:dbbf35b96557 314
Kojto 99:dbbf35b96557 315 #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
Kojto 99:dbbf35b96557 316 /* TI CCS specific functions */
Kojto 99:dbbf35b96557 317
Kojto 99:dbbf35b96557 318 #include <cmsis_ccs.h>
Kojto 99:dbbf35b96557 319
Kojto 99:dbbf35b96557 320
Kojto 99:dbbf35b96557 321 #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
Kojto 99:dbbf35b96557 322 /* GNU gcc specific functions */
Kojto 99:dbbf35b96557 323
Kojto 99:dbbf35b96557 324 /** \brief Enable IRQ Interrupts
Kojto 99:dbbf35b96557 325
Kojto 99:dbbf35b96557 326 This function enables IRQ interrupts by clearing the I-bit in the CPSR.
Kojto 99:dbbf35b96557 327 Can only be executed in Privileged modes.
Kojto 99:dbbf35b96557 328 */
Kojto 99:dbbf35b96557 329 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
Kojto 99:dbbf35b96557 330 {
Kojto 99:dbbf35b96557 331 __ASM volatile ("cpsie i" : : : "memory");
Kojto 99:dbbf35b96557 332 }
Kojto 99:dbbf35b96557 333
Kojto 99:dbbf35b96557 334
Kojto 99:dbbf35b96557 335 /** \brief Disable IRQ Interrupts
Kojto 99:dbbf35b96557 336
Kojto 99:dbbf35b96557 337 This function disables IRQ interrupts by setting the I-bit in the CPSR.
Kojto 99:dbbf35b96557 338 Can only be executed in Privileged modes.
Kojto 99:dbbf35b96557 339 */
Kojto 99:dbbf35b96557 340 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
Kojto 99:dbbf35b96557 341 {
Kojto 99:dbbf35b96557 342 __ASM volatile ("cpsid i" : : : "memory");
Kojto 99:dbbf35b96557 343 }
Kojto 99:dbbf35b96557 344
Kojto 99:dbbf35b96557 345
Kojto 99:dbbf35b96557 346 /** \brief Get Control Register
Kojto 99:dbbf35b96557 347
Kojto 99:dbbf35b96557 348 This function returns the content of the Control Register.
Kojto 99:dbbf35b96557 349
Kojto 99:dbbf35b96557 350 \return Control Register value
Kojto 99:dbbf35b96557 351 */
Kojto 99:dbbf35b96557 352 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
Kojto 99:dbbf35b96557 353 {
Kojto 99:dbbf35b96557 354 uint32_t result;
Kojto 99:dbbf35b96557 355
Kojto 99:dbbf35b96557 356 __ASM volatile ("MRS %0, control" : "=r" (result) );
Kojto 99:dbbf35b96557 357 return(result);
Kojto 99:dbbf35b96557 358 }
Kojto 99:dbbf35b96557 359
Kojto 99:dbbf35b96557 360
Kojto 99:dbbf35b96557 361 /** \brief Set Control Register
Kojto 99:dbbf35b96557 362
Kojto 99:dbbf35b96557 363 This function writes the given value to the Control Register.
Kojto 99:dbbf35b96557 364
Kojto 99:dbbf35b96557 365 \param [in] control Control Register value to set
Kojto 99:dbbf35b96557 366 */
Kojto 99:dbbf35b96557 367 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
Kojto 99:dbbf35b96557 368 {
Kojto 99:dbbf35b96557 369 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
Kojto 99:dbbf35b96557 370 }
Kojto 99:dbbf35b96557 371
Kojto 99:dbbf35b96557 372
Kojto 99:dbbf35b96557 373 /** \brief Get IPSR Register
Kojto 99:dbbf35b96557 374
Kojto 99:dbbf35b96557 375 This function returns the content of the IPSR Register.
Kojto 99:dbbf35b96557 376
Kojto 99:dbbf35b96557 377 \return IPSR Register value
Kojto 99:dbbf35b96557 378 */
Kojto 99:dbbf35b96557 379 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
Kojto 99:dbbf35b96557 380 {
Kojto 99:dbbf35b96557 381 uint32_t result;
Kojto 99:dbbf35b96557 382
Kojto 99:dbbf35b96557 383 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
Kojto 99:dbbf35b96557 384 return(result);
Kojto 99:dbbf35b96557 385 }
Kojto 99:dbbf35b96557 386
Kojto 99:dbbf35b96557 387
Kojto 99:dbbf35b96557 388 /** \brief Get APSR Register
Kojto 99:dbbf35b96557 389
Kojto 99:dbbf35b96557 390 This function returns the content of the APSR Register.
Kojto 99:dbbf35b96557 391
Kojto 99:dbbf35b96557 392 \return APSR Register value
Kojto 99:dbbf35b96557 393 */
Kojto 99:dbbf35b96557 394 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
Kojto 99:dbbf35b96557 395 {
Kojto 99:dbbf35b96557 396 uint32_t result;
Kojto 99:dbbf35b96557 397
Kojto 99:dbbf35b96557 398 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
Kojto 99:dbbf35b96557 399 return(result);
Kojto 99:dbbf35b96557 400 }
Kojto 99:dbbf35b96557 401
Kojto 99:dbbf35b96557 402
Kojto 99:dbbf35b96557 403 /** \brief Get xPSR Register
Kojto 99:dbbf35b96557 404
Kojto 99:dbbf35b96557 405 This function returns the content of the xPSR Register.
Kojto 99:dbbf35b96557 406
Kojto 99:dbbf35b96557 407 \return xPSR Register value
Kojto 99:dbbf35b96557 408 */
Kojto 99:dbbf35b96557 409 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
Kojto 99:dbbf35b96557 410 {
Kojto 99:dbbf35b96557 411 uint32_t result;
Kojto 99:dbbf35b96557 412
Kojto 99:dbbf35b96557 413 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
Kojto 99:dbbf35b96557 414 return(result);
Kojto 99:dbbf35b96557 415 }
Kojto 99:dbbf35b96557 416
Kojto 99:dbbf35b96557 417
Kojto 99:dbbf35b96557 418 /** \brief Get Process Stack Pointer
Kojto 99:dbbf35b96557 419
Kojto 99:dbbf35b96557 420 This function returns the current value of the Process Stack Pointer (PSP).
Kojto 99:dbbf35b96557 421
Kojto 99:dbbf35b96557 422 \return PSP Register value
Kojto 99:dbbf35b96557 423 */
Kojto 99:dbbf35b96557 424 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
Kojto 99:dbbf35b96557 425 {
Kojto 99:dbbf35b96557 426 register uint32_t result;
Kojto 99:dbbf35b96557 427
Kojto 99:dbbf35b96557 428 __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
Kojto 99:dbbf35b96557 429 return(result);
Kojto 99:dbbf35b96557 430 }
Kojto 99:dbbf35b96557 431
Kojto 99:dbbf35b96557 432
Kojto 99:dbbf35b96557 433 /** \brief Set Process Stack Pointer
Kojto 99:dbbf35b96557 434
Kojto 99:dbbf35b96557 435 This function assigns the given value to the Process Stack Pointer (PSP).
Kojto 99:dbbf35b96557 436
Kojto 99:dbbf35b96557 437 \param [in] topOfProcStack Process Stack Pointer value to set
Kojto 99:dbbf35b96557 438 */
Kojto 99:dbbf35b96557 439 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Kojto 99:dbbf35b96557 440 {
Kojto 99:dbbf35b96557 441 __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
Kojto 99:dbbf35b96557 442 }
Kojto 99:dbbf35b96557 443
Kojto 99:dbbf35b96557 444
Kojto 99:dbbf35b96557 445 /** \brief Get Main Stack Pointer
Kojto 99:dbbf35b96557 446
Kojto 99:dbbf35b96557 447 This function returns the current value of the Main Stack Pointer (MSP).
Kojto 99:dbbf35b96557 448
Kojto 99:dbbf35b96557 449 \return MSP Register value
Kojto 99:dbbf35b96557 450 */
Kojto 99:dbbf35b96557 451 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
Kojto 99:dbbf35b96557 452 {
Kojto 99:dbbf35b96557 453 register uint32_t result;
Kojto 99:dbbf35b96557 454
Kojto 99:dbbf35b96557 455 __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
Kojto 99:dbbf35b96557 456 return(result);
Kojto 99:dbbf35b96557 457 }
Kojto 99:dbbf35b96557 458
Kojto 99:dbbf35b96557 459
Kojto 99:dbbf35b96557 460 /** \brief Set Main Stack Pointer
Kojto 99:dbbf35b96557 461
Kojto 99:dbbf35b96557 462 This function assigns the given value to the Main Stack Pointer (MSP).
Kojto 99:dbbf35b96557 463
Kojto 99:dbbf35b96557 464 \param [in] topOfMainStack Main Stack Pointer value to set
Kojto 99:dbbf35b96557 465 */
Kojto 99:dbbf35b96557 466 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Kojto 99:dbbf35b96557 467 {
Kojto 99:dbbf35b96557 468 __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
Kojto 99:dbbf35b96557 469 }
Kojto 99:dbbf35b96557 470
Kojto 99:dbbf35b96557 471
Kojto 99:dbbf35b96557 472 /** \brief Get Priority Mask
Kojto 99:dbbf35b96557 473
Kojto 99:dbbf35b96557 474 This function returns the current state of the priority mask bit from the Priority Mask Register.
Kojto 99:dbbf35b96557 475
Kojto 99:dbbf35b96557 476 \return Priority Mask value
Kojto 99:dbbf35b96557 477 */
Kojto 99:dbbf35b96557 478 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
Kojto 99:dbbf35b96557 479 {
Kojto 99:dbbf35b96557 480 uint32_t result;
Kojto 99:dbbf35b96557 481
Kojto 99:dbbf35b96557 482 __ASM volatile ("MRS %0, primask" : "=r" (result) );
Kojto 99:dbbf35b96557 483 return(result);
Kojto 99:dbbf35b96557 484 }
Kojto 99:dbbf35b96557 485
Kojto 99:dbbf35b96557 486
Kojto 99:dbbf35b96557 487 /** \brief Set Priority Mask
Kojto 99:dbbf35b96557 488
Kojto 99:dbbf35b96557 489 This function assigns the given value to the Priority Mask Register.
Kojto 99:dbbf35b96557 490
Kojto 99:dbbf35b96557 491 \param [in] priMask Priority Mask
Kojto 99:dbbf35b96557 492 */
Kojto 99:dbbf35b96557 493 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Kojto 99:dbbf35b96557 494 {
Kojto 99:dbbf35b96557 495 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
Kojto 99:dbbf35b96557 496 }
Kojto 99:dbbf35b96557 497
Kojto 99:dbbf35b96557 498
Kojto 99:dbbf35b96557 499 #if (__CORTEX_M >= 0x03)
Kojto 99:dbbf35b96557 500
Kojto 99:dbbf35b96557 501 /** \brief Enable FIQ
Kojto 99:dbbf35b96557 502
Kojto 99:dbbf35b96557 503 This function enables FIQ interrupts by clearing the F-bit in the CPSR.
Kojto 99:dbbf35b96557 504 Can only be executed in Privileged modes.
Kojto 99:dbbf35b96557 505 */
Kojto 99:dbbf35b96557 506 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
Kojto 99:dbbf35b96557 507 {
Kojto 99:dbbf35b96557 508 __ASM volatile ("cpsie f" : : : "memory");
Kojto 99:dbbf35b96557 509 }
Kojto 99:dbbf35b96557 510
Kojto 99:dbbf35b96557 511
Kojto 99:dbbf35b96557 512 /** \brief Disable FIQ
Kojto 99:dbbf35b96557 513
Kojto 99:dbbf35b96557 514 This function disables FIQ interrupts by setting the F-bit in the CPSR.
Kojto 99:dbbf35b96557 515 Can only be executed in Privileged modes.
Kojto 99:dbbf35b96557 516 */
Kojto 99:dbbf35b96557 517 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
Kojto 99:dbbf35b96557 518 {
Kojto 99:dbbf35b96557 519 __ASM volatile ("cpsid f" : : : "memory");
Kojto 99:dbbf35b96557 520 }
Kojto 99:dbbf35b96557 521
Kojto 99:dbbf35b96557 522
Kojto 99:dbbf35b96557 523 /** \brief Get Base Priority
Kojto 99:dbbf35b96557 524
Kojto 99:dbbf35b96557 525 This function returns the current value of the Base Priority register.
Kojto 99:dbbf35b96557 526
Kojto 99:dbbf35b96557 527 \return Base Priority register value
Kojto 99:dbbf35b96557 528 */
Kojto 99:dbbf35b96557 529 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
Kojto 99:dbbf35b96557 530 {
Kojto 99:dbbf35b96557 531 uint32_t result;
Kojto 99:dbbf35b96557 532
Kojto 99:dbbf35b96557 533 __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
Kojto 99:dbbf35b96557 534 return(result);
Kojto 99:dbbf35b96557 535 }
Kojto 99:dbbf35b96557 536
Kojto 99:dbbf35b96557 537
Kojto 99:dbbf35b96557 538 /** \brief Set Base Priority
Kojto 99:dbbf35b96557 539
Kojto 99:dbbf35b96557 540 This function assigns the given value to the Base Priority register.
Kojto 99:dbbf35b96557 541
Kojto 99:dbbf35b96557 542 \param [in] basePri Base Priority value to set
Kojto 99:dbbf35b96557 543 */
Kojto 99:dbbf35b96557 544 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
Kojto 99:dbbf35b96557 545 {
Kojto 99:dbbf35b96557 546 __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
Kojto 99:dbbf35b96557 547 }
Kojto 99:dbbf35b96557 548
Kojto 99:dbbf35b96557 549
Kojto 99:dbbf35b96557 550 /** \brief Get Fault Mask
Kojto 99:dbbf35b96557 551
Kojto 99:dbbf35b96557 552 This function returns the current value of the Fault Mask register.
Kojto 99:dbbf35b96557 553
Kojto 99:dbbf35b96557 554 \return Fault Mask register value
Kojto 99:dbbf35b96557 555 */
Kojto 99:dbbf35b96557 556 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Kojto 99:dbbf35b96557 557 {
Kojto 99:dbbf35b96557 558 uint32_t result;
Kojto 99:dbbf35b96557 559
Kojto 99:dbbf35b96557 560 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
Kojto 99:dbbf35b96557 561 return(result);
Kojto 99:dbbf35b96557 562 }
Kojto 99:dbbf35b96557 563
Kojto 99:dbbf35b96557 564
Kojto 99:dbbf35b96557 565 /** \brief Set Fault Mask
Kojto 99:dbbf35b96557 566
Kojto 99:dbbf35b96557 567 This function assigns the given value to the Fault Mask register.
Kojto 99:dbbf35b96557 568
Kojto 99:dbbf35b96557 569 \param [in] faultMask Fault Mask value to set
Kojto 99:dbbf35b96557 570 */
Kojto 99:dbbf35b96557 571 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Kojto 99:dbbf35b96557 572 {
Kojto 99:dbbf35b96557 573 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
Kojto 99:dbbf35b96557 574 }
Kojto 99:dbbf35b96557 575
Kojto 99:dbbf35b96557 576 #endif /* (__CORTEX_M >= 0x03) */
Kojto 99:dbbf35b96557 577
Kojto 99:dbbf35b96557 578
Kojto 99:dbbf35b96557 579 #if (__CORTEX_M == 0x04)
Kojto 99:dbbf35b96557 580
Kojto 99:dbbf35b96557 581 /** \brief Get FPSCR
Kojto 99:dbbf35b96557 582
Kojto 99:dbbf35b96557 583 This function returns the current value of the Floating Point Status/Control register.
Kojto 99:dbbf35b96557 584
Kojto 99:dbbf35b96557 585 \return Floating Point Status/Control register value
Kojto 99:dbbf35b96557 586 */
Kojto 99:dbbf35b96557 587 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
Kojto 99:dbbf35b96557 588 {
Kojto 99:dbbf35b96557 589 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 99:dbbf35b96557 590 uint32_t result;
Kojto 99:dbbf35b96557 591
Kojto 99:dbbf35b96557 592 /* Empty asm statement works as a scheduling barrier */
Kojto 99:dbbf35b96557 593 __ASM volatile ("");
Kojto 99:dbbf35b96557 594 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
Kojto 99:dbbf35b96557 595 __ASM volatile ("");
Kojto 99:dbbf35b96557 596 return(result);
Kojto 99:dbbf35b96557 597 #else
Kojto 99:dbbf35b96557 598 return(0);
Kojto 99:dbbf35b96557 599 #endif
Kojto 99:dbbf35b96557 600 }
Kojto 99:dbbf35b96557 601
Kojto 99:dbbf35b96557 602
Kojto 99:dbbf35b96557 603 /** \brief Set FPSCR
Kojto 99:dbbf35b96557 604
Kojto 99:dbbf35b96557 605 This function assigns the given value to the Floating Point Status/Control register.
Kojto 99:dbbf35b96557 606
Kojto 99:dbbf35b96557 607 \param [in] fpscr Floating Point Status/Control value to set
Kojto 99:dbbf35b96557 608 */
Kojto 99:dbbf35b96557 609 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Kojto 99:dbbf35b96557 610 {
Kojto 99:dbbf35b96557 611 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 99:dbbf35b96557 612 /* Empty asm statement works as a scheduling barrier */
Kojto 99:dbbf35b96557 613 __ASM volatile ("");
Kojto 99:dbbf35b96557 614 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
Kojto 99:dbbf35b96557 615 __ASM volatile ("");
Kojto 99:dbbf35b96557 616 #endif
Kojto 99:dbbf35b96557 617 }
Kojto 99:dbbf35b96557 618
Kojto 99:dbbf35b96557 619 #endif /* (__CORTEX_M == 0x04) */
Kojto 99:dbbf35b96557 620
Kojto 99:dbbf35b96557 621
Kojto 99:dbbf35b96557 622 #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
Kojto 99:dbbf35b96557 623 /* TASKING carm specific functions */
Kojto 99:dbbf35b96557 624
Kojto 99:dbbf35b96557 625 /*
Kojto 99:dbbf35b96557 626 * The CMSIS functions have been implemented as intrinsics in the compiler.
Kojto 99:dbbf35b96557 627 * Please use "carm -?i" to get an up to date list of all instrinsics,
Kojto 99:dbbf35b96557 628 * Including the CMSIS ones.
Kojto 99:dbbf35b96557 629 */
Kojto 99:dbbf35b96557 630
Kojto 99:dbbf35b96557 631 #endif
Kojto 99:dbbf35b96557 632
Kojto 99:dbbf35b96557 633 /*@} end of CMSIS_Core_RegAccFunctions */
Kojto 99:dbbf35b96557 634
Kojto 99:dbbf35b96557 635
Kojto 99:dbbf35b96557 636 #endif /* __CORE_CMFUNC_H */