meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed Nov 25 13:21:40 2015 +0000
Revision:
110:165afa46840b
Parent:
65:5798e58a58b1
Release 110  of the mbed library

Changes:
- new platforms - STM32F410R, DISCO_F429ZI, DISCO_F469NI
- Nucleo L476 - gcc and uvision template
- k22,k64f targets - ADC channels A addition
- EFM32 - bugfixes in sleep, serial and spi
- Delta DFCM NNN40 - pinnames update

Who changed what in which revision?

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