test

Dependents:   robotic_fish_6

Committer:
juansal12
Date:
Fri Dec 03 23:00:34 2021 +0000
Revision:
0:c792b17d9f78
uploaded sofi code ;

Who changed what in which revision?

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