modtronix H / mbed_nz32sc151
Committer:
modtronix
Date:
Fri Jul 24 21:01:44 2015 +1000
Revision:
1:71204b8406f2
Child:
10:6444e6c798ce
Current mbed v103 (594)

Who changed what in which revision?

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