2 ******************************************************************************
3 * @file stm32f30x_misc.h
4 * @author MCD Application Team
7 * @brief This file contains all the functions prototypes for the miscellaneous
8 * firmware library functions (add-on to CMSIS functions).
9 ******************************************************************************
12 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 * You may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at:
18 * http://www.st.com/software_license_agreement_liberty_v2
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
26 ******************************************************************************
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F30x_MISC_H
31 #define __STM32F30x_MISC_H
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f30x.h"
40 /** @addtogroup STM32F30x_StdPeriph_Driver
48 /* Exported types ------------------------------------------------------------*/
51 * @brief NVIC Init Structure definition
56 uint8_t NVIC_IRQChannel
; /*!< Specifies the IRQ channel to be enabled or disabled.
57 This parameter can be a value of @ref IRQn_Type (For
58 the complete STM32 Devices IRQ Channels list, please
59 refer to stm32f30x.h file) */
61 uint8_t NVIC_IRQChannelPreemptionPriority
; /*!< Specifies the pre-emption priority for the IRQ channel
62 specified in NVIC_IRQChannel. This parameter can be a value
64 A lower priority value indicates a higher priority */
67 uint8_t NVIC_IRQChannelSubPriority
; /*!< Specifies the subpriority level for the IRQ channel specified
68 in NVIC_IRQChannel. This parameter can be a value
70 A lower priority value indicates a higher priority */
72 FunctionalState NVIC_IRQChannelCmd
; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
73 will be enabled or disabled.
74 This parameter can be set either to ENABLE or DISABLE */
80 The table below gives the allowed values of the pre-emption priority and subpriority according
81 to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
82 ============================================================================================================================
83 NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description
84 ============================================================================================================================
85 NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority
86 | | | 4 bits for subpriority
87 ----------------------------------------------------------------------------------------------------------------------------
88 NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority
89 | | | 3 bits for subpriority
90 ----------------------------------------------------------------------------------------------------------------------------
91 NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority
92 | | | 2 bits for subpriority
93 ----------------------------------------------------------------------------------------------------------------------------
94 NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority
95 | | | 1 bits for subpriority
96 ----------------------------------------------------------------------------------------------------------------------------
97 NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority
98 | | | 0 bits for subpriority
99 ============================================================================================================================
103 /* Exported constants --------------------------------------------------------*/
105 /** @defgroup MISC_Exported_Constants
109 /** @defgroup MISC_Vector_Table_Base
113 #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
114 #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
115 #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
116 ((VECTTAB) == NVIC_VectTab_FLASH))
121 /** @defgroup MISC_System_Low_Power
125 #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
126 #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
127 #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
128 #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
129 ((LP) == NVIC_LP_SLEEPDEEP) || \
130 ((LP) == NVIC_LP_SLEEPONEXIT))
135 /** @defgroup MISC_Preemption_Priority_Group
139 #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
140 4 bits for subpriority */
141 #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
142 3 bits for subpriority */
143 #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
144 2 bits for subpriority */
145 #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
146 1 bits for subpriority */
147 #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
148 0 bits for subpriority */
150 #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
151 ((GROUP) == NVIC_PriorityGroup_1) || \
152 ((GROUP) == NVIC_PriorityGroup_2) || \
153 ((GROUP) == NVIC_PriorityGroup_3) || \
154 ((GROUP) == NVIC_PriorityGroup_4))
156 #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
158 #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
160 #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
166 /** @defgroup MISC_SysTick_clock_source
169 #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
170 #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
171 #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
172 ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
181 /* Exported macro ------------------------------------------------------------*/
182 /* Exported functions --------------------------------------------------------*/
184 void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup
);
185 void NVIC_Init(NVIC_InitTypeDef
* NVIC_InitStruct
);
186 void NVIC_SetVectorTable(uint32_t NVIC_VectTab
, uint32_t Offset
);
187 void NVIC_SystemLPConfig(uint8_t LowPowerMode
, FunctionalState NewState
);
188 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource
);
194 #endif /* __STM32F30x_MISC_H */
204 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/