Rev 49 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 49 | Rev 50 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /**************************************************************************//** |
1 | /**************************************************************************//** |
2 | * @file core_cm0.h |
2 | * @file core_cm0.h |
3 | * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File |
3 | * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File |
4 | * @version V4.30 |
4 | * @version V5.0.5 |
5 | * @date 20. October 2015 |
5 | * @date 28. May 2018 |
6 | ******************************************************************************/ |
6 | ******************************************************************************/ |
- | 7 | /* |
|
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED |
8 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. |
8 | 9 | * |
|
9 | All rights reserved. |
10 | * SPDX-License-Identifier: Apache-2.0 |
10 | Redistribution and use in source and binary forms, with or without |
- | |
11 | modification, are permitted provided that the following conditions are met: |
- | |
- | 11 | * |
|
12 | - Redistributions of source code must retain the above copyright |
12 | * Licensed under the Apache License, Version 2.0 (the License); you may |
13 | notice, this list of conditions and the following disclaimer. |
13 | * not use this file except in compliance with the License. |
14 | - Redistributions in binary form must reproduce the above copyright |
14 | * You may obtain a copy of the License at |
15 | notice, this list of conditions and the following disclaimer in the |
- | |
16 | documentation and/or other materials provided with the distribution. |
- | |
17 | - Neither the name of ARM nor the names of its contributors may be used |
- | |
18 | to endorse or promote products derived from this software without |
- | |
- | 15 | * |
|
19 | specific prior written permission. |
16 | * www.apache.org/licenses/LICENSE-2.0 |
20 | * |
17 | * |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
- | |
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
- | |
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
- | |
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
- | |
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
18 | * Unless required by applicable law or agreed to in writing, software |
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
21 | * See the License for the specific language governing permissions and |
31 | POSSIBILITY OF SUCH DAMAGE. |
22 | * limitations under the License. |
32 | ---------------------------------------------------------------------------*/ |
- | |
33 | 23 | */ |
|
34 | 24 | ||
35 | #if defined ( __ICCARM__ ) |
25 | #if defined ( __ICCARM__ ) |
36 | #pragma system_include /* treat file as system include file for MISRA check */ |
26 | #pragma system_include /* treat file as system include file for MISRA check */ |
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
27 | #elif defined (__clang__) |
38 | #pragma clang system_header /* treat file as system include file */ |
28 | #pragma clang system_header /* treat file as system include file */ |
39 | #endif |
29 | #endif |
40 | 30 | ||
41 | #ifndef __CORE_CM0_H_GENERIC |
31 | #ifndef __CORE_CM0_H_GENERIC |
42 | #define __CORE_CM0_H_GENERIC |
32 | #define __CORE_CM0_H_GENERIC |
Line 68... | Line 58... | ||
68 | /** |
58 | /** |
69 | \ingroup Cortex_M0 |
59 | \ingroup Cortex_M0 |
70 | @{ |
60 | @{ |
71 | */ |
61 | */ |
72 | 62 | ||
- | 63 | #include "cmsis_version.h" |
|
- | 64 | ||
73 | /* CMSIS CM0 definitions */ |
65 | /* CMSIS CM0 definitions */ |
74 | #define __CM0_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ |
66 | #define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ |
75 | #define __CM0_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ |
67 | #define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ |
76 | #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ |
68 | #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ |
77 | __CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ |
69 | __CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ |
78 | - | ||
79 | #define __CORTEX_M (0x00U) /*!< Cortex-M Core */ |
- | |
80 | - | ||
81 | - | ||
82 | #if defined ( __CC_ARM ) |
- | |
83 | #define __ASM __asm /*!< asm keyword for ARM Compiler */ |
- | |
84 | #define __INLINE __inline /*!< inline keyword for ARM Compiler */ |
- | |
85 | #define __STATIC_INLINE static __inline |
- | |
86 | - | ||
87 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
- | |
88 | #define __ASM __asm /*!< asm keyword for ARM Compiler */ |
- | |
89 | #define __INLINE __inline /*!< inline keyword for ARM Compiler */ |
- | |
90 | #define __STATIC_INLINE static __inline |
- | |
91 | - | ||
92 | #elif defined ( __GNUC__ ) |
- | |
93 | #define __ASM __asm /*!< asm keyword for GNU Compiler */ |
- | |
94 | #define __INLINE inline /*!< inline keyword for GNU Compiler */ |
- | |
95 | #define __STATIC_INLINE static inline |
- | |
96 | - | ||
97 | #elif defined ( __ICCARM__ ) |
- | |
98 | #define __ASM __asm /*!< asm keyword for IAR Compiler */ |
- | |
99 | #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ |
- | |
100 | #define __STATIC_INLINE static inline |
- | |
101 | - | ||
102 | #elif defined ( __TMS470__ ) |
- | |
103 | #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ |
- | |
104 | #define __STATIC_INLINE static inline |
- | |
105 | - | ||
106 | #elif defined ( __TASKING__ ) |
- | |
107 | #define __ASM __asm /*!< asm keyword for TASKING Compiler */ |
- | |
108 | #define __INLINE inline /*!< inline keyword for TASKING Compiler */ |
- | |
109 | #define __STATIC_INLINE static inline |
- | |
110 | - | ||
111 | #elif defined ( __CSMC__ ) |
- | |
112 | #define __packed |
- | |
113 | #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ |
- | |
114 | #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ |
- | |
115 | #define __STATIC_INLINE static inline |
- | |
116 | 70 | ||
117 | #else |
- | |
118 | #error Unknown compiler |
71 | #define __CORTEX_M (0U) /*!< Cortex-M Core */ |
119 | #endif |
- | |
120 | 72 | ||
121 | /** __FPU_USED indicates whether an FPU is used or not. |
73 | /** __FPU_USED indicates whether an FPU is used or not. |
122 | This core does not support an FPU at all |
74 | This core does not support an FPU at all |
123 | */ |
75 | */ |
124 | #define __FPU_USED 0U |
76 | #define __FPU_USED 0U |
Line 126... | Line 78... | ||
126 | #if defined ( __CC_ARM ) |
78 | #if defined ( __CC_ARM ) |
127 | #if defined __TARGET_FPU_VFP |
79 | #if defined __TARGET_FPU_VFP |
128 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
80 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
129 | #endif |
81 | #endif |
130 | 82 | ||
131 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
83 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
132 | #if defined __ARM_PCS_VFP |
84 | #if defined __ARM_PCS_VFP |
133 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
85 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
134 | #endif |
86 | #endif |
135 | 87 | ||
136 | #elif defined ( __GNUC__ ) |
88 | #elif defined ( __GNUC__ ) |
Line 141... | Line 93... | ||
141 | #elif defined ( __ICCARM__ ) |
93 | #elif defined ( __ICCARM__ ) |
142 | #if defined __ARMVFP__ |
94 | #if defined __ARMVFP__ |
143 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
95 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
144 | #endif |
96 | #endif |
145 | 97 | ||
146 | #elif defined ( __TMS470__ ) |
98 | #elif defined ( __TI_ARM__ ) |
147 | #if defined __TI_VFP_SUPPORT__ |
99 | #if defined __TI_VFP_SUPPORT__ |
148 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
100 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
149 | #endif |
101 | #endif |
150 | 102 | ||
151 | #elif defined ( __TASKING__ ) |
103 | #elif defined ( __TASKING__ ) |
Line 158... | Line 110... | ||
158 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
110 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" |
159 | #endif |
111 | #endif |
160 | 112 | ||
161 | #endif |
113 | #endif |
162 | 114 | ||
163 | #include "core_cmInstr.h" /* Core Instruction Access */ |
115 | #include "cmsis_compiler.h" /* CMSIS compiler specific defines */ |
164 | #include "core_cmFunc.h" /* Core Function Access */ |
- | |
- | 116 | ||
165 | 117 | ||
166 | #ifdef __cplusplus |
118 | #ifdef __cplusplus |
167 | } |
119 | } |
168 | #endif |
120 | #endif |
169 | 121 | ||
Line 553... | Line 505... | ||
553 | */ |
505 | */ |
554 | 506 | ||
555 | /** |
507 | /** |
556 | \brief Mask and shift a bit field value for use in a register bit range. |
508 | \brief Mask and shift a bit field value for use in a register bit range. |
557 | \param[in] field Name of the register bit field. |
509 | \param[in] field Name of the register bit field. |
558 | \param[in] value Value of the bit field. |
510 | \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. |
559 | \return Masked and shifted value. |
511 | \return Masked and shifted value. |
560 | */ |
512 | */ |
561 | #define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) |
513 | #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) |
562 | 514 | ||
563 | /** |
515 | /** |
564 | \brief Mask and shift a register value to extract a bit filed value. |
516 | \brief Mask and shift a register value to extract a bit filed value. |
565 | \param[in] field Name of the register bit field. |
517 | \param[in] field Name of the register bit field. |
566 | \param[in] value Value of register. |
518 | \param[in] value Value of register. This parameter is interpreted as an uint32_t type. |
567 | \return Masked and shifted bit field value. |
519 | \return Masked and shifted bit field value. |
568 | */ |
520 | */ |
569 | #define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) |
521 | #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) |
570 | 522 | ||
571 | /*@} end of group CMSIS_core_bitfield */ |
523 | /*@} end of group CMSIS_core_bitfield */ |
572 | 524 | ||
573 | 525 | ||
574 | /** |
526 | /** |
Line 576... | Line 528... | ||
576 | \defgroup CMSIS_core_base Core Definitions |
528 | \defgroup CMSIS_core_base Core Definitions |
577 | \brief Definitions for base addresses, unions, and structures. |
529 | \brief Definitions for base addresses, unions, and structures. |
578 | @{ |
530 | @{ |
579 | */ |
531 | */ |
580 | 532 | ||
581 | /* Memory mapping of Cortex-M0 Hardware */ |
533 | /* Memory mapping of Core Hardware */ |
582 | #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ |
534 | #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ |
583 | #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ |
535 | #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ |
584 | #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ |
536 | #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ |
585 | #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ |
537 | #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ |
586 | 538 | ||
Line 612... | Line 564... | ||
612 | \defgroup CMSIS_Core_NVICFunctions NVIC Functions |
564 | \defgroup CMSIS_Core_NVICFunctions NVIC Functions |
613 | \brief Functions that manage interrupts and exceptions via the NVIC. |
565 | \brief Functions that manage interrupts and exceptions via the NVIC. |
614 | @{ |
566 | @{ |
615 | */ |
567 | */ |
616 | 568 | ||
- | 569 | #ifdef CMSIS_NVIC_VIRTUAL |
|
- | 570 | #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE |
|
- | 571 | #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" |
|
- | 572 | #endif |
|
- | 573 | #include CMSIS_NVIC_VIRTUAL_HEADER_FILE |
|
- | 574 | #else |
|
- | 575 | #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping |
|
- | 576 | #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping |
|
- | 577 | #define NVIC_EnableIRQ __NVIC_EnableIRQ |
|
- | 578 | #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ |
|
- | 579 | #define NVIC_DisableIRQ __NVIC_DisableIRQ |
|
- | 580 | #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ |
|
- | 581 | #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ |
|
- | 582 | #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ |
|
- | 583 | /*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */ |
|
- | 584 | #define NVIC_SetPriority __NVIC_SetPriority |
|
- | 585 | #define NVIC_GetPriority __NVIC_GetPriority |
|
- | 586 | #define NVIC_SystemReset __NVIC_SystemReset |
|
- | 587 | #endif /* CMSIS_NVIC_VIRTUAL */ |
|
- | 588 | ||
- | 589 | #ifdef CMSIS_VECTAB_VIRTUAL |
|
- | 590 | #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE |
|
- | 591 | #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" |
|
- | 592 | #endif |
|
- | 593 | #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE |
|
- | 594 | #else |
|
- | 595 | #define NVIC_SetVector __NVIC_SetVector |
|
- | 596 | #define NVIC_GetVector __NVIC_GetVector |
|
- | 597 | #endif /* (CMSIS_VECTAB_VIRTUAL) */ |
|
- | 598 | ||
- | 599 | #define NVIC_USER_IRQ_OFFSET 16 |
|
- | 600 | ||
- | 601 | ||
- | 602 | /* The following EXC_RETURN values are saved the LR on exception entry */ |
|
- | 603 | #define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ |
|
- | 604 | #define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ |
|
- | 605 | #define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ |
|
- | 606 | ||
- | 607 | ||
617 | /* Interrupt Priorities are WORD accessible only under ARMv6M */ |
608 | /* Interrupt Priorities are WORD accessible only under Armv6-M */ |
618 | /* The following MACROS handle generation of the register offset and byte masks */ |
609 | /* The following MACROS handle generation of the register offset and byte masks */ |
619 | #define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) |
610 | #define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) |
620 | #define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) |
611 | #define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) |
621 | #define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) |
612 | #define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) |
622 | 613 | ||
- | 614 | #define __NVIC_SetPriorityGrouping(X) (void)(X) |
|
- | 615 | #define __NVIC_GetPriorityGrouping() (0U) |
|
- | 616 | ||
- | 617 | /** |
|
- | 618 | \brief Enable Interrupt |
|
- | 619 | \details Enables a device specific interrupt in the NVIC interrupt controller. |
|
- | 620 | \param [in] IRQn Device specific interrupt number. |
|
- | 621 | \note IRQn must not be negative. |
|
- | 622 | */ |
|
- | 623 | __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) |
|
- | 624 | { |
|
- | 625 | if ((int32_t)(IRQn) >= 0) |
|
- | 626 | { |
|
- | 627 | NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); |
|
- | 628 | } |
|
- | 629 | } |
|
- | 630 | ||
623 | 631 | ||
624 | /** |
632 | /** |
625 | \brief Enable External Interrupt |
633 | \brief Get Interrupt Enable status |
626 | \details Enables a device-specific interrupt in the NVIC interrupt controller. |
634 | \details Returns a device specific interrupt enable status from the NVIC interrupt controller. |
627 | \param [in] IRQn External interrupt number. Value cannot be negative. |
635 | \param [in] IRQn Device specific interrupt number. |
- | 636 | \return 0 Interrupt is not enabled. |
|
- | 637 | \return 1 Interrupt is enabled. |
|
- | 638 | \note IRQn must not be negative. |
|
628 | */ |
639 | */ |
629 | __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) |
640 | __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) |
630 | { |
641 | { |
- | 642 | if ((int32_t)(IRQn) >= 0) |
|
- | 643 | { |
|
631 | NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); |
644 | return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); |
- | 645 | } |
|
- | 646 | else |
|
- | 647 | { |
|
- | 648 | return(0U); |
|
- | 649 | } |
|
632 | } |
650 | } |
633 | 651 | ||
634 | 652 | ||
635 | /** |
653 | /** |
636 | \brief Disable External Interrupt |
654 | \brief Disable Interrupt |
637 | \details Disables a device-specific interrupt in the NVIC interrupt controller. |
655 | \details Disables a device specific interrupt in the NVIC interrupt controller. |
638 | \param [in] IRQn External interrupt number. Value cannot be negative. |
656 | \param [in] IRQn Device specific interrupt number. |
- | 657 | \note IRQn must not be negative. |
|
639 | */ |
658 | */ |
640 | __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) |
659 | __STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) |
641 | { |
660 | { |
- | 661 | if ((int32_t)(IRQn) >= 0) |
|
- | 662 | { |
|
642 | NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); |
663 | NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); |
- | 664 | __DSB(); |
|
- | 665 | __ISB(); |
|
- | 666 | } |
|
643 | } |
667 | } |
644 | 668 | ||
645 | 669 | ||
646 | /** |
670 | /** |
647 | \brief Get Pending Interrupt |
671 | \brief Get Pending Interrupt |
648 | \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. |
672 | \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. |
649 | \param [in] IRQn Interrupt number. |
673 | \param [in] IRQn Device specific interrupt number. |
650 | \return 0 Interrupt status is not pending. |
674 | \return 0 Interrupt status is not pending. |
651 | \return 1 Interrupt status is pending. |
675 | \return 1 Interrupt status is pending. |
- | 676 | \note IRQn must not be negative. |
|
652 | */ |
677 | */ |
653 | __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) |
678 | __STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) |
654 | { |
679 | { |
- | 680 | if ((int32_t)(IRQn) >= 0) |
|
- | 681 | { |
|
655 | return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); |
682 | return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); |
- | 683 | } |
|
- | 684 | else |
|
- | 685 | { |
|
- | 686 | return(0U); |
|
- | 687 | } |
|
656 | } |
688 | } |
657 | 689 | ||
658 | 690 | ||
659 | /** |
691 | /** |
660 | \brief Set Pending Interrupt |
692 | \brief Set Pending Interrupt |
661 | \details Sets the pending bit of an external interrupt. |
693 | \details Sets the pending bit of a device specific interrupt in the NVIC pending register. |
662 | \param [in] IRQn Interrupt number. Value cannot be negative. |
694 | \param [in] IRQn Device specific interrupt number. |
- | 695 | \note IRQn must not be negative. |
|
663 | */ |
696 | */ |
664 | __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) |
697 | __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) |
665 | { |
698 | { |
- | 699 | if ((int32_t)(IRQn) >= 0) |
|
- | 700 | { |
|
666 | NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); |
701 | NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); |
- | 702 | } |
|
667 | } |
703 | } |
668 | 704 | ||
669 | 705 | ||
670 | /** |
706 | /** |
671 | \brief Clear Pending Interrupt |
707 | \brief Clear Pending Interrupt |
672 | \details Clears the pending bit of an external interrupt. |
708 | \details Clears the pending bit of a device specific interrupt in the NVIC pending register. |
673 | \param [in] IRQn External interrupt number. Value cannot be negative. |
709 | \param [in] IRQn Device specific interrupt number. |
- | 710 | \note IRQn must not be negative. |
|
674 | */ |
711 | */ |
675 | __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) |
712 | __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) |
676 | { |
713 | { |
- | 714 | if ((int32_t)(IRQn) >= 0) |
|
- | 715 | { |
|
677 | NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); |
716 | NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); |
- | 717 | } |
|
678 | } |
718 | } |
679 | 719 | ||
680 | 720 | ||
681 | /** |
721 | /** |
682 | \brief Set Interrupt Priority |
722 | \brief Set Interrupt Priority |
683 | \details Sets the priority of an interrupt. |
723 | \details Sets the priority of a device specific interrupt or a processor exception. |
684 | \note The priority cannot be set for every core interrupt. |
724 | The interrupt number can be positive to specify a device specific interrupt, |
- | 725 | or negative to specify a processor exception. |
|
685 | \param [in] IRQn Interrupt number. |
726 | \param [in] IRQn Interrupt number. |
686 | \param [in] priority Priority to set. |
727 | \param [in] priority Priority to set. |
- | 728 | \note The priority cannot be set for every processor exception. |
|
687 | */ |
729 | */ |
688 | __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) |
730 | __STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) |
689 | { |
731 | { |
690 | if ((int32_t)(IRQn) < 0) |
732 | if ((int32_t)(IRQn) >= 0) |
691 | { |
733 | { |
692 | SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | |
734 | NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | |
693 | (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); |
735 | (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); |
694 | } |
736 | } |
695 | else |
737 | else |
696 | { |
738 | { |
697 | NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | |
739 | SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | |
698 | (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); |
740 | (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); |
699 | } |
741 | } |
700 | } |
742 | } |
701 | 743 | ||
702 | 744 | ||
703 | /** |
745 | /** |
704 | \brief Get Interrupt Priority |
746 | \brief Get Interrupt Priority |
705 | \details Reads the priority of an interrupt. |
747 | \details Reads the priority of a device specific interrupt or a processor exception. |
706 | The interrupt number can be positive to specify an external (device specific) interrupt, |
748 | The interrupt number can be positive to specify a device specific interrupt, |
707 | or negative to specify an internal (core) interrupt. |
749 | or negative to specify a processor exception. |
708 | \param [in] IRQn Interrupt number. |
750 | \param [in] IRQn Interrupt number. |
709 | \return Interrupt Priority. |
751 | \return Interrupt Priority. |
710 | Value is aligned automatically to the implemented priority bits of the microcontroller. |
752 | Value is aligned automatically to the implemented priority bits of the microcontroller. |
711 | */ |
753 | */ |
712 | __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) |
754 | __STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) |
713 | { |
755 | { |
714 | 756 | ||
715 | if ((int32_t)(IRQn) < 0) |
757 | if ((int32_t)(IRQn) >= 0) |
716 | { |
758 | { |
717 | return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); |
759 | return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); |
718 | } |
760 | } |
719 | else |
761 | else |
720 | { |
762 | { |
721 | return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); |
763 | return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); |
722 | } |
764 | } |
723 | } |
765 | } |
724 | 766 | ||
725 | 767 | ||
726 | /** |
768 | /** |
- | 769 | \brief Encode Priority |
|
- | 770 | \details Encodes the priority for an interrupt with the given priority group, |
|
- | 771 | preemptive priority value, and subpriority value. |
|
- | 772 | In case of a conflict between priority grouping and available |
|
- | 773 | priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. |
|
- | 774 | \param [in] PriorityGroup Used priority group. |
|
- | 775 | \param [in] PreemptPriority Preemptive priority value (starting from 0). |
|
- | 776 | \param [in] SubPriority Subpriority value (starting from 0). |
|
- | 777 | \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). |
|
- | 778 | */ |
|
- | 779 | __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) |
|
- | 780 | { |
|
- | 781 | uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ |
|
- | 782 | uint32_t PreemptPriorityBits; |
|
- | 783 | uint32_t SubPriorityBits; |
|
- | 784 | ||
- | 785 | PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); |
|
- | 786 | SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); |
|
- | 787 | ||
- | 788 | return ( |
|
- | 789 | ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | |
|
- | 790 | ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) |
|
- | 791 | ); |
|
- | 792 | } |
|
- | 793 | ||
- | 794 | ||
- | 795 | /** |
|
- | 796 | \brief Decode Priority |
|
- | 797 | \details Decodes an interrupt priority value with a given priority group to |
|
- | 798 | preemptive priority value and subpriority value. |
|
- | 799 | In case of a conflict between priority grouping and available |
|
- | 800 | priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. |
|
- | 801 | \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). |
|
- | 802 | \param [in] PriorityGroup Used priority group. |
|
- | 803 | \param [out] pPreemptPriority Preemptive priority value (starting from 0). |
|
- | 804 | \param [out] pSubPriority Subpriority value (starting from 0). |
|
- | 805 | */ |
|
- | 806 | __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) |
|
- | 807 | { |
|
- | 808 | uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ |
|
- | 809 | uint32_t PreemptPriorityBits; |
|
- | 810 | uint32_t SubPriorityBits; |
|
- | 811 | ||
- | 812 | PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); |
|
- | 813 | SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); |
|
- | 814 | ||
- | 815 | *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); |
|
- | 816 | *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); |
|
- | 817 | } |
|
- | 818 | ||
- | 819 | ||
- | 820 | ||
- | 821 | /** |
|
- | 822 | \brief Set Interrupt Vector |
|
- | 823 | \details Sets an interrupt vector in SRAM based interrupt vector table. |
|
- | 824 | The interrupt number can be positive to specify a device specific interrupt, |
|
- | 825 | or negative to specify a processor exception. |
|
- | 826 | Address 0 must be mapped to SRAM. |
|
- | 827 | \param [in] IRQn Interrupt number |
|
- | 828 | \param [in] vector Address of interrupt handler function |
|
- | 829 | */ |
|
- | 830 | __STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) |
|
- | 831 | { |
|
- | 832 | uint32_t *vectors = (uint32_t *)0x0U; |
|
- | 833 | vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; |
|
- | 834 | } |
|
- | 835 | ||
- | 836 | ||
- | 837 | /** |
|
- | 838 | \brief Get Interrupt Vector |
|
- | 839 | \details Reads an interrupt vector from interrupt vector table. |
|
- | 840 | The interrupt number can be positive to specify a device specific interrupt, |
|
- | 841 | or negative to specify a processor exception. |
|
- | 842 | \param [in] IRQn Interrupt number. |
|
- | 843 | \return Address of interrupt handler function |
|
- | 844 | */ |
|
- | 845 | __STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) |
|
- | 846 | { |
|
- | 847 | uint32_t *vectors = (uint32_t *)0x0U; |
|
- | 848 | return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; |
|
- | 849 | } |
|
- | 850 | ||
- | 851 | ||
- | 852 | /** |
|
727 | \brief System Reset |
853 | \brief System Reset |
728 | \details Initiates a system reset request to reset the MCU. |
854 | \details Initiates a system reset request to reset the MCU. |
729 | */ |
855 | */ |
730 | __STATIC_INLINE void NVIC_SystemReset(void) |
856 | __NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) |
731 | { |
857 | { |
732 | __DSB(); /* Ensure all outstanding memory accesses included |
858 | __DSB(); /* Ensure all outstanding memory accesses included |
733 | buffered write are completed before reset */ |
859 | buffered write are completed before reset */ |
734 | SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | |
860 | SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | |
735 | SCB_AIRCR_SYSRESETREQ_Msk); |
861 | SCB_AIRCR_SYSRESETREQ_Msk); |
Line 742... | Line 868... | ||
742 | } |
868 | } |
743 | 869 | ||
744 | /*@} end of CMSIS_Core_NVICFunctions */ |
870 | /*@} end of CMSIS_Core_NVICFunctions */ |
745 | 871 | ||
746 | 872 | ||
- | 873 | /* ########################## FPU functions #################################### */ |
|
- | 874 | /** |
|
- | 875 | \ingroup CMSIS_Core_FunctionInterface |
|
- | 876 | \defgroup CMSIS_Core_FpuFunctions FPU Functions |
|
- | 877 | \brief Function that provides FPU type. |
|
- | 878 | @{ |
|
- | 879 | */ |
|
- | 880 | ||
- | 881 | /** |
|
- | 882 | \brief get FPU type |
|
- | 883 | \details returns the FPU type |
|
- | 884 | \returns |
|
- | 885 | - \b 0: No FPU |
|
- | 886 | - \b 1: Single precision FPU |
|
- | 887 | - \b 2: Double + Single precision FPU |
|
- | 888 | */ |
|
- | 889 | __STATIC_INLINE uint32_t SCB_GetFPUType(void) |
|
- | 890 | { |
|
- | 891 | return 0U; /* No FPU */ |
|
- | 892 | } |
|
- | 893 | ||
- | 894 | ||
- | 895 | /*@} end of CMSIS_Core_FpuFunctions */ |
|
- | 896 | ||
- | 897 | ||
747 | 898 | ||
748 | /* ################################## SysTick function ############################################ */ |
899 | /* ################################## SysTick function ############################################ */ |
749 | /** |
900 | /** |
750 | \ingroup CMSIS_Core_FunctionInterface |
901 | \ingroup CMSIS_Core_FunctionInterface |
751 | \defgroup CMSIS_Core_SysTickFunctions SysTick Functions |
902 | \defgroup CMSIS_Core_SysTickFunctions SysTick Functions |
752 | \brief Functions that configure the System. |
903 | \brief Functions that configure the System. |
753 | @{ |
904 | @{ |
754 | */ |
905 | */ |
755 | 906 | ||
756 | #if (__Vendor_SysTickConfig == 0U) |
907 | #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) |
757 | 908 | ||
758 | /** |
909 | /** |
759 | \brief System Tick Configuration |
910 | \brief System Tick Configuration |
760 | \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. |
911 | \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. |
761 | Counter is in free running mode to generate periodic interrupts. |
912 | Counter is in free running mode to generate periodic interrupts. |