1 |
582 |
jeremybenn |
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
|
2 |
|
|
* File Name : stm32f10x_nvic.h
|
3 |
|
|
* Author : MCD Application Team
|
4 |
|
|
* Date First Issued : 09/29/2006
|
5 |
|
|
* Description : This file contains all the functions prototypes for the
|
6 |
|
|
* NVIC firmware library.
|
7 |
|
|
********************************************************************************
|
8 |
|
|
* History:
|
9 |
|
|
* 04/02/2007: V0.2
|
10 |
|
|
* 02/05/2007: V0.1
|
11 |
|
|
* 09/29/2006: V0.01
|
12 |
|
|
********************************************************************************
|
13 |
|
|
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
14 |
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
15 |
|
|
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
16 |
|
|
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
17 |
|
|
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
18 |
|
|
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
19 |
|
|
*******************************************************************************/
|
20 |
|
|
|
21 |
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
22 |
|
|
#ifndef __STM32F10x_NVIC_H
|
23 |
|
|
#define __STM32F10x_NVIC_H
|
24 |
|
|
|
25 |
|
|
/* Includes ------------------------------------------------------------------*/
|
26 |
|
|
#include "stm32f10x_map.h"
|
27 |
|
|
|
28 |
|
|
/* Exported types ------------------------------------------------------------*/
|
29 |
|
|
/* NVIC Init Structure definition */
|
30 |
|
|
typedef struct
|
31 |
|
|
{
|
32 |
|
|
u8 NVIC_IRQChannel;
|
33 |
|
|
u8 NVIC_IRQChannelPreemptionPriority;
|
34 |
|
|
u8 NVIC_IRQChannelSubPriority;
|
35 |
|
|
FunctionalState NVIC_IRQChannelCmd;
|
36 |
|
|
} NVIC_InitTypeDef;
|
37 |
|
|
|
38 |
|
|
/* Exported constants --------------------------------------------------------*/
|
39 |
|
|
/* IRQ Channels --------------------------------------------------------------*/
|
40 |
|
|
#define WWDG_IRQChannel ((u8)0x00) /* Window WatchDog Interrupt */
|
41 |
|
|
#define PVD_IRQChannel ((u8)0x01) /* PVD through EXTI Line detection Interrupt */
|
42 |
|
|
#define TAMPER_IRQChannel ((u8)0x02) /* Tamper Interrupt */
|
43 |
|
|
#define RTC_IRQChannel ((u8)0x03) /* RTC global Interrupt */
|
44 |
|
|
#define FLASH_IRQChannel ((u8)0x04) /* FLASH global Interrupt */
|
45 |
|
|
#define RCC_IRQChannel ((u8)0x05) /* RCC global Interrupt */
|
46 |
|
|
#define EXTI0_IRQChannel ((u8)0x06) /* EXTI Line0 Interrupt */
|
47 |
|
|
#define EXTI1_IRQChannel ((u8)0x07) /* EXTI Line1 Interrupt */
|
48 |
|
|
#define EXTI2_IRQChannel ((u8)0x08) /* EXTI Line2 Interrupt */
|
49 |
|
|
#define EXTI3_IRQChannel ((u8)0x09) /* EXTI Line3 Interrupt */
|
50 |
|
|
#define EXTI4_IRQChannel ((u8)0x0A) /* EXTI Line4 Interrupt */
|
51 |
|
|
#define DMAChannel1_IRQChannel ((u8)0x0B) /* DMA Channel 1 global Interrupt */
|
52 |
|
|
#define DMAChannel2_IRQChannel ((u8)0x0C) /* DMA Channel 2 global Interrupt */
|
53 |
|
|
#define DMAChannel3_IRQChannel ((u8)0x0D) /* DMA Channel 3 global Interrupt */
|
54 |
|
|
#define DMAChannel4_IRQChannel ((u8)0x0E) /* DMA Channel 4 global Interrupt */
|
55 |
|
|
#define DMAChannel5_IRQChannel ((u8)0x0F) /* DMA Channel 5 global Interrupt */
|
56 |
|
|
#define DMAChannel6_IRQChannel ((u8)0x10) /* DMA Channel 6 global Interrupt */
|
57 |
|
|
#define DMAChannel7_IRQChannel ((u8)0x11) /* DMA Channel 7 global Interrupt */
|
58 |
|
|
#define ADC_IRQChannel ((u8)0x12) /* ADC global Interrupt */
|
59 |
|
|
#define USB_HP_CAN_TX_IRQChannel ((u8)0x13) /* USB High Priority or CAN TX Interrupts */
|
60 |
|
|
#define USB_LP_CAN_RX0_IRQChannel ((u8)0x14) /* USB Low Priority or CAN RX0 Interrupts */
|
61 |
|
|
#define CAN_RX1_IRQChannel ((u8)0x15) /* CAN RX1 Interrupt */
|
62 |
|
|
#define CAN_SCE_IRQChannel ((u8)0x16) /* CAN SCE Interrupt */
|
63 |
|
|
#define EXTI9_5_IRQChannel ((u8)0x17) /* External Line[9:5] Interrupts */
|
64 |
|
|
#define TIM1_BRK_IRQChannel ((u8)0x18) /* TIM1 Break Interrupt */
|
65 |
|
|
#define TIM1_UP_IRQChannel ((u8)0x19) /* TIM1 Update Interrupt */
|
66 |
|
|
#define TIM1_TRG_COM_IRQChannel ((u8)0x1A) /* TIM1 Trigger and Commutation Interrupt */
|
67 |
|
|
#define TIM1_CC_IRQChannel ((u8)0x1B) /* TIM1 Capture Compare Interrupt */
|
68 |
|
|
#define TIM2_IRQChannel ((u8)0x1C) /* TIM2 global Interrupt */
|
69 |
|
|
#define TIM3_IRQChannel ((u8)0x1D) /* TIM3 global Interrupt */
|
70 |
|
|
#define TIM4_IRQChannel ((u8)0x1E) /* TIM4 global Interrupt */
|
71 |
|
|
#define I2C1_EV_IRQChannel ((u8)0x1F) /* I2C1 Event Interrupt */
|
72 |
|
|
#define I2C1_ER_IRQChannel ((u8)0x20) /* I2C1 Error Interrupt */
|
73 |
|
|
#define I2C2_EV_IRQChannel ((u8)0x21) /* I2C2 Event Interrupt */
|
74 |
|
|
#define I2C2_ER_IRQChannel ((u8)0x22) /* I2C2 Error Interrupt */
|
75 |
|
|
#define SPI1_IRQChannel ((u8)0x23) /* SPI1 global Interrupt */
|
76 |
|
|
#define SPI2_IRQChannel ((u8)0x24) /* SPI2 global Interrupt */
|
77 |
|
|
#define USART1_IRQChannel ((u8)0x25) /* USART1 global Interrupt */
|
78 |
|
|
#define USART2_IRQChannel ((u8)0x26) /* USART2 global Interrupt */
|
79 |
|
|
#define USART3_IRQChannel ((u8)0x27) /* USART3 global Interrupt */
|
80 |
|
|
#define EXTI15_10_IRQChannel ((u8)0x28) /* External Line[15:10] Interrupts */
|
81 |
|
|
#define RTCAlarm_IRQChannel ((u8)0x29) /* RTC Alarm through EXTI Line Interrupt */
|
82 |
|
|
#define USBWakeUp_IRQChannel ((u8)0x2A) /* USB WakeUp from suspend through EXTI Line Interrupt */
|
83 |
|
|
|
84 |
|
|
#define IS_NVIC_IRQ_CHANNEL(CHANNEL) ((CHANNEL == WWDG_IRQChannel) || \
|
85 |
|
|
(CHANNEL == PVD_IRQChannel) || \
|
86 |
|
|
(CHANNEL == TAMPER_IRQChannel) || \
|
87 |
|
|
(CHANNEL == RTC_IRQChannel) || \
|
88 |
|
|
(CHANNEL == FLASH_IRQChannel) || \
|
89 |
|
|
(CHANNEL == RCC_IRQChannel) || \
|
90 |
|
|
(CHANNEL == EXTI0_IRQChannel) || \
|
91 |
|
|
(CHANNEL == EXTI1_IRQChannel) || \
|
92 |
|
|
(CHANNEL == EXTI2_IRQChannel) || \
|
93 |
|
|
(CHANNEL == EXTI3_IRQChannel) || \
|
94 |
|
|
(CHANNEL == EXTI4_IRQChannel) || \
|
95 |
|
|
(CHANNEL == DMAChannel1_IRQChannel) || \
|
96 |
|
|
(CHANNEL == DMAChannel2_IRQChannel) || \
|
97 |
|
|
(CHANNEL == DMAChannel3_IRQChannel) || \
|
98 |
|
|
(CHANNEL == DMAChannel4_IRQChannel) || \
|
99 |
|
|
(CHANNEL == DMAChannel5_IRQChannel) || \
|
100 |
|
|
(CHANNEL == DMAChannel6_IRQChannel) || \
|
101 |
|
|
(CHANNEL == DMAChannel7_IRQChannel) || \
|
102 |
|
|
(CHANNEL == ADC_IRQChannel) || \
|
103 |
|
|
(CHANNEL == USB_HP_CAN_TX_IRQChannel) || \
|
104 |
|
|
(CHANNEL == USB_LP_CAN_RX0_IRQChannel) || \
|
105 |
|
|
(CHANNEL == CAN_RX1_IRQChannel) || \
|
106 |
|
|
(CHANNEL == CAN_SCE_IRQChannel) || \
|
107 |
|
|
(CHANNEL == EXTI9_5_IRQChannel) || \
|
108 |
|
|
(CHANNEL == TIM1_BRK_IRQChannel) || \
|
109 |
|
|
(CHANNEL == TIM1_UP_IRQChannel) || \
|
110 |
|
|
(CHANNEL == TIM1_TRG_COM_IRQChannel) || \
|
111 |
|
|
(CHANNEL == TIM1_CC_IRQChannel) || \
|
112 |
|
|
(CHANNEL == TIM2_IRQChannel) || \
|
113 |
|
|
(CHANNEL == TIM3_IRQChannel) || \
|
114 |
|
|
(CHANNEL == TIM4_IRQChannel) || \
|
115 |
|
|
(CHANNEL == I2C1_EV_IRQChannel) || \
|
116 |
|
|
(CHANNEL == I2C1_ER_IRQChannel) || \
|
117 |
|
|
(CHANNEL == I2C2_EV_IRQChannel) || \
|
118 |
|
|
(CHANNEL == I2C2_ER_IRQChannel) || \
|
119 |
|
|
(CHANNEL == SPI1_IRQChannel) || \
|
120 |
|
|
(CHANNEL == SPI2_IRQChannel) || \
|
121 |
|
|
(CHANNEL == USART1_IRQChannel) || \
|
122 |
|
|
(CHANNEL == USART2_IRQChannel) || \
|
123 |
|
|
(CHANNEL == USART3_IRQChannel) || \
|
124 |
|
|
(CHANNEL == EXTI15_10_IRQChannel) || \
|
125 |
|
|
(CHANNEL == RTCAlarm_IRQChannel) || \
|
126 |
|
|
(CHANNEL == USBWakeUp_IRQChannel))
|
127 |
|
|
|
128 |
|
|
/* System Handlers -----------------------------------------------------------*/
|
129 |
|
|
#define SystemHandler_NMI ((u32)0x00001F) /* NMI Handler */
|
130 |
|
|
#define SystemHandler_HardFault ((u32)0x000000) /* Hard Fault Handler */
|
131 |
|
|
#define SystemHandler_MemoryManage ((u32)0x043430) /* Memory Manage Handler */
|
132 |
|
|
#define SystemHandler_BusFault ((u32)0x547931) /* Bus Fault Handler */
|
133 |
|
|
#define SystemHandler_UsageFault ((u32)0x24C232) /* Usage Fault Handler */
|
134 |
|
|
#define SystemHandler_SVCall ((u32)0x01FF40) /* SVCall Handler */
|
135 |
|
|
#define SystemHandler_DebugMonitor ((u32)0x0A0080) /* Debug Monitor Handler */
|
136 |
|
|
#define SystemHandler_PSV ((u32)0x02829C) /* PSV Handler */
|
137 |
|
|
#define SystemHandler_SysTick ((u32)0x02C39A) /* SysTick Handler */
|
138 |
|
|
|
139 |
|
|
#define IS_CONFIG_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_MemoryManage) || \
|
140 |
|
|
(HANDLER == SystemHandler_BusFault) || \
|
141 |
|
|
(HANDLER == SystemHandler_UsageFault))
|
142 |
|
|
|
143 |
|
|
#define IS_PRIORITY_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_MemoryManage) || \
|
144 |
|
|
(HANDLER == SystemHandler_BusFault) || \
|
145 |
|
|
(HANDLER == SystemHandler_UsageFault) || \
|
146 |
|
|
(HANDLER == SystemHandler_SVCall) || \
|
147 |
|
|
(HANDLER == SystemHandler_DebugMonitor) || \
|
148 |
|
|
(HANDLER == SystemHandler_PSV) || \
|
149 |
|
|
(HANDLER == SystemHandler_SysTick))
|
150 |
|
|
|
151 |
|
|
#define IS_GET_PENDING_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_MemoryManage) || \
|
152 |
|
|
(HANDLER == SystemHandler_BusFault) || \
|
153 |
|
|
(HANDLER == SystemHandler_SVCall))
|
154 |
|
|
|
155 |
|
|
#define IS_SET_PENDING_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_NMI) || \
|
156 |
|
|
(HANDLER == SystemHandler_PSV) || \
|
157 |
|
|
(HANDLER == SystemHandler_SysTick))
|
158 |
|
|
|
159 |
|
|
#define IS_CLEAR_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_PSV) || \
|
160 |
|
|
(HANDLER == SystemHandler_SysTick))
|
161 |
|
|
|
162 |
|
|
#define IS_GET_ACTIVE_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_MemoryManage) || \
|
163 |
|
|
(HANDLER == SystemHandler_BusFault) || \
|
164 |
|
|
(HANDLER == SystemHandler_UsageFault) || \
|
165 |
|
|
(HANDLER == SystemHandler_SVCall) || \
|
166 |
|
|
(HANDLER == SystemHandler_DebugMonitor) || \
|
167 |
|
|
(HANDLER == SystemHandler_PSV) || \
|
168 |
|
|
(HANDLER == SystemHandler_SysTick))
|
169 |
|
|
|
170 |
|
|
#define IS_FAULT_SOURCE_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_HardFault) || \
|
171 |
|
|
(HANDLER == SystemHandler_MemoryManage) || \
|
172 |
|
|
(HANDLER == SystemHandler_BusFault) || \
|
173 |
|
|
(HANDLER == SystemHandler_UsageFault) || \
|
174 |
|
|
(HANDLER == SystemHandler_DebugMonitor))
|
175 |
|
|
|
176 |
|
|
#define IS_FAULT_ADDRESS_SYSTEM_HANDLER(HANDLER) ((HANDLER == SystemHandler_MemoryManage) || \
|
177 |
|
|
(HANDLER == SystemHandler_BusFault))
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
/* Vector Table Base ---------------------------------------------------------*/
|
181 |
|
|
#define NVIC_VectTab_RAM ((u32)0x20000000)
|
182 |
|
|
#define NVIC_VectTab_FLASH ((u32)0x00000000)
|
183 |
|
|
|
184 |
|
|
#define IS_NVIC_VECTTAB(VECTTAB) ((VECTTAB == NVIC_VectTab_RAM) || \
|
185 |
|
|
(VECTTAB == NVIC_VectTab_FLASH))
|
186 |
|
|
|
187 |
|
|
/* System Low Power ----------------------------------------------------------*/
|
188 |
|
|
#define NVIC_LP_SEVONPEND ((u8)0x10)
|
189 |
|
|
#define NVIC_LP_SLEEPDEEP ((u8)0x04)
|
190 |
|
|
#define NVIC_LP_SLEEPONEXIT ((u8)0x02)
|
191 |
|
|
|
192 |
|
|
#define IS_NVIC_LP(LP) ((LP == NVIC_LP_SEVONPEND) || \
|
193 |
|
|
(LP == NVIC_LP_SLEEPDEEP) || \
|
194 |
|
|
(LP == NVIC_LP_SLEEPONEXIT))
|
195 |
|
|
|
196 |
|
|
/* Preemption Priority Group -------------------------------------------------*/
|
197 |
|
|
#define NVIC_PriorityGroup_0 ((u32)0x700) /* 0 bits for pre-emption priority
|
198 |
|
|
4 bits for subpriority */
|
199 |
|
|
#define NVIC_PriorityGroup_1 ((u32)0x600) /* 1 bits for pre-emption priority
|
200 |
|
|
3 bits for subpriority */
|
201 |
|
|
#define NVIC_PriorityGroup_2 ((u32)0x500) /* 2 bits for pre-emption priority
|
202 |
|
|
2 bits for subpriority */
|
203 |
|
|
#define NVIC_PriorityGroup_3 ((u32)0x400) /* 3 bits for pre-emption priority
|
204 |
|
|
1 bits for subpriority */
|
205 |
|
|
#define NVIC_PriorityGroup_4 ((u32)0x300) /* 4 bits for pre-emption priority
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
#define IS_NVIC_PRIORITY_GROUP(GROUP) ((GROUP == NVIC_PriorityGroup_0) || \
|
209 |
|
|
(GROUP == NVIC_PriorityGroup_1) || \
|
210 |
|
|
(GROUP == NVIC_PriorityGroup_2) || \
|
211 |
|
|
(GROUP == NVIC_PriorityGroup_3) || \
|
212 |
|
|
(GROUP == NVIC_PriorityGroup_4))
|
213 |
|
|
|
214 |
|
|
#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) (PRIORITY < 0x10)
|
215 |
|
|
#define IS_NVIC_SUB_PRIORITY(PRIORITY) (PRIORITY < 0x10)
|
216 |
|
|
#define IS_NVIC_OFFSET(OFFSET) (OFFSET < 0x3FFFFF)
|
217 |
|
|
#define IS_NVIC_BASE_PRI(PRI) ((PRI > 0x00) && (PRI < 0x10))
|
218 |
|
|
|
219 |
|
|
/* Exported macro ------------------------------------------------------------*/
|
220 |
|
|
/* Exported functions ------------------------------------------------------- */
|
221 |
|
|
void NVIC_DeInit(void);
|
222 |
|
|
void NVIC_SCBDeInit(void);
|
223 |
|
|
void NVIC_PriorityGroupConfig(u32 NVIC_PriorityGroup);
|
224 |
|
|
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
|
225 |
|
|
void NVIC_StructInit(NVIC_InitTypeDef* NVIC_InitStruct);
|
226 |
|
|
void NVIC_SETPRIMASK(void);
|
227 |
|
|
void NVIC_RESETPRIMASK(void);
|
228 |
|
|
void NVIC_SETFAULTMASK(void);
|
229 |
|
|
void NVIC_RESETFAULTMASK(void);
|
230 |
|
|
void NVIC_BASEPRICONFIG(u32 NewPriority);
|
231 |
|
|
u32 NVIC_GetBASEPRI(void);
|
232 |
|
|
u16 NVIC_GetCurrentPendingIRQChannel(void);
|
233 |
|
|
ITStatus NVIC_GetIRQChannelPendingBitStatus(u8 NVIC_IRQChannel);
|
234 |
|
|
void NVIC_SetIRQChannelPendingBit(u8 NVIC_IRQChannel);
|
235 |
|
|
void NVIC_ClearIRQChannelPendingBit(u8 NVIC_IRQChannel);
|
236 |
|
|
u16 NVIC_GetCurrentActiveHandler(void);
|
237 |
|
|
ITStatus NVIC_GetIRQChannelActiveBitStatus(u8 NVIC_IRQChannel);
|
238 |
|
|
u32 NVIC_GetCPUID(void);
|
239 |
|
|
void NVIC_SetVectorTable(u32 NVIC_VectTab, u32 Offset);
|
240 |
|
|
void NVIC_GenerateSystemReset(void);
|
241 |
|
|
void NVIC_GenerateCoreReset(void);
|
242 |
|
|
void NVIC_SystemLPConfig(u8 LowPowerMode, FunctionalState NewState);
|
243 |
|
|
void NVIC_SystemHandlerConfig(u32 SystemHandler, FunctionalState NewState);
|
244 |
|
|
void NVIC_SystemHandlerPriorityConfig(u32 SystemHandler, u8 SystemHandlerPreemptionPriority,
|
245 |
|
|
u8 SystemHandlerSubPriority);
|
246 |
|
|
ITStatus NVIC_GetSystemHandlerPendingBitStatus(u32 SystemHandler);
|
247 |
|
|
void NVIC_SetSystemHandlerPendingBit(u32 SystemHandler);
|
248 |
|
|
void NVIC_ClearSystemHandlerPendingBit(u32 SystemHandler);
|
249 |
|
|
ITStatus NVIC_GetSystemHandlerActiveBitStatus(u32 SystemHandler);
|
250 |
|
|
u32 NVIC_GetFaultHandlerSources(u32 SystemHandler);
|
251 |
|
|
u32 NVIC_GetFaultAddress(u32 SystemHandler);
|
252 |
|
|
|
253 |
|
|
#endif /* __STM32F10x_NVIC_H */
|
254 |
|
|
|
255 |
|
|
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
|