mbed-os

Fork of mbed-os by erkin yucel

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

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