stm32f10x_nvic.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:19k
源码类别:

uCOS

开发平台:

C/C++

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