Interrupt */
SPI3_IRQn = 51, /*!< SPI3 global
Interrupt */
UART4_IRQn = 52, /*!< UART4 global
Interrupt */
UART5_IRQn = 53, /*!< UART5 global
Interrupt */
TIM6_IRQn = 54, /*!< TIM6 global
Interrupt */
TIM7_IRQn = 55, /*!< TIM7 global
Interrupt */
DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global
Interrupt */
DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global
Interrupt */
DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global
Interrupt */
DMA2_Channel4_IRQn = 59, /*!< DMA2 Channel 4 global
Interrupt */
DMA2_Channel5_IRQn = 60, /*!< DMA2 Channel 5 global
Interrupt */
ETH_IRQn = 61, /*!< Ethernet global
Interrupt */ ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */
CAN2_TX_IRQn = 63, /*!< CAN2 TX
Interrupt */
CAN2_RX0_IRQn = 64, /*!< CAN2 RX0
Interrupt */
CAN2_RX1_IRQn = 65, /*!< CAN2 RX1
Interrupt */
CAN2_SCE_IRQn = 66, /*!< CAN2 SCE
Interrupt */
OTG_FS_IRQn = 67 /*!< USB OTG FS global
Interrupt */ #endif /* STM32F10X_CL */ } IRQn_Type;
使用库函数进行时钟系统初始化配置
void NVIC_config()//配置中断 {
NVIC_InitTypeDef NVIC_InitStructure;
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//选择中断分组1 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;//选择串口1中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//抢占式中断优先级设置为0 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;//响应式中断优先级设置为3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能中断 NVIC_Init(&NVIC_InitStructure); }
四、相关库函数解析
1、库中所涉及到的结构体
typedef struct {
uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
This parameter can be a value of @ref IRQn_Type (For the complete STM32 Devices IRQ Channels list, please refer to stm32f10x.h file) */
uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the
IRQ channel specified in NVIC_IRQChannel. This parameter can be a value between 0 and 15 as described in the table @ref NVIC_Priority_Table */
uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel
specified in NVIC_IRQChannel. This parameter can be a value between 0 and 15 as described in the table @ref NVIC_Priority_Table */
FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in
NVIC_IRQChannel will be enabled or disabled.
This parameter can be set either to ENABLE or DISABLE */
} NVIC_InitTypeDef;
2、库函数解析
在misc.h中:
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);//对优先级分组进行配置 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);//根据中断结构体的值初始化中断 void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);//设置向量表的位置和
偏移
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); //选择系
统进入低功耗模式的条件
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);//系统滴答时钟源的配置 在core_cm3.h中:
uint32_t __get_BASEPRI(void);//Return the Base Priority value
void __set_BASEPRI(uint32_t basePri);//Set the Base Priority value uint32_t __get_PRIMASK(void);//Return the Priority Mask value
void __set_PRIMASK(uint32_t priMask);//Set the Priority Mask value uint32_t __get_FAULTMASK(void);//Return the Fault Mask value
void __set_FAULTMASK(uint32_t faultMask);//Set the Fault Mask value uint32_t __get_CONTROL(void);//Return the Control Register value
void __set_CONTROL(uint32_t control);//Set the Control Register value
void NVIC_SetPriorityGrouping(uint32_t PriorityGroup); uint32_t NVIC_GetPriorityGrouping(void); void NVIC_EnableIRQ(IRQn_Type IRQn); void NVIC_DisableIRQ(IRQn_Type IRQn);
uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn); void NVIC_SetPendingIRQ(IRQn_Type IRQn); void NVIC_ClearPendingIRQ(IRQn_Type IRQn); uint32_t NVIC_GetActive(IRQn_Type IRQn);
void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority); uint32_t NVIC_GetPriority(IRQn_Type IRQn);
uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t
SubPriority);
void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority);
五、实例详解
void NVIC_config()//配置中断 {
NVIC_InitTypeDef NVIC_InitStructure;
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//选择中断分组1 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;//选择串口1中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//抢占式中断优先级设置为0 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;//响应式中断优先级设置为3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能中断 NVIC_Init(&NVIC_InitStructure); }