1 /**************************************************************************//**
\r
3 * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
\r
5 * @date 02. March 2016
\r
6 ******************************************************************************/
\r
8 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
\r
10 * SPDX-License-Identifier: Apache-2.0
\r
12 * Licensed under the Apache License, Version 2.0 (the License); you may
\r
13 * not use this file except in compliance with the License.
\r
14 * You may obtain a copy of the License at
\r
16 * http://www.apache.org/licenses/LICENSE-2.0
\r
18 * Unless required by applicable law or agreed to in writing, software
\r
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
\r
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
21 * See the License for the specific language governing permissions and
\r
22 * limitations under the License.
\r
25 #if defined ( __ICCARM__ )
\r
26 #pragma system_include /* treat file as system include file for MISRA check */
\r
27 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
\r
28 #pragma clang system_header /* treat file as system include file */
\r
31 #ifndef __CORE_CM0_H_GENERIC
\r
32 #define __CORE_CM0_H_GENERIC
\r
41 \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
\r
42 CMSIS violates the following MISRA-C:2004 rules:
\r
44 \li Required Rule 8.5, object/function definition in header file.<br>
\r
45 Function definitions in header files are used to allow 'inlining'.
\r
47 \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
\r
48 Unions are used for effective representation of core registers.
\r
50 \li Advisory Rule 19.7, Function-like macro defined.<br>
\r
51 Function-like macros are used to allow more efficient code.
\r
55 /*******************************************************************************
\r
57 ******************************************************************************/
\r
63 /* CMSIS CM0 definitions */
\r
64 #define __CM0_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS HAL main version */
\r
65 #define __CM0_CMSIS_VERSION_SUB ( 0U) /*!< [15:0] CMSIS HAL sub version */
\r
66 #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
\r
67 __CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
\r
69 #define __CORTEX_M (0U) /*!< Cortex-M Core */
\r
71 /* Common defines in core_*.h files
\r
72 - #define __ASM Compiler keyword for asm
\r
73 - #define __INLINE Compiler keyword for inline
\r
74 - #define __STATIC_INLINE Compiler keyword for static inline
\r
75 - #define __NO_RETURN function that never returns
\r
76 - #define __USED function or variable that is not optimized away
\r
77 - #define __WEAK weak function or variable
\r
78 - #define __UNALIGNED_UINT32 pointer to unaligned uint32_t variable
\r
80 #if defined ( __CC_ARM ) /* ARM Compiler 4/5 */
\r
82 #define __INLINE __inline
\r
83 #define __STATIC_INLINE static __inline
\r
84 #define __NO_RETURN __declspec(noreturn)
\r
85 #define __USED __attribute__((used))
\r
86 #define __WEAK __attribute__((weak))
\r
87 #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
\r
89 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler 6 */
\r
91 #define __INLINE __inline
\r
92 #define __STATIC_INLINE static __inline
\r
93 #define __NO_RETURN __attribute__((noreturn))
\r
94 #define __USED __attribute__((used))
\r
95 #define __WEAK __attribute__((weak))
\r
96 #pragma clang diagnostic push
\r
97 #pragma clang diagnostic ignored "-Wpacked"
\r
98 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
\r
99 #pragma clang diagnostic pop
\r
100 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
102 #elif defined ( __GNUC__ ) /* GNU Compiler */
\r
103 #define __ASM __asm
\r
104 #define __INLINE inline
\r
105 #define __STATIC_INLINE static inline
\r
106 #define __NO_RETURN __attribute__((noreturn))
\r
107 #define __USED __attribute__((used))
\r
108 #define __WEAK __attribute__((weak))
\r
109 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
\r
110 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
112 #elif defined ( __ICCARM__ ) /* IAR Compiler */
\r
113 #define __ASM __asm
\r
114 #define __INLINE inline
\r
115 #define __STATIC_INLINE static inline
\r
116 #define __NO_RETURN __noreturn
\r
118 #define __WEAK __weak
\r
119 struct __packed T_UINT32 { uint32_t v; };
\r
120 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
122 #elif defined ( __TI_ARM__ ) /* TI ARM Compiler */
\r
123 #define __ASM __asm
\r
124 #define __INLINE inline
\r
125 #define __STATIC_INLINE static inline
\r
126 #define __NO_RETURN __attribute__((noreturn))
\r
127 #define __USED __attribute__((used))
\r
128 #define __WEAK __attribute__((weak))
\r
129 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
\r
130 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
132 #elif defined ( __TASKING__ ) /* TASKING Compiler */
\r
133 #define __ASM __asm
\r
134 #define __INLINE inline
\r
135 #define __STATIC_INLINE static inline
\r
136 #define __NO_RETURN __attribute__((noreturn))
\r
137 #define __USED __attribute__((used))
\r
138 #define __WEAK __attribute__((weak))
\r
139 struct __packed__ T_UINT32 { uint32_t v; };
\r
140 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
\r
142 #elif defined ( __CSMC__ ) /* COSMIC Compiler */
\r
145 #define __INLINE inline
\r
146 #define __STATIC_INLINE static inline
\r
147 #define __NO_RETURN
\r
150 #define __UNALIGNED_UINT32(x) (*x)
\r
153 #error Unknown compiler
\r
156 /** __FPU_USED indicates whether an FPU is used or not.
\r
157 This core does not support an FPU at all
\r
159 #define __FPU_USED 0U
\r
161 #if defined ( __CC_ARM )
\r
162 #if defined __TARGET_FPU_VFP
\r
163 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
166 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
\r
167 #if defined __ARM_PCS_VFP
\r
168 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
171 #elif defined ( __GNUC__ )
\r
172 #if defined (__VFP_FP__) && !defined(__SOFTFP__)
\r
173 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
176 #elif defined ( __ICCARM__ )
\r
177 #if defined __ARMVFP__
\r
178 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
181 #elif defined ( __TI_ARM__ )
\r
182 #if defined __TI_VFP_SUPPORT__
\r
183 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
186 #elif defined ( __TASKING__ )
\r
187 #if defined __FPU_VFP__
\r
188 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
191 #elif defined ( __CSMC__ )
\r
192 #if ( __CSMC__ & 0x400U)
\r
193 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
\r
198 #include "core_cminstr.h" /* Core Instruction Access */
\r
199 #include "core_cmfunc.h" /* Core Function Access */
\r
205 #endif /* __CORE_CM0_H_GENERIC */
\r
207 #ifndef __CMSIS_GENERIC
\r
209 #ifndef __CORE_CM0_H_DEPENDANT
\r
210 #define __CORE_CM0_H_DEPENDANT
\r
216 /* check device defines and use defaults */
\r
217 #if defined __CHECK_DEVICE_DEFINES
\r
219 #define __CM0_REV 0x0000U
\r
220 #warning "__CM0_REV not defined in device header file; using default!"
\r
223 #ifndef __NVIC_PRIO_BITS
\r
224 #define __NVIC_PRIO_BITS 2U
\r
225 #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
\r
228 #ifndef __Vendor_SysTickConfig
\r
229 #define __Vendor_SysTickConfig 0U
\r
230 #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
\r
234 /* IO definitions (access restrictions to peripheral registers) */
\r
236 \defgroup CMSIS_glob_defs CMSIS Global Defines
\r
238 <strong>IO Type Qualifiers</strong> are used
\r
239 \li to specify the access to peripheral variables.
\r
240 \li for automatic generation of peripheral register debug information.
\r
243 #define __I volatile /*!< Defines 'read only' permissions */
\r
245 #define __I volatile const /*!< Defines 'read only' permissions */
\r
247 #define __O volatile /*!< Defines 'write only' permissions */
\r
248 #define __IO volatile /*!< Defines 'read / write' permissions */
\r
250 /* following defines should be used for structure members */
\r
251 #define __IM volatile const /*! Defines 'read only' structure member permissions */
\r
252 #define __OM volatile /*! Defines 'write only' structure member permissions */
\r
253 #define __IOM volatile /*! Defines 'read / write' structure member permissions */
\r
255 /*@} end of group Cortex_M0 */
\r
259 /*******************************************************************************
\r
260 * Register Abstraction
\r
261 Core Register contain:
\r
263 - Core NVIC Register
\r
264 - Core SCB Register
\r
265 - Core SysTick Register
\r
266 ******************************************************************************/
\r
268 \defgroup CMSIS_core_register Defines and Type Definitions
\r
269 \brief Type definitions and defines for Cortex-M processor based devices.
\r
273 \ingroup CMSIS_core_register
\r
274 \defgroup CMSIS_CORE Status and Control Registers
\r
275 \brief Core Register type definitions.
\r
280 \brief Union type to access the Application Program Status Register (APSR).
\r
286 uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
\r
287 uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
\r
288 uint32_t C:1; /*!< bit: 29 Carry condition code flag */
\r
289 uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
\r
290 uint32_t N:1; /*!< bit: 31 Negative condition code flag */
\r
291 } b; /*!< Structure used for bit access */
\r
292 uint32_t w; /*!< Type used for word access */
\r
295 /* APSR Register Definitions */
\r
296 #define APSR_N_Pos 31U /*!< APSR: N Position */
\r
297 #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
\r
299 #define APSR_Z_Pos 30U /*!< APSR: Z Position */
\r
300 #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
\r
302 #define APSR_C_Pos 29U /*!< APSR: C Position */
\r
303 #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
\r
305 #define APSR_V_Pos 28U /*!< APSR: V Position */
\r
306 #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
\r
310 \brief Union type to access the Interrupt Program Status Register (IPSR).
\r
316 uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
\r
317 uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
\r
318 } b; /*!< Structure used for bit access */
\r
319 uint32_t w; /*!< Type used for word access */
\r
322 /* IPSR Register Definitions */
\r
323 #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
\r
324 #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
\r
328 \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
\r
334 uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
\r
335 uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
\r
336 uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
\r
337 uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
\r
338 uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
\r
339 uint32_t C:1; /*!< bit: 29 Carry condition code flag */
\r
340 uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
\r
341 uint32_t N:1; /*!< bit: 31 Negative condition code flag */
\r
342 } b; /*!< Structure used for bit access */
\r
343 uint32_t w; /*!< Type used for word access */
\r
346 /* xPSR Register Definitions */
\r
347 #define xPSR_N_Pos 31U /*!< xPSR: N Position */
\r
348 #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
\r
350 #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
\r
351 #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
\r
353 #define xPSR_C_Pos 29U /*!< xPSR: C Position */
\r
354 #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
\r
356 #define xPSR_V_Pos 28U /*!< xPSR: V Position */
\r
357 #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
\r
359 #define xPSR_T_Pos 24U /*!< xPSR: T Position */
\r
360 #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
\r
362 #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
\r
363 #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
\r
367 \brief Union type to access the Control Registers (CONTROL).
\r
373 uint32_t _reserved0:1; /*!< bit: 0 Reserved */
\r
374 uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
\r
375 uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
\r
376 } b; /*!< Structure used for bit access */
\r
377 uint32_t w; /*!< Type used for word access */
\r
380 /* CONTROL Register Definitions */
\r
381 #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
\r
382 #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
\r
384 /*@} end of group CMSIS_CORE */
\r
388 \ingroup CMSIS_core_register
\r
389 \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
\r
390 \brief Type definitions for the NVIC Registers
\r
395 \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
\r
399 __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
\r
400 uint32_t RESERVED0[31U];
\r
401 __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
\r
402 uint32_t RSERVED1[31U];
\r
403 __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
\r
404 uint32_t RESERVED2[31U];
\r
405 __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
\r
406 uint32_t RESERVED3[31U];
\r
407 uint32_t RESERVED4[64U];
\r
408 __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
\r
411 /*@} end of group CMSIS_NVIC */
\r
415 \ingroup CMSIS_core_register
\r
416 \defgroup CMSIS_SCB System Control Block (SCB)
\r
417 \brief Type definitions for the System Control Block Registers
\r
422 \brief Structure type to access the System Control Block (SCB).
\r
426 __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
\r
427 __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
\r
428 uint32_t RESERVED0;
\r
429 __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
\r
430 __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
\r
431 __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
\r
432 uint32_t RESERVED1;
\r
433 __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
\r
434 __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
\r
437 /* SCB CPUID Register Definitions */
\r
438 #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
\r
439 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
\r
441 #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
\r
442 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
\r
444 #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
\r
445 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
\r
447 #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
\r
448 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
\r
450 #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
\r
451 #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
\r
453 /* SCB Interrupt Control State Register Definitions */
\r
454 #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
\r
455 #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
\r
457 #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
\r
458 #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
\r
460 #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
\r
461 #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
\r
463 #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
\r
464 #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
\r
466 #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
\r
467 #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
\r
469 #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
\r
470 #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
\r
472 #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
\r
473 #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
\r
475 #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
\r
476 #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
\r
478 #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
\r
479 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
\r
481 /* SCB Application Interrupt and Reset Control Register Definitions */
\r
482 #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
\r
483 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
\r
485 #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
\r
486 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
\r
488 #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
\r
489 #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
\r
491 #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
\r
492 #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
\r
494 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
\r
495 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
\r
497 /* SCB System Control Register Definitions */
\r
498 #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
\r
499 #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
\r
501 #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
\r
502 #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
\r
504 #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
\r
505 #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
\r
507 /* SCB Configuration Control Register Definitions */
\r
508 #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
\r
509 #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
\r
511 #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
\r
512 #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
\r
514 /* SCB System Handler Control and State Register Definitions */
\r
515 #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
\r
516 #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
\r
518 /*@} end of group CMSIS_SCB */
\r
522 \ingroup CMSIS_core_register
\r
523 \defgroup CMSIS_SysTick System Tick Timer (SysTick)
\r
524 \brief Type definitions for the System Timer Registers.
\r
529 \brief Structure type to access the System Timer (SysTick).
\r
533 __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
\r
534 __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
\r
535 __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
\r
536 __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
\r
539 /* SysTick Control / Status Register Definitions */
\r
540 #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
\r
541 #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
\r
543 #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
\r
544 #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
\r
546 #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
\r
547 #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
\r
549 #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
\r
550 #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
\r
552 /* SysTick Reload Register Definitions */
\r
553 #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
\r
554 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
\r
556 /* SysTick Current Register Definitions */
\r
557 #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
\r
558 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
\r
560 /* SysTick Calibration Register Definitions */
\r
561 #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
\r
562 #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
\r
564 #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
\r
565 #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
\r
567 #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
\r
568 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
\r
570 /*@} end of group CMSIS_SysTick */
\r
574 \ingroup CMSIS_core_register
\r
575 \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
\r
576 \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
\r
577 Therefore they are not covered by the Cortex-M0 header file.
\r
580 /*@} end of group CMSIS_CoreDebug */
\r
584 \ingroup CMSIS_core_register
\r
585 \defgroup CMSIS_core_bitfield Core register bit field macros
\r
586 \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
\r
591 \brief Mask and shift a bit field value for use in a register bit range.
\r
592 \param[in] field Name of the register bit field.
\r
593 \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
\r
594 \return Masked and shifted value.
\r
596 #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
\r
599 \brief Mask and shift a register value to extract a bit filed value.
\r
600 \param[in] field Name of the register bit field.
\r
601 \param[in] value Value of register. This parameter is interpreted as an uint32_t type.
\r
602 \return Masked and shifted bit field value.
\r
604 #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
\r
606 /*@} end of group CMSIS_core_bitfield */
\r
610 \ingroup CMSIS_core_register
\r
611 \defgroup CMSIS_core_base Core Definitions
\r
612 \brief Definitions for base addresses, unions, and structures.
\r
616 /* Memory mapping of Cortex-M0 Hardware */
\r
617 #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
\r
618 #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
\r
619 #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
\r
620 #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
\r
622 #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
\r
623 #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
\r
624 #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
\r
631 /*******************************************************************************
\r
632 * Hardware Abstraction Layer
\r
633 Core Function Interface contains:
\r
634 - Core NVIC Functions
\r
635 - Core SysTick Functions
\r
636 - Core Register Access Functions
\r
637 ******************************************************************************/
\r
639 \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
\r
644 /* ########################## NVIC functions #################################### */
\r
646 \ingroup CMSIS_Core_FunctionInterface
\r
647 \defgroup CMSIS_Core_NVICFunctions NVIC Functions
\r
648 \brief Functions that manage interrupts and exceptions via the NVIC.
\r
652 /* Interrupt Priorities are WORD accessible only under ARMv6M */
\r
653 /* The following MACROS handle generation of the register offset and byte masks */
\r
654 #define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
\r
655 #define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
\r
656 #define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
\r
660 \brief Enable External Interrupt
\r
661 \details Enables a device-specific interrupt in the NVIC interrupt controller.
\r
662 \param [in] IRQn External interrupt number. Value cannot be negative.
\r
664 __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
\r
666 NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
\r
671 \brief Disable External Interrupt
\r
672 \details Disables a device-specific interrupt in the NVIC interrupt controller.
\r
673 \param [in] IRQn External interrupt number. Value cannot be negative.
\r
675 __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
\r
677 NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
\r
682 \brief Get Pending Interrupt
\r
683 \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
\r
684 \param [in] IRQn Interrupt number.
\r
685 \return 0 Interrupt status is not pending.
\r
686 \return 1 Interrupt status is pending.
\r
688 __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
\r
690 return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
\r
695 \brief Set Pending Interrupt
\r
696 \details Sets the pending bit of an external interrupt.
\r
697 \param [in] IRQn Interrupt number. Value cannot be negative.
\r
699 __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
\r
701 NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
\r
706 \brief Clear Pending Interrupt
\r
707 \details Clears the pending bit of an external interrupt.
\r
708 \param [in] IRQn External interrupt number. Value cannot be negative.
\r
710 __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
\r
712 NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
\r
717 \brief Set Interrupt Priority
\r
718 \details Sets the priority of an interrupt.
\r
719 \note The priority cannot be set for every core interrupt.
\r
720 \param [in] IRQn Interrupt number.
\r
721 \param [in] priority Priority to set.
\r
723 __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
\r
725 if ((int32_t)(IRQn) < 0)
\r
727 SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
\r
728 (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
\r
732 NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
\r
733 (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
\r
739 \brief Get Interrupt Priority
\r
740 \details Reads the priority of an interrupt.
\r
741 The interrupt number can be positive to specify an external (device specific) interrupt,
\r
742 or negative to specify an internal (core) interrupt.
\r
743 \param [in] IRQn Interrupt number.
\r
744 \return Interrupt Priority.
\r
745 Value is aligned automatically to the implemented priority bits of the microcontroller.
\r
747 __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
\r
750 if ((int32_t)(IRQn) < 0)
\r
752 return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
\r
756 return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
\r
762 \brief System Reset
\r
763 \details Initiates a system reset request to reset the MCU.
\r
765 __STATIC_INLINE void NVIC_SystemReset(void)
\r
767 __DSB(); /* Ensure all outstanding memory accesses included
\r
768 buffered write are completed before reset */
\r
769 SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
\r
770 SCB_AIRCR_SYSRESETREQ_Msk);
\r
771 __DSB(); /* Ensure completion of memory access */
\r
773 for(;;) /* wait until reset */
\r
779 /*@} end of CMSIS_Core_NVICFunctions */
\r
782 /* ########################## FPU functions #################################### */
\r
784 \ingroup CMSIS_Core_FunctionInterface
\r
785 \defgroup CMSIS_Core_FpuFunctions FPU Functions
\r
786 \brief Function that provides FPU type.
\r
791 \brief get FPU type
\r
792 \details returns the FPU type
\r
795 - \b 1: Single precision FPU
\r
796 - \b 2: Double + Single precision FPU
\r
798 __STATIC_INLINE uint32_t SCB_GetFPUType(void)
\r
800 return 0U; /* No FPU */
\r
804 /*@} end of CMSIS_Core_FpuFunctions */
\r
808 /* ################################## SysTick function ############################################ */
\r
810 \ingroup CMSIS_Core_FunctionInterface
\r
811 \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
\r
812 \brief Functions that configure the System.
\r
816 #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
\r
819 \brief System Tick Configuration
\r
820 \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
\r
821 Counter is in free running mode to generate periodic interrupts.
\r
822 \param [in] ticks Number of ticks between two interrupts.
\r
823 \return 0 Function succeeded.
\r
824 \return 1 Function failed.
\r
825 \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
\r
826 function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
\r
827 must contain a vendor-specific implementation of this function.
\r
829 __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
\r
831 if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
\r
833 return (1UL); /* Reload value impossible */
\r
836 SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
\r
837 NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
\r
838 SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
\r
839 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
\r
840 SysTick_CTRL_TICKINT_Msk |
\r
841 SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
\r
842 return (0UL); /* Function successful */
\r
847 /*@} end of CMSIS_Core_SysTickFunctions */
\r
856 #endif /* __CORE_CM0_H_DEPENDANT */
\r
858 #endif /* __CMSIS_GENERIC */
\r