ads1115 only

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed May 27 08:07:35 2015 +0100
Revision:
100:cbbeb26dbd92
Child:
110:165afa46840b
Release 100 of the mbed library

Changes:
- new target: DISCOF334C8
- API: Ticker/Timer bugfix with constness
- Silabs: RTC, PWM, Serial clocks bufixes
- Renesas: i2c bugfix
- Maxim: 326000 - pin definitions for v2, spi freq fix

Who changed what in which revision?

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