mbed library sources

Committer:
ebrus
Date:
Wed Jul 27 18:35:32 2016 +0000
Revision:
0:0a673c671a56
4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ebrus 0:0a673c671a56 1 /**************************************************************************//**
ebrus 0:0a673c671a56 2 * @file core_cm0.h
ebrus 0:0a673c671a56 3 * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
ebrus 0:0a673c671a56 4 * @version V3.20
ebrus 0:0a673c671a56 5 * @date 25. February 2013
ebrus 0:0a673c671a56 6 *
ebrus 0:0a673c671a56 7 * @note
ebrus 0:0a673c671a56 8 *
ebrus 0:0a673c671a56 9 ******************************************************************************/
ebrus 0:0a673c671a56 10 /* Copyright (c) 2009 - 2013 ARM LIMITED
ebrus 0:0a673c671a56 11
ebrus 0:0a673c671a56 12 All rights reserved.
ebrus 0:0a673c671a56 13 Redistribution and use in source and binary forms, with or without
ebrus 0:0a673c671a56 14 modification, are permitted provided that the following conditions are met:
ebrus 0:0a673c671a56 15 - Redistributions of source code must retain the above copyright
ebrus 0:0a673c671a56 16 notice, this list of conditions and the following disclaimer.
ebrus 0:0a673c671a56 17 - Redistributions in binary form must reproduce the above copyright
ebrus 0:0a673c671a56 18 notice, this list of conditions and the following disclaimer in the
ebrus 0:0a673c671a56 19 documentation and/or other materials provided with the distribution.
ebrus 0:0a673c671a56 20 - Neither the name of ARM nor the names of its contributors may be used
ebrus 0:0a673c671a56 21 to endorse or promote products derived from this software without
ebrus 0:0a673c671a56 22 specific prior written permission.
ebrus 0:0a673c671a56 23 *
ebrus 0:0a673c671a56 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ebrus 0:0a673c671a56 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ebrus 0:0a673c671a56 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ebrus 0:0a673c671a56 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
ebrus 0:0a673c671a56 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
ebrus 0:0a673c671a56 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
ebrus 0:0a673c671a56 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
ebrus 0:0a673c671a56 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
ebrus 0:0a673c671a56 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ebrus 0:0a673c671a56 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
ebrus 0:0a673c671a56 34 POSSIBILITY OF SUCH DAMAGE.
ebrus 0:0a673c671a56 35 ---------------------------------------------------------------------------*/
ebrus 0:0a673c671a56 36
ebrus 0:0a673c671a56 37
ebrus 0:0a673c671a56 38 #if defined ( __ICCARM__ )
ebrus 0:0a673c671a56 39 #pragma system_include /* treat file as system include file for MISRA check */
ebrus 0:0a673c671a56 40 #endif
ebrus 0:0a673c671a56 41
ebrus 0:0a673c671a56 42 #ifdef __cplusplus
ebrus 0:0a673c671a56 43 extern "C" {
ebrus 0:0a673c671a56 44 #endif
ebrus 0:0a673c671a56 45
ebrus 0:0a673c671a56 46 #ifndef __CORE_CM0_H_GENERIC
ebrus 0:0a673c671a56 47 #define __CORE_CM0_H_GENERIC
ebrus 0:0a673c671a56 48
ebrus 0:0a673c671a56 49 /** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
ebrus 0:0a673c671a56 50 CMSIS violates the following MISRA-C:2004 rules:
ebrus 0:0a673c671a56 51
ebrus 0:0a673c671a56 52 \li Required Rule 8.5, object/function definition in header file.<br>
ebrus 0:0a673c671a56 53 Function definitions in header files are used to allow 'inlining'.
ebrus 0:0a673c671a56 54
ebrus 0:0a673c671a56 55 \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
ebrus 0:0a673c671a56 56 Unions are used for effective representation of core registers.
ebrus 0:0a673c671a56 57
ebrus 0:0a673c671a56 58 \li Advisory Rule 19.7, Function-like macro defined.<br>
ebrus 0:0a673c671a56 59 Function-like macros are used to allow more efficient code.
ebrus 0:0a673c671a56 60 */
ebrus 0:0a673c671a56 61
ebrus 0:0a673c671a56 62
ebrus 0:0a673c671a56 63 /*******************************************************************************
ebrus 0:0a673c671a56 64 * CMSIS definitions
ebrus 0:0a673c671a56 65 ******************************************************************************/
ebrus 0:0a673c671a56 66 /** \ingroup Cortex_M0
ebrus 0:0a673c671a56 67 @{
ebrus 0:0a673c671a56 68 */
ebrus 0:0a673c671a56 69
ebrus 0:0a673c671a56 70 /* CMSIS CM0 definitions */
ebrus 0:0a673c671a56 71 #define __CM0_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
ebrus 0:0a673c671a56 72 #define __CM0_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
ebrus 0:0a673c671a56 73 #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16) | \
ebrus 0:0a673c671a56 74 __CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
ebrus 0:0a673c671a56 75
ebrus 0:0a673c671a56 76 #define __CORTEX_M (0x00) /*!< Cortex-M Core */
ebrus 0:0a673c671a56 77
ebrus 0:0a673c671a56 78
ebrus 0:0a673c671a56 79 #if defined ( __CC_ARM )
ebrus 0:0a673c671a56 80 #define __ASM __asm /*!< asm keyword for ARM Compiler */
ebrus 0:0a673c671a56 81 #define __INLINE __inline /*!< inline keyword for ARM Compiler */
ebrus 0:0a673c671a56 82 #define __STATIC_INLINE static __inline
ebrus 0:0a673c671a56 83
ebrus 0:0a673c671a56 84 #elif defined ( __ICCARM__ )
ebrus 0:0a673c671a56 85 #define __ASM __asm /*!< asm keyword for IAR Compiler */
ebrus 0:0a673c671a56 86 #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
ebrus 0:0a673c671a56 87 #define __STATIC_INLINE static inline
ebrus 0:0a673c671a56 88
ebrus 0:0a673c671a56 89 #elif defined ( __GNUC__ )
ebrus 0:0a673c671a56 90 #define __ASM __asm /*!< asm keyword for GNU Compiler */
ebrus 0:0a673c671a56 91 #define __INLINE inline /*!< inline keyword for GNU Compiler */
ebrus 0:0a673c671a56 92 #define __STATIC_INLINE static inline
ebrus 0:0a673c671a56 93
ebrus 0:0a673c671a56 94 #elif defined ( __TASKING__ )
ebrus 0:0a673c671a56 95 #define __ASM __asm /*!< asm keyword for TASKING Compiler */
ebrus 0:0a673c671a56 96 #define __INLINE inline /*!< inline keyword for TASKING Compiler */
ebrus 0:0a673c671a56 97 #define __STATIC_INLINE static inline
ebrus 0:0a673c671a56 98
ebrus 0:0a673c671a56 99 #endif
ebrus 0:0a673c671a56 100
ebrus 0:0a673c671a56 101 /** __FPU_USED indicates whether an FPU is used or not. This core does not support an FPU at all
ebrus 0:0a673c671a56 102 */
ebrus 0:0a673c671a56 103 #define __FPU_USED 0
ebrus 0:0a673c671a56 104
ebrus 0:0a673c671a56 105 #if defined ( __CC_ARM )
ebrus 0:0a673c671a56 106 #if defined __TARGET_FPU_VFP
ebrus 0:0a673c671a56 107 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
ebrus 0:0a673c671a56 108 #endif
ebrus 0:0a673c671a56 109
ebrus 0:0a673c671a56 110 #elif defined ( __ICCARM__ )
ebrus 0:0a673c671a56 111 #if defined __ARMVFP__
ebrus 0:0a673c671a56 112 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
ebrus 0:0a673c671a56 113 #endif
ebrus 0:0a673c671a56 114
ebrus 0:0a673c671a56 115 #elif defined ( __GNUC__ )
ebrus 0:0a673c671a56 116 #if defined (__VFP_FP__) && !defined(__SOFTFP__)
ebrus 0:0a673c671a56 117 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
ebrus 0:0a673c671a56 118 #endif
ebrus 0:0a673c671a56 119
ebrus 0:0a673c671a56 120 #elif defined ( __TASKING__ )
ebrus 0:0a673c671a56 121 #if defined __FPU_VFP__
ebrus 0:0a673c671a56 122 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
ebrus 0:0a673c671a56 123 #endif
ebrus 0:0a673c671a56 124 #endif
ebrus 0:0a673c671a56 125
ebrus 0:0a673c671a56 126 #include <stdint.h> /* standard types definitions */
ebrus 0:0a673c671a56 127 #include <core_cmInstr.h> /* Core Instruction Access */
ebrus 0:0a673c671a56 128 #include <core_cmFunc.h> /* Core Function Access */
ebrus 0:0a673c671a56 129
ebrus 0:0a673c671a56 130 #endif /* __CORE_CM0_H_GENERIC */
ebrus 0:0a673c671a56 131
ebrus 0:0a673c671a56 132 #ifndef __CMSIS_GENERIC
ebrus 0:0a673c671a56 133
ebrus 0:0a673c671a56 134 #ifndef __CORE_CM0_H_DEPENDANT
ebrus 0:0a673c671a56 135 #define __CORE_CM0_H_DEPENDANT
ebrus 0:0a673c671a56 136
ebrus 0:0a673c671a56 137 /* check device defines and use defaults */
ebrus 0:0a673c671a56 138 #if defined __CHECK_DEVICE_DEFINES
ebrus 0:0a673c671a56 139 #ifndef __CM0_REV
ebrus 0:0a673c671a56 140 #define __CM0_REV 0x0000
ebrus 0:0a673c671a56 141 #warning "__CM0_REV not defined in device header file; using default!"
ebrus 0:0a673c671a56 142 #endif
ebrus 0:0a673c671a56 143
ebrus 0:0a673c671a56 144 #ifndef __NVIC_PRIO_BITS
ebrus 0:0a673c671a56 145 #define __NVIC_PRIO_BITS 2
ebrus 0:0a673c671a56 146 #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
ebrus 0:0a673c671a56 147 #endif
ebrus 0:0a673c671a56 148
ebrus 0:0a673c671a56 149 #ifndef __Vendor_SysTickConfig
ebrus 0:0a673c671a56 150 #define __Vendor_SysTickConfig 0
ebrus 0:0a673c671a56 151 #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
ebrus 0:0a673c671a56 152 #endif
ebrus 0:0a673c671a56 153 #endif
ebrus 0:0a673c671a56 154
ebrus 0:0a673c671a56 155 /* IO definitions (access restrictions to peripheral registers) */
ebrus 0:0a673c671a56 156 /**
ebrus 0:0a673c671a56 157 \defgroup CMSIS_glob_defs CMSIS Global Defines
ebrus 0:0a673c671a56 158
ebrus 0:0a673c671a56 159 <strong>IO Type Qualifiers</strong> are used
ebrus 0:0a673c671a56 160 \li to specify the access to peripheral variables.
ebrus 0:0a673c671a56 161 \li for automatic generation of peripheral register debug information.
ebrus 0:0a673c671a56 162 */
ebrus 0:0a673c671a56 163 #ifdef __cplusplus
ebrus 0:0a673c671a56 164 #define __I volatile /*!< Defines 'read only' permissions */
ebrus 0:0a673c671a56 165 #else
ebrus 0:0a673c671a56 166 #define __I volatile const /*!< Defines 'read only' permissions */
ebrus 0:0a673c671a56 167 #endif
ebrus 0:0a673c671a56 168 #define __O volatile /*!< Defines 'write only' permissions */
ebrus 0:0a673c671a56 169 #define __IO volatile /*!< Defines 'read / write' permissions */
ebrus 0:0a673c671a56 170
ebrus 0:0a673c671a56 171 /*@} end of group Cortex_M0 */
ebrus 0:0a673c671a56 172
ebrus 0:0a673c671a56 173
ebrus 0:0a673c671a56 174
ebrus 0:0a673c671a56 175 /*******************************************************************************
ebrus 0:0a673c671a56 176 * Register Abstraction
ebrus 0:0a673c671a56 177 Core Register contain:
ebrus 0:0a673c671a56 178 - Core Register
ebrus 0:0a673c671a56 179 - Core NVIC Register
ebrus 0:0a673c671a56 180 - Core SCB Register
ebrus 0:0a673c671a56 181 - Core SysTick Register
ebrus 0:0a673c671a56 182 ******************************************************************************/
ebrus 0:0a673c671a56 183 /** \defgroup CMSIS_core_register Defines and Type Definitions
ebrus 0:0a673c671a56 184 \brief Type definitions and defines for Cortex-M processor based devices.
ebrus 0:0a673c671a56 185 */
ebrus 0:0a673c671a56 186
ebrus 0:0a673c671a56 187 /** \ingroup CMSIS_core_register
ebrus 0:0a673c671a56 188 \defgroup CMSIS_CORE Status and Control Registers
ebrus 0:0a673c671a56 189 \brief Core Register type definitions.
ebrus 0:0a673c671a56 190 @{
ebrus 0:0a673c671a56 191 */
ebrus 0:0a673c671a56 192
ebrus 0:0a673c671a56 193 /** \brief Union type to access the Application Program Status Register (APSR).
ebrus 0:0a673c671a56 194 */
ebrus 0:0a673c671a56 195 typedef union
ebrus 0:0a673c671a56 196 {
ebrus 0:0a673c671a56 197 struct
ebrus 0:0a673c671a56 198 {
ebrus 0:0a673c671a56 199 #if (__CORTEX_M != 0x04)
ebrus 0:0a673c671a56 200 uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */
ebrus 0:0a673c671a56 201 #else
ebrus 0:0a673c671a56 202 uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
ebrus 0:0a673c671a56 203 uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
ebrus 0:0a673c671a56 204 uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
ebrus 0:0a673c671a56 205 #endif
ebrus 0:0a673c671a56 206 uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
ebrus 0:0a673c671a56 207 uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
ebrus 0:0a673c671a56 208 uint32_t C:1; /*!< bit: 29 Carry condition code flag */
ebrus 0:0a673c671a56 209 uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
ebrus 0:0a673c671a56 210 uint32_t N:1; /*!< bit: 31 Negative condition code flag */
ebrus 0:0a673c671a56 211 } b; /*!< Structure used for bit access */
ebrus 0:0a673c671a56 212 uint32_t w; /*!< Type used for word access */
ebrus 0:0a673c671a56 213 } APSR_Type;
ebrus 0:0a673c671a56 214
ebrus 0:0a673c671a56 215
ebrus 0:0a673c671a56 216 /** \brief Union type to access the Interrupt Program Status Register (IPSR).
ebrus 0:0a673c671a56 217 */
ebrus 0:0a673c671a56 218 typedef union
ebrus 0:0a673c671a56 219 {
ebrus 0:0a673c671a56 220 struct
ebrus 0:0a673c671a56 221 {
ebrus 0:0a673c671a56 222 uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
ebrus 0:0a673c671a56 223 uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
ebrus 0:0a673c671a56 224 } b; /*!< Structure used for bit access */
ebrus 0:0a673c671a56 225 uint32_t w; /*!< Type used for word access */
ebrus 0:0a673c671a56 226 } IPSR_Type;
ebrus 0:0a673c671a56 227
ebrus 0:0a673c671a56 228
ebrus 0:0a673c671a56 229 /** \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
ebrus 0:0a673c671a56 230 */
ebrus 0:0a673c671a56 231 typedef union
ebrus 0:0a673c671a56 232 {
ebrus 0:0a673c671a56 233 struct
ebrus 0:0a673c671a56 234 {
ebrus 0:0a673c671a56 235 uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
ebrus 0:0a673c671a56 236 #if (__CORTEX_M != 0x04)
ebrus 0:0a673c671a56 237 uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
ebrus 0:0a673c671a56 238 #else
ebrus 0:0a673c671a56 239 uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */
ebrus 0:0a673c671a56 240 uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
ebrus 0:0a673c671a56 241 uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
ebrus 0:0a673c671a56 242 #endif
ebrus 0:0a673c671a56 243 uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
ebrus 0:0a673c671a56 244 uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */
ebrus 0:0a673c671a56 245 uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
ebrus 0:0a673c671a56 246 uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
ebrus 0:0a673c671a56 247 uint32_t C:1; /*!< bit: 29 Carry condition code flag */
ebrus 0:0a673c671a56 248 uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
ebrus 0:0a673c671a56 249 uint32_t N:1; /*!< bit: 31 Negative condition code flag */
ebrus 0:0a673c671a56 250 } b; /*!< Structure used for bit access */
ebrus 0:0a673c671a56 251 uint32_t w; /*!< Type used for word access */
ebrus 0:0a673c671a56 252 } xPSR_Type;
ebrus 0:0a673c671a56 253
ebrus 0:0a673c671a56 254
ebrus 0:0a673c671a56 255 /** \brief Union type to access the Control Registers (CONTROL).
ebrus 0:0a673c671a56 256 */
ebrus 0:0a673c671a56 257 typedef union
ebrus 0:0a673c671a56 258 {
ebrus 0:0a673c671a56 259 struct
ebrus 0:0a673c671a56 260 {
ebrus 0:0a673c671a56 261 uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
ebrus 0:0a673c671a56 262 uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
ebrus 0:0a673c671a56 263 uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
ebrus 0:0a673c671a56 264 uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
ebrus 0:0a673c671a56 265 } b; /*!< Structure used for bit access */
ebrus 0:0a673c671a56 266 uint32_t w; /*!< Type used for word access */
ebrus 0:0a673c671a56 267 } CONTROL_Type;
ebrus 0:0a673c671a56 268
ebrus 0:0a673c671a56 269 /*@} end of group CMSIS_CORE */
ebrus 0:0a673c671a56 270
ebrus 0:0a673c671a56 271
ebrus 0:0a673c671a56 272 /** \ingroup CMSIS_core_register
ebrus 0:0a673c671a56 273 \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
ebrus 0:0a673c671a56 274 \brief Type definitions for the NVIC Registers
ebrus 0:0a673c671a56 275 @{
ebrus 0:0a673c671a56 276 */
ebrus 0:0a673c671a56 277
ebrus 0:0a673c671a56 278 /** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
ebrus 0:0a673c671a56 279 */
ebrus 0:0a673c671a56 280 typedef struct
ebrus 0:0a673c671a56 281 {
ebrus 0:0a673c671a56 282 __IO uint32_t ISER[1]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
ebrus 0:0a673c671a56 283 uint32_t RESERVED0[31];
ebrus 0:0a673c671a56 284 __IO uint32_t ICER[1]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
ebrus 0:0a673c671a56 285 uint32_t RSERVED1[31];
ebrus 0:0a673c671a56 286 __IO uint32_t ISPR[1]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
ebrus 0:0a673c671a56 287 uint32_t RESERVED2[31];
ebrus 0:0a673c671a56 288 __IO uint32_t ICPR[1]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
ebrus 0:0a673c671a56 289 uint32_t RESERVED3[31];
ebrus 0:0a673c671a56 290 uint32_t RESERVED4[64];
ebrus 0:0a673c671a56 291 __IO uint32_t IP[8]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
ebrus 0:0a673c671a56 292 } NVIC_Type;
ebrus 0:0a673c671a56 293
ebrus 0:0a673c671a56 294 /*@} end of group CMSIS_NVIC */
ebrus 0:0a673c671a56 295
ebrus 0:0a673c671a56 296
ebrus 0:0a673c671a56 297 /** \ingroup CMSIS_core_register
ebrus 0:0a673c671a56 298 \defgroup CMSIS_SCB System Control Block (SCB)
ebrus 0:0a673c671a56 299 \brief Type definitions for the System Control Block Registers
ebrus 0:0a673c671a56 300 @{
ebrus 0:0a673c671a56 301 */
ebrus 0:0a673c671a56 302
ebrus 0:0a673c671a56 303 /** \brief Structure type to access the System Control Block (SCB).
ebrus 0:0a673c671a56 304 */
ebrus 0:0a673c671a56 305 typedef struct
ebrus 0:0a673c671a56 306 {
ebrus 0:0a673c671a56 307 __I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
ebrus 0:0a673c671a56 308 __IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
ebrus 0:0a673c671a56 309 uint32_t RESERVED0;
ebrus 0:0a673c671a56 310 __IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
ebrus 0:0a673c671a56 311 __IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
ebrus 0:0a673c671a56 312 __IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
ebrus 0:0a673c671a56 313 uint32_t RESERVED1;
ebrus 0:0a673c671a56 314 __IO uint32_t SHP[2]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
ebrus 0:0a673c671a56 315 __IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
ebrus 0:0a673c671a56 316 } SCB_Type;
ebrus 0:0a673c671a56 317
ebrus 0:0a673c671a56 318 /* SCB CPUID Register Definitions */
ebrus 0:0a673c671a56 319 #define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
ebrus 0:0a673c671a56 320 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
ebrus 0:0a673c671a56 321
ebrus 0:0a673c671a56 322 #define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
ebrus 0:0a673c671a56 323 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
ebrus 0:0a673c671a56 324
ebrus 0:0a673c671a56 325 #define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */
ebrus 0:0a673c671a56 326 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
ebrus 0:0a673c671a56 327
ebrus 0:0a673c671a56 328 #define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
ebrus 0:0a673c671a56 329 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
ebrus 0:0a673c671a56 330
ebrus 0:0a673c671a56 331 #define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
ebrus 0:0a673c671a56 332 #define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
ebrus 0:0a673c671a56 333
ebrus 0:0a673c671a56 334 /* SCB Interrupt Control State Register Definitions */
ebrus 0:0a673c671a56 335 #define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
ebrus 0:0a673c671a56 336 #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
ebrus 0:0a673c671a56 337
ebrus 0:0a673c671a56 338 #define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
ebrus 0:0a673c671a56 339 #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
ebrus 0:0a673c671a56 340
ebrus 0:0a673c671a56 341 #define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
ebrus 0:0a673c671a56 342 #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
ebrus 0:0a673c671a56 343
ebrus 0:0a673c671a56 344 #define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
ebrus 0:0a673c671a56 345 #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
ebrus 0:0a673c671a56 346
ebrus 0:0a673c671a56 347 #define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
ebrus 0:0a673c671a56 348 #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
ebrus 0:0a673c671a56 349
ebrus 0:0a673c671a56 350 #define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
ebrus 0:0a673c671a56 351 #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
ebrus 0:0a673c671a56 352
ebrus 0:0a673c671a56 353 #define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
ebrus 0:0a673c671a56 354 #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
ebrus 0:0a673c671a56 355
ebrus 0:0a673c671a56 356 #define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
ebrus 0:0a673c671a56 357 #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
ebrus 0:0a673c671a56 358
ebrus 0:0a673c671a56 359 #define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
ebrus 0:0a673c671a56 360 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
ebrus 0:0a673c671a56 361
ebrus 0:0a673c671a56 362 /* SCB Application Interrupt and Reset Control Register Definitions */
ebrus 0:0a673c671a56 363 #define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
ebrus 0:0a673c671a56 364 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
ebrus 0:0a673c671a56 365
ebrus 0:0a673c671a56 366 #define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
ebrus 0:0a673c671a56 367 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
ebrus 0:0a673c671a56 368
ebrus 0:0a673c671a56 369 #define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
ebrus 0:0a673c671a56 370 #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
ebrus 0:0a673c671a56 371
ebrus 0:0a673c671a56 372 #define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
ebrus 0:0a673c671a56 373 #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
ebrus 0:0a673c671a56 374
ebrus 0:0a673c671a56 375 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
ebrus 0:0a673c671a56 376 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
ebrus 0:0a673c671a56 377
ebrus 0:0a673c671a56 378 /* SCB System Control Register Definitions */
ebrus 0:0a673c671a56 379 #define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
ebrus 0:0a673c671a56 380 #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
ebrus 0:0a673c671a56 381
ebrus 0:0a673c671a56 382 #define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
ebrus 0:0a673c671a56 383 #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
ebrus 0:0a673c671a56 384
ebrus 0:0a673c671a56 385 #define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
ebrus 0:0a673c671a56 386 #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
ebrus 0:0a673c671a56 387
ebrus 0:0a673c671a56 388 /* SCB Configuration Control Register Definitions */
ebrus 0:0a673c671a56 389 #define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
ebrus 0:0a673c671a56 390 #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
ebrus 0:0a673c671a56 391
ebrus 0:0a673c671a56 392 #define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
ebrus 0:0a673c671a56 393 #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
ebrus 0:0a673c671a56 394
ebrus 0:0a673c671a56 395 /* SCB System Handler Control and State Register Definitions */
ebrus 0:0a673c671a56 396 #define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
ebrus 0:0a673c671a56 397 #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
ebrus 0:0a673c671a56 398
ebrus 0:0a673c671a56 399 /*@} end of group CMSIS_SCB */
ebrus 0:0a673c671a56 400
ebrus 0:0a673c671a56 401
ebrus 0:0a673c671a56 402 /** \ingroup CMSIS_core_register
ebrus 0:0a673c671a56 403 \defgroup CMSIS_SysTick System Tick Timer (SysTick)
ebrus 0:0a673c671a56 404 \brief Type definitions for the System Timer Registers.
ebrus 0:0a673c671a56 405 @{
ebrus 0:0a673c671a56 406 */
ebrus 0:0a673c671a56 407
ebrus 0:0a673c671a56 408 /** \brief Structure type to access the System Timer (SysTick).
ebrus 0:0a673c671a56 409 */
ebrus 0:0a673c671a56 410 typedef struct
ebrus 0:0a673c671a56 411 {
ebrus 0:0a673c671a56 412 __IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
ebrus 0:0a673c671a56 413 __IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
ebrus 0:0a673c671a56 414 __IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
ebrus 0:0a673c671a56 415 __I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
ebrus 0:0a673c671a56 416 } SysTick_Type;
ebrus 0:0a673c671a56 417
ebrus 0:0a673c671a56 418 /* SysTick Control / Status Register Definitions */
ebrus 0:0a673c671a56 419 #define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
ebrus 0:0a673c671a56 420 #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
ebrus 0:0a673c671a56 421
ebrus 0:0a673c671a56 422 #define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
ebrus 0:0a673c671a56 423 #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
ebrus 0:0a673c671a56 424
ebrus 0:0a673c671a56 425 #define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
ebrus 0:0a673c671a56 426 #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
ebrus 0:0a673c671a56 427
ebrus 0:0a673c671a56 428 #define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
ebrus 0:0a673c671a56 429 #define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
ebrus 0:0a673c671a56 430
ebrus 0:0a673c671a56 431 /* SysTick Reload Register Definitions */
ebrus 0:0a673c671a56 432 #define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
ebrus 0:0a673c671a56 433 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
ebrus 0:0a673c671a56 434
ebrus 0:0a673c671a56 435 /* SysTick Current Register Definitions */
ebrus 0:0a673c671a56 436 #define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
ebrus 0:0a673c671a56 437 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
ebrus 0:0a673c671a56 438
ebrus 0:0a673c671a56 439 /* SysTick Calibration Register Definitions */
ebrus 0:0a673c671a56 440 #define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
ebrus 0:0a673c671a56 441 #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
ebrus 0:0a673c671a56 442
ebrus 0:0a673c671a56 443 #define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
ebrus 0:0a673c671a56 444 #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
ebrus 0:0a673c671a56 445
ebrus 0:0a673c671a56 446 #define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
ebrus 0:0a673c671a56 447 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */
ebrus 0:0a673c671a56 448
ebrus 0:0a673c671a56 449 /*@} end of group CMSIS_SysTick */
ebrus 0:0a673c671a56 450
ebrus 0:0a673c671a56 451
ebrus 0:0a673c671a56 452 /** \ingroup CMSIS_core_register
ebrus 0:0a673c671a56 453 \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
ebrus 0:0a673c671a56 454 \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR)
ebrus 0:0a673c671a56 455 are only accessible over DAP and not via processor. Therefore
ebrus 0:0a673c671a56 456 they are not covered by the Cortex-M0 header file.
ebrus 0:0a673c671a56 457 @{
ebrus 0:0a673c671a56 458 */
ebrus 0:0a673c671a56 459 /*@} end of group CMSIS_CoreDebug */
ebrus 0:0a673c671a56 460
ebrus 0:0a673c671a56 461
ebrus 0:0a673c671a56 462 /** \ingroup CMSIS_core_register
ebrus 0:0a673c671a56 463 \defgroup CMSIS_core_base Core Definitions
ebrus 0:0a673c671a56 464 \brief Definitions for base addresses, unions, and structures.
ebrus 0:0a673c671a56 465 @{
ebrus 0:0a673c671a56 466 */
ebrus 0:0a673c671a56 467
ebrus 0:0a673c671a56 468 /* Memory mapping of Cortex-M0 Hardware */
ebrus 0:0a673c671a56 469 #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
ebrus 0:0a673c671a56 470 #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
ebrus 0:0a673c671a56 471 #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
ebrus 0:0a673c671a56 472 #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
ebrus 0:0a673c671a56 473
ebrus 0:0a673c671a56 474 #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
ebrus 0:0a673c671a56 475 #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
ebrus 0:0a673c671a56 476 #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
ebrus 0:0a673c671a56 477
ebrus 0:0a673c671a56 478
ebrus 0:0a673c671a56 479 /*@} */
ebrus 0:0a673c671a56 480
ebrus 0:0a673c671a56 481
ebrus 0:0a673c671a56 482
ebrus 0:0a673c671a56 483 /*******************************************************************************
ebrus 0:0a673c671a56 484 * Hardware Abstraction Layer
ebrus 0:0a673c671a56 485 Core Function Interface contains:
ebrus 0:0a673c671a56 486 - Core NVIC Functions
ebrus 0:0a673c671a56 487 - Core SysTick Functions
ebrus 0:0a673c671a56 488 - Core Register Access Functions
ebrus 0:0a673c671a56 489 ******************************************************************************/
ebrus 0:0a673c671a56 490 /** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
ebrus 0:0a673c671a56 491 */
ebrus 0:0a673c671a56 492
ebrus 0:0a673c671a56 493
ebrus 0:0a673c671a56 494
ebrus 0:0a673c671a56 495 /* ########################## NVIC functions #################################### */
ebrus 0:0a673c671a56 496 /** \ingroup CMSIS_Core_FunctionInterface
ebrus 0:0a673c671a56 497 \defgroup CMSIS_Core_NVICFunctions NVIC Functions
ebrus 0:0a673c671a56 498 \brief Functions that manage interrupts and exceptions via the NVIC.
ebrus 0:0a673c671a56 499 @{
ebrus 0:0a673c671a56 500 */
ebrus 0:0a673c671a56 501
ebrus 0:0a673c671a56 502 /* Interrupt Priorities are WORD accessible only under ARMv6M */
ebrus 0:0a673c671a56 503 /* The following MACROS handle generation of the register offset and byte masks */
ebrus 0:0a673c671a56 504 #define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 )
ebrus 0:0a673c671a56 505 #define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )
ebrus 0:0a673c671a56 506 #define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) )
ebrus 0:0a673c671a56 507
ebrus 0:0a673c671a56 508
ebrus 0:0a673c671a56 509 /** \brief Enable External Interrupt
ebrus 0:0a673c671a56 510
ebrus 0:0a673c671a56 511 The function enables a device-specific interrupt in the NVIC interrupt controller.
ebrus 0:0a673c671a56 512
ebrus 0:0a673c671a56 513 \param [in] IRQn External interrupt number. Value cannot be negative.
ebrus 0:0a673c671a56 514 */
ebrus 0:0a673c671a56 515 __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
ebrus 0:0a673c671a56 516 {
ebrus 0:0a673c671a56 517 NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
ebrus 0:0a673c671a56 518 }
ebrus 0:0a673c671a56 519
ebrus 0:0a673c671a56 520
ebrus 0:0a673c671a56 521 /** \brief Disable External Interrupt
ebrus 0:0a673c671a56 522
ebrus 0:0a673c671a56 523 The function disables a device-specific interrupt in the NVIC interrupt controller.
ebrus 0:0a673c671a56 524
ebrus 0:0a673c671a56 525 \param [in] IRQn External interrupt number. Value cannot be negative.
ebrus 0:0a673c671a56 526 */
ebrus 0:0a673c671a56 527 __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
ebrus 0:0a673c671a56 528 {
ebrus 0:0a673c671a56 529 NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
ebrus 0:0a673c671a56 530 }
ebrus 0:0a673c671a56 531
ebrus 0:0a673c671a56 532
ebrus 0:0a673c671a56 533 /** \brief Get Pending Interrupt
ebrus 0:0a673c671a56 534
ebrus 0:0a673c671a56 535 The function reads the pending register in the NVIC and returns the pending bit
ebrus 0:0a673c671a56 536 for the specified interrupt.
ebrus 0:0a673c671a56 537
ebrus 0:0a673c671a56 538 \param [in] IRQn Interrupt number.
ebrus 0:0a673c671a56 539
ebrus 0:0a673c671a56 540 \return 0 Interrupt status is not pending.
ebrus 0:0a673c671a56 541 \return 1 Interrupt status is pending.
ebrus 0:0a673c671a56 542 */
ebrus 0:0a673c671a56 543 __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
ebrus 0:0a673c671a56 544 {
ebrus 0:0a673c671a56 545 return((uint32_t) ((NVIC->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
ebrus 0:0a673c671a56 546 }
ebrus 0:0a673c671a56 547
ebrus 0:0a673c671a56 548
ebrus 0:0a673c671a56 549 /** \brief Set Pending Interrupt
ebrus 0:0a673c671a56 550
ebrus 0:0a673c671a56 551 The function sets the pending bit of an external interrupt.
ebrus 0:0a673c671a56 552
ebrus 0:0a673c671a56 553 \param [in] IRQn Interrupt number. Value cannot be negative.
ebrus 0:0a673c671a56 554 */
ebrus 0:0a673c671a56 555 __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
ebrus 0:0a673c671a56 556 {
ebrus 0:0a673c671a56 557 NVIC->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
ebrus 0:0a673c671a56 558 }
ebrus 0:0a673c671a56 559
ebrus 0:0a673c671a56 560
ebrus 0:0a673c671a56 561 /** \brief Clear Pending Interrupt
ebrus 0:0a673c671a56 562
ebrus 0:0a673c671a56 563 The function clears the pending bit of an external interrupt.
ebrus 0:0a673c671a56 564
ebrus 0:0a673c671a56 565 \param [in] IRQn External interrupt number. Value cannot be negative.
ebrus 0:0a673c671a56 566 */
ebrus 0:0a673c671a56 567 __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
ebrus 0:0a673c671a56 568 {
ebrus 0:0a673c671a56 569 NVIC->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
ebrus 0:0a673c671a56 570 }
ebrus 0:0a673c671a56 571
ebrus 0:0a673c671a56 572
ebrus 0:0a673c671a56 573 /** \brief Set Interrupt Priority
ebrus 0:0a673c671a56 574
ebrus 0:0a673c671a56 575 The function sets the priority of an interrupt.
ebrus 0:0a673c671a56 576
ebrus 0:0a673c671a56 577 \note The priority cannot be set for every core interrupt.
ebrus 0:0a673c671a56 578
ebrus 0:0a673c671a56 579 \param [in] IRQn Interrupt number.
ebrus 0:0a673c671a56 580 \param [in] priority Priority to set.
ebrus 0:0a673c671a56 581 */
ebrus 0:0a673c671a56 582 __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
ebrus 0:0a673c671a56 583 {
ebrus 0:0a673c671a56 584 if(IRQn < 0) {
ebrus 0:0a673c671a56 585 SCB->SHP[_SHP_IDX(IRQn)] = (SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
ebrus 0:0a673c671a56 586 (((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
ebrus 0:0a673c671a56 587 else {
ebrus 0:0a673c671a56 588 NVIC->IP[_IP_IDX(IRQn)] = (NVIC->IP[_IP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
ebrus 0:0a673c671a56 589 (((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
ebrus 0:0a673c671a56 590 }
ebrus 0:0a673c671a56 591
ebrus 0:0a673c671a56 592
ebrus 0:0a673c671a56 593 /** \brief Get Interrupt Priority
ebrus 0:0a673c671a56 594
ebrus 0:0a673c671a56 595 The function reads the priority of an interrupt. The interrupt
ebrus 0:0a673c671a56 596 number can be positive to specify an external (device specific)
ebrus 0:0a673c671a56 597 interrupt, or negative to specify an internal (core) interrupt.
ebrus 0:0a673c671a56 598
ebrus 0:0a673c671a56 599
ebrus 0:0a673c671a56 600 \param [in] IRQn Interrupt number.
ebrus 0:0a673c671a56 601 \return Interrupt Priority. Value is aligned automatically to the implemented
ebrus 0:0a673c671a56 602 priority bits of the microcontroller.
ebrus 0:0a673c671a56 603 */
ebrus 0:0a673c671a56 604 __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
ebrus 0:0a673c671a56 605 {
ebrus 0:0a673c671a56 606
ebrus 0:0a673c671a56 607 if(IRQn < 0) {
ebrus 0:0a673c671a56 608 return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
ebrus 0:0a673c671a56 609 else {
ebrus 0:0a673c671a56 610 return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & 0xFF) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
ebrus 0:0a673c671a56 611 }
ebrus 0:0a673c671a56 612
ebrus 0:0a673c671a56 613
ebrus 0:0a673c671a56 614 /** \brief System Reset
ebrus 0:0a673c671a56 615
ebrus 0:0a673c671a56 616 The function initiates a system reset request to reset the MCU.
ebrus 0:0a673c671a56 617 */
ebrus 0:0a673c671a56 618 __STATIC_INLINE void NVIC_SystemReset(void)
ebrus 0:0a673c671a56 619 {
ebrus 0:0a673c671a56 620 __DSB(); /* Ensure all outstanding memory accesses included
ebrus 0:0a673c671a56 621 buffered write are completed before reset */
ebrus 0:0a673c671a56 622 SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
ebrus 0:0a673c671a56 623 SCB_AIRCR_SYSRESETREQ_Msk);
ebrus 0:0a673c671a56 624 __DSB(); /* Ensure completion of memory access */
ebrus 0:0a673c671a56 625 while(1); /* wait until reset */
ebrus 0:0a673c671a56 626 }
ebrus 0:0a673c671a56 627
ebrus 0:0a673c671a56 628 /*@} end of CMSIS_Core_NVICFunctions */
ebrus 0:0a673c671a56 629
ebrus 0:0a673c671a56 630
ebrus 0:0a673c671a56 631
ebrus 0:0a673c671a56 632 /* ################################## SysTick function ############################################ */
ebrus 0:0a673c671a56 633 /** \ingroup CMSIS_Core_FunctionInterface
ebrus 0:0a673c671a56 634 \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
ebrus 0:0a673c671a56 635 \brief Functions that configure the System.
ebrus 0:0a673c671a56 636 @{
ebrus 0:0a673c671a56 637 */
ebrus 0:0a673c671a56 638
ebrus 0:0a673c671a56 639 #if (__Vendor_SysTickConfig == 0)
ebrus 0:0a673c671a56 640
ebrus 0:0a673c671a56 641 /** \brief System Tick Configuration
ebrus 0:0a673c671a56 642
ebrus 0:0a673c671a56 643 The function initializes the System Timer and its interrupt, and starts the System Tick Timer.
ebrus 0:0a673c671a56 644 Counter is in free running mode to generate periodic interrupts.
ebrus 0:0a673c671a56 645
ebrus 0:0a673c671a56 646 \param [in] ticks Number of ticks between two interrupts.
ebrus 0:0a673c671a56 647
ebrus 0:0a673c671a56 648 \return 0 Function succeeded.
ebrus 0:0a673c671a56 649 \return 1 Function failed.
ebrus 0:0a673c671a56 650
ebrus 0:0a673c671a56 651 \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
ebrus 0:0a673c671a56 652 function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
ebrus 0:0a673c671a56 653 must contain a vendor-specific implementation of this function.
ebrus 0:0a673c671a56 654
ebrus 0:0a673c671a56 655 */
ebrus 0:0a673c671a56 656 __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
ebrus 0:0a673c671a56 657 {
ebrus 0:0a673c671a56 658 if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
ebrus 0:0a673c671a56 659
ebrus 0:0a673c671a56 660 SysTick->LOAD = ticks - 1; /* set reload register */
ebrus 0:0a673c671a56 661 NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
ebrus 0:0a673c671a56 662 SysTick->VAL = 0; /* Load the SysTick Counter Value */
ebrus 0:0a673c671a56 663 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
ebrus 0:0a673c671a56 664 SysTick_CTRL_TICKINT_Msk |
ebrus 0:0a673c671a56 665 SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
ebrus 0:0a673c671a56 666 return (0); /* Function successful */
ebrus 0:0a673c671a56 667 }
ebrus 0:0a673c671a56 668
ebrus 0:0a673c671a56 669 #endif
ebrus 0:0a673c671a56 670
ebrus 0:0a673c671a56 671 /*@} end of CMSIS_Core_SysTickFunctions */
ebrus 0:0a673c671a56 672
ebrus 0:0a673c671a56 673
ebrus 0:0a673c671a56 674
ebrus 0:0a673c671a56 675
ebrus 0:0a673c671a56 676 #endif /* __CORE_CM0_H_DEPENDANT */
ebrus 0:0a673c671a56 677
ebrus 0:0a673c671a56 678 #endif /* __CMSIS_GENERIC */
ebrus 0:0a673c671a56 679
ebrus 0:0a673c671a56 680 #ifdef __cplusplus
ebrus 0:0a673c671a56 681 }
ebrus 0:0a673c671a56 682 #endif