version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
erezi
Date:
Wed Jun 25 06:08:49 2014 +0000
Revision:
86:4f9a848d74c7
Parent:
66:9c8f0e3462fb
version_2.0

Who changed what in which revision?

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