PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Wed Dec 25 23:59:52 2019 +0000
Revision:
71:531419862202
Parent:
5:ea7377f3d1af
Changed Mode2 C++ refresh code (graphical errors)

Who changed what in which revision?

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