18 #ifndef __STM32F10x_NVIC_H
19 #define __STM32F10x_NVIC_H
22 #include "stm32f10x_map.h"
29 u8 NVIC_IRQChannelPreemptionPriority;
30 u8 NVIC_IRQChannelSubPriority;
31 FunctionalState NVIC_IRQChannelCmd;
36 #define WWDG_IRQChannel ((u8)0x00)
37 #define PVD_IRQChannel ((u8)0x01)
38 #define TAMPER_IRQChannel ((u8)0x02)
39 #define RTC_IRQChannel ((u8)0x03)
40 #define FLASH_IRQChannel ((u8)0x04)
41 #define RCC_IRQChannel ((u8)0x05)
42 #define EXTI0_IRQChannel ((u8)0x06)
43 #define EXTI1_IRQChannel ((u8)0x07)
44 #define EXTI2_IRQChannel ((u8)0x08)
45 #define EXTI3_IRQChannel ((u8)0x09)
46 #define EXTI4_IRQChannel ((u8)0x0A)
47 #define DMA1_Channel1_IRQChannel ((u8)0x0B)
48 #define DMA1_Channel2_IRQChannel ((u8)0x0C)
49 #define DMA1_Channel3_IRQChannel ((u8)0x0D)
50 #define DMA1_Channel4_IRQChannel ((u8)0x0E)
51 #define DMA1_Channel5_IRQChannel ((u8)0x0F)
52 #define DMA1_Channel6_IRQChannel ((u8)0x10)
53 #define DMA1_Channel7_IRQChannel ((u8)0x11)
54 #define ADC1_2_IRQChannel ((u8)0x12)
55 #define USB_HP_CAN_TX_IRQChannel ((u8)0x13)
56 #define USB_LP_CAN_RX0_IRQChannel ((u8)0x14)
57 #define CAN_RX1_IRQChannel ((u8)0x15)
58 #define CAN_SCE_IRQChannel ((u8)0x16)
59 #define EXTI9_5_IRQChannel ((u8)0x17)
60 #define TIM1_BRK_IRQChannel ((u8)0x18)
61 #define TIM1_UP_IRQChannel ((u8)0x19)
62 #define TIM1_TRG_COM_IRQChannel ((u8)0x1A)
63 #define TIM1_CC_IRQChannel ((u8)0x1B)
64 #define TIM2_IRQChannel ((u8)0x1C)
65 #define TIM3_IRQChannel ((u8)0x1D)
66 #define TIM4_IRQChannel ((u8)0x1E)
67 #define I2C1_EV_IRQChannel ((u8)0x1F)
68 #define I2C1_ER_IRQChannel ((u8)0x20)
69 #define I2C2_EV_IRQChannel ((u8)0x21)
70 #define I2C2_ER_IRQChannel ((u8)0x22)
71 #define SPI1_IRQChannel ((u8)0x23)
72 #define SPI2_IRQChannel ((u8)0x24)
73 #define USART1_IRQChannel ((u8)0x25)
74 #define USART2_IRQChannel ((u8)0x26)
75 #define USART3_IRQChannel ((u8)0x27)
76 #define EXTI15_10_IRQChannel ((u8)0x28)
77 #define RTCAlarm_IRQChannel ((u8)0x29)
78 #define USBWakeUp_IRQChannel ((u8)0x2A)
79 #define TIM8_BRK_IRQChannel ((u8)0x2B)
80 #define TIM8_UP_IRQChannel ((u8)0x2C)
81 #define TIM8_TRG_COM_IRQChannel ((u8)0x2D)
82 #define TIM8_CC_IRQChannel ((u8)0x2E)
83 #define ADC3_IRQChannel ((u8)0x2F)
84 #define FSMC_IRQChannel ((u8)0x30)
85 #define SDIO_IRQChannel ((u8)0x31)
86 #define TIM5_IRQChannel ((u8)0x32)
87 #define SPI3_IRQChannel ((u8)0x33)
88 #define UART4_IRQChannel ((u8)0x34)
89 #define UART5_IRQChannel ((u8)0x35)
90 #define TIM6_IRQChannel ((u8)0x36)
91 #define TIM7_IRQChannel ((u8)0x37)
92 #define DMA2_Channel1_IRQChannel ((u8)0x38)
93 #define DMA2_Channel2_IRQChannel ((u8)0x39)
94 #define DMA2_Channel3_IRQChannel ((u8)0x3A)
95 #define DMA2_Channel4_5_IRQChannel ((u8)0x3B)
98 #define IS_NVIC_IRQ_CHANNEL(CHANNEL) (((CHANNEL) == WWDG_IRQChannel) || \
99 ((CHANNEL) == PVD_IRQChannel) || \
100 ((CHANNEL) == TAMPER_IRQChannel) || \
101 ((CHANNEL) == RTC_IRQChannel) || \
102 ((CHANNEL) == FLASH_IRQChannel) || \
103 ((CHANNEL) == RCC_IRQChannel) || \
104 ((CHANNEL) == EXTI0_IRQChannel) || \
105 ((CHANNEL) == EXTI1_IRQChannel) || \
106 ((CHANNEL) == EXTI2_IRQChannel) || \
107 ((CHANNEL) == EXTI3_IRQChannel) || \
108 ((CHANNEL) == EXTI4_IRQChannel) || \
109 ((CHANNEL) == DMA1_Channel1_IRQChannel) || \
110 ((CHANNEL) == DMA1_Channel2_IRQChannel) || \
111 ((CHANNEL) == DMA1_Channel3_IRQChannel) || \
112 ((CHANNEL) == DMA1_Channel4_IRQChannel) || \
113 ((CHANNEL) == DMA1_Channel5_IRQChannel) || \
114 ((CHANNEL) == DMA1_Channel6_IRQChannel) || \
115 ((CHANNEL) == DMA1_Channel7_IRQChannel) || \
116 ((CHANNEL) == ADC1_2_IRQChannel) || \
117 ((CHANNEL) == USB_HP_CAN_TX_IRQChannel) || \
118 ((CHANNEL) == USB_LP_CAN_RX0_IRQChannel) || \
119 ((CHANNEL) == CAN_RX1_IRQChannel) || \
120 ((CHANNEL) == CAN_SCE_IRQChannel) || \
121 ((CHANNEL) == EXTI9_5_IRQChannel) || \
122 ((CHANNEL) == TIM1_BRK_IRQChannel) || \
123 ((CHANNEL) == TIM1_UP_IRQChannel) || \
124 ((CHANNEL) == TIM1_TRG_COM_IRQChannel) || \
125 ((CHANNEL) == TIM1_CC_IRQChannel) || \
126 ((CHANNEL) == TIM2_IRQChannel) || \
127 ((CHANNEL) == TIM3_IRQChannel) || \
128 ((CHANNEL) == TIM4_IRQChannel) || \
129 ((CHANNEL) == I2C1_EV_IRQChannel) || \
130 ((CHANNEL) == I2C1_ER_IRQChannel) || \
131 ((CHANNEL) == I2C2_EV_IRQChannel) || \
132 ((CHANNEL) == I2C2_ER_IRQChannel) || \
133 ((CHANNEL) == SPI1_IRQChannel) || \
134 ((CHANNEL) == SPI2_IRQChannel) || \
135 ((CHANNEL) == USART1_IRQChannel) || \
136 ((CHANNEL) == USART2_IRQChannel) || \
137 ((CHANNEL) == USART3_IRQChannel) || \
138 ((CHANNEL) == EXTI15_10_IRQChannel) || \
139 ((CHANNEL) == RTCAlarm_IRQChannel) || \
140 ((CHANNEL) == USBWakeUp_IRQChannel) || \
141 ((CHANNEL) == TIM8_BRK_IRQChannel) || \
142 ((CHANNEL) == TIM8_UP_IRQChannel) || \
143 ((CHANNEL) == TIM8_TRG_COM_IRQChannel) || \
144 ((CHANNEL) == TIM8_CC_IRQChannel) || \
145 ((CHANNEL) == ADC3_IRQChannel) || \
146 ((CHANNEL) == FSMC_IRQChannel) || \
147 ((CHANNEL) == SDIO_IRQChannel) || \
148 ((CHANNEL) == TIM5_IRQChannel) || \
149 ((CHANNEL) == SPI3_IRQChannel) || \
150 ((CHANNEL) == UART4_IRQChannel) || \
151 ((CHANNEL) == UART5_IRQChannel) || \
152 ((CHANNEL) == TIM6_IRQChannel) || \
153 ((CHANNEL) == TIM7_IRQChannel) || \
154 ((CHANNEL) == DMA2_Channel1_IRQChannel) || \
155 ((CHANNEL) == DMA2_Channel2_IRQChannel) || \
156 ((CHANNEL) == DMA2_Channel3_IRQChannel) || \
157 ((CHANNEL) == DMA2_Channel4_5_IRQChannel))
161 #define SystemHandler_NMI ((u32)0x00001F)
162 #define SystemHandler_HardFault ((u32)0x000000)
163 #define SystemHandler_MemoryManage ((u32)0x043430)
164 #define SystemHandler_BusFault ((u32)0x547931)
165 #define SystemHandler_UsageFault ((u32)0x24C232)
166 #define SystemHandler_SVCall ((u32)0x01FF40)
167 #define SystemHandler_DebugMonitor ((u32)0x0A0080)
168 #define SystemHandler_PSV ((u32)0x02829C)
169 #define SystemHandler_SysTick ((u32)0x02C39A)
171 #define IS_CONFIG_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_MemoryManage) || \
172 ((HANDLER) == SystemHandler_BusFault) || \
173 ((HANDLER) == SystemHandler_UsageFault))
175 #define IS_PRIORITY_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_MemoryManage) || \
176 ((HANDLER) == SystemHandler_BusFault) || \
177 ((HANDLER) == SystemHandler_UsageFault) || \
178 ((HANDLER) == SystemHandler_SVCall) || \
179 ((HANDLER) == SystemHandler_DebugMonitor) || \
180 ((HANDLER) == SystemHandler_PSV) || \
181 ((HANDLER) == SystemHandler_SysTick))
183 #define IS_GET_PENDING_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_MemoryManage) || \
184 ((HANDLER) == SystemHandler_BusFault) || \
185 ((HANDLER) == SystemHandler_SVCall))
187 #define IS_SET_PENDING_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_NMI) || \
188 ((HANDLER) == SystemHandler_PSV) || \
189 ((HANDLER) == SystemHandler_SysTick))
191 #define IS_CLEAR_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_PSV) || \
192 ((HANDLER) == SystemHandler_SysTick))
194 #define IS_GET_ACTIVE_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_MemoryManage) || \
195 ((HANDLER) == SystemHandler_BusFault) || \
196 ((HANDLER) == SystemHandler_UsageFault) || \
197 ((HANDLER) == SystemHandler_SVCall) || \
198 ((HANDLER) == SystemHandler_DebugMonitor) || \
199 ((HANDLER) == SystemHandler_PSV) || \
200 ((HANDLER) == SystemHandler_SysTick))
202 #define IS_FAULT_SOURCE_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_HardFault) || \
203 ((HANDLER) == SystemHandler_MemoryManage) || \
204 ((HANDLER) == SystemHandler_BusFault) || \
205 ((HANDLER) == SystemHandler_UsageFault) || \
206 ((HANDLER) == SystemHandler_DebugMonitor))
208 #define IS_FAULT_ADDRESS_SYSTEM_HANDLER(HANDLER) (((HANDLER) == SystemHandler_MemoryManage) || \
209 ((HANDLER) == SystemHandler_BusFault))
213 #define NVIC_VectTab_RAM ((u32)0x20000000)
214 #define NVIC_VectTab_FLASH ((u32)0x08000000)
216 #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
217 ((VECTTAB) == NVIC_VectTab_FLASH))
220 #define NVIC_LP_SEVONPEND ((u8)0x10)
221 #define NVIC_LP_SLEEPDEEP ((u8)0x04)
222 #define NVIC_LP_SLEEPONEXIT ((u8)0x02)
224 #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
225 ((LP) == NVIC_LP_SLEEPDEEP) || \
226 ((LP) == NVIC_LP_SLEEPONEXIT))
229 #define NVIC_PriorityGroup_0 ((u32)0x700)
231 #define NVIC_PriorityGroup_1 ((u32)0x600)
233 #define NVIC_PriorityGroup_2 ((u32)0x500)
235 #define NVIC_PriorityGroup_3 ((u32)0x400)
237 #define NVIC_PriorityGroup_4 ((u32)0x300)
240 #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
241 ((GROUP) == NVIC_PriorityGroup_1) || \
242 ((GROUP) == NVIC_PriorityGroup_2) || \
243 ((GROUP) == NVIC_PriorityGroup_3) || \
244 ((GROUP) == NVIC_PriorityGroup_4))
246 #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
247 #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
248 #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x0007FFFF)
249 #define IS_NVIC_BASE_PRI(PRI) ((PRI) < 0x10)
253 void NVIC_DeInit(
void);
254 void NVIC_SCBDeInit(
void);
255 void NVIC_PriorityGroupConfig(u32 NVIC_PriorityGroup);
256 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
257 void NVIC_StructInit(NVIC_InitTypeDef* NVIC_InitStruct);
258 void NVIC_SETPRIMASK(
void);
259 void NVIC_RESETPRIMASK(
void);
260 void NVIC_SETFAULTMASK(
void);
261 void NVIC_RESETFAULTMASK(
void);
262 void NVIC_BASEPRICONFIG(u32 NewPriority);
263 u32 NVIC_GetBASEPRI(
void);
264 u16 NVIC_GetCurrentPendingIRQChannel(
void);
265 ITStatus NVIC_GetIRQChannelPendingBitStatus(u8 NVIC_IRQChannel);
266 void NVIC_SetIRQChannelPendingBit(u8 NVIC_IRQChannel);
267 void NVIC_ClearIRQChannelPendingBit(u8 NVIC_IRQChannel);
268 u16 NVIC_GetCurrentActiveHandler(
void);
269 ITStatus NVIC_GetIRQChannelActiveBitStatus(u8 NVIC_IRQChannel);
270 u32 NVIC_GetCPUID(
void);
271 void NVIC_SetVectorTable(u32 NVIC_VectTab, u32 Offset);
272 void NVIC_GenerateSystemReset(
void);
273 void NVIC_GenerateCoreReset(
void);
274 void NVIC_SystemLPConfig(u8 LowPowerMode, FunctionalState NewState);
275 void NVIC_SystemHandlerConfig(u32 SystemHandler, FunctionalState NewState);
276 void NVIC_SystemHandlerPriorityConfig(u32 SystemHandler, u8 SystemHandlerPreemptionPriority,
277 u8 SystemHandlerSubPriority);
278 ITStatus NVIC_GetSystemHandlerPendingBitStatus(u32 SystemHandler);
279 void NVIC_SetSystemHandlerPendingBit(u32 SystemHandler);
280 void NVIC_ClearSystemHandlerPendingBit(u32 SystemHandler);
281 ITStatus NVIC_GetSystemHandlerActiveBitStatus(u32 SystemHandler);
282 u32 NVIC_GetFaultHandlerSources(u32 SystemHandler);
283 u32 NVIC_GetFaultAddress(u32 SystemHandler);