I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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