Binary version of Lancaster University's mbed branch, soon to be merged. The source lives here:https://developer.mbed.org/teams/Lancaster-University/code/mbed-src/

Dependents:   microbit-dal microbit-ble-open microbit-dal-eddystone microbit-dal ... more

Fork of mbed-lite-test by Lancaster University

Committer:
jamesadevine
Date:
Wed Jul 13 15:12:06 2016 +0100
Revision:
3:768173a57492
Parent:
0:e1a608bb55e8
further updates to mbed-dev-bin

Who changed what in which revision?

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