This is a repository for all my programs or modified programs.

Committer:
mturner5
Date:
Sun Sep 11 23:48:09 2016 +0000
Revision:
0:72480818e4a9
Made delays for the LEDS and button presses

Who changed what in which revision?

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