本文整理匯總了C++中GPIO_EXTILineConfig函數的典型用法代碼示例。如果您正苦於以下問題:C++ GPIO_EXTILineConfig函數的具體用法?C++ GPIO_EXTILineConfig怎麽用?C++ GPIO_EXTILineConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GPIO_EXTILineConfig函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: EXTI_Configuration
/*******************************************************************************
* Function Name : EXTI_Configuration
* Description : Configures the used EXTI lines.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void EXTI_Configuration(void)
{
/* Connect EXTI Line0 to PA.00 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
/* Configure EXTI Line0 to generate an interrupt on falling edge */
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Connect EXTI Line13 to PC.13 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource13);
/* Configure EXTI Line13 to generate an event on falling edge */
EXTI_InitStructure.EXTI_Line = EXTI_Line13;
EXTI_Init(&EXTI_InitStructure);
/* Connect Key Button EXTI Line to GPIO Key Button Pin */
GPIO_EXTILineConfig(GPIO_PORT_SOURCE_KEY_BUTTON, GPIO_PIN_SOURCE_KEY_BUTTON);
/* Configure Key Button EXTI Line to generate an event on falling edge */
EXTI_InitStructure.EXTI_Line = EXTI_LINE_KEY_BUTTON;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
EXTI_Init(&EXTI_InitStructure);
}
示例2: EXTI_Configuration
/*******************************************************************************
* Function Name : EXTI_Configuration.
* Description : Configure the EXTI lines for Key and Tamper push buttons.
* Input : None.
* Output : None.
* Return value : The direction value.
*******************************************************************************/
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
/* Configure gpio as input : Button Left-WKUP */
/* Connect EXTI Line to gpio pin */
GPIO_EXTILineConfig(GPIO_PORTSOURCE_KEY, GPIO_PINSOURCE_KEY1);
/* Configure EXTI Line to generate an interrupt */
EXTI_InitStructure.EXTI_Line = GPIO_EXTI_Line_KEY1;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Configure gpio as input : Button Right-USER */
/* Connect EXTI Line to gpio pin */
GPIO_EXTILineConfig(GPIO_PORTSOURCE_KEY, GPIO_PINSOURCE_KEY2);
/* Configure EXTI Line to generate an interrupt */
EXTI_InitStructure.EXTI_Line = GPIO_EXTI_Line_KEY2;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* USB Wakeup from suspend event */
EXTI_ClearITPendingBit(EXTI_Line18);
EXTI_InitStructure.EXTI_Line = EXTI_Line18; // USB resume from suspend mode
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
示例3: ExtI_Configuration
//================================================================================================
//
//================================================================================================
void ExtI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStruct;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
EXTI_InitStruct.EXTI_Line = EXTI_Line0;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);
EXTI_ClearITPendingBit(EXTI_Line0);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource1);
EXTI_InitStruct.EXTI_Line = EXTI_Line1;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);
EXTI_ClearITPendingBit(EXTI_Line1);
}
示例4: Exti_Config
/**
* @file Exti_Config
* @brief 調用函數庫,初始化中斷配置
* @param 無
* @retval 無
*/
void Exti_Config(void)
{
/*查看外部中斷/事件線路映像
PA0、PB0、PC0、PD0、PE0、PF0、PG0 ————>映像於 EXTI0
PA1、PB1、PC1、PD1、PE1、PF1、PG1 ————>映像於 EXTI1
PA2、PB2、PC2、PD2、PE2、PF2、PG2 ————>映像於 EXTI2
PA3、PB3、PC3、PD3、PE3、PF3、PG3 ————>映像於 EXTI3
.......依次類推,每個外部中斷都有一個事件線路映射*/
//定義一個EXTI_InitTypeDef 類型的結構體
EXTI_InitTypeDef EXTI_InitStructure;
//使能AFIO功能的時鍾
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
//設置PB14,PB15,PB5作為中斷線路
GPIO_EXTILineConfig(KEY1_BUTTON_EXTI_PORT_SOURCE, KEY1_BUTTON_EXTI_PIN_SOURCE);
GPIO_EXTILineConfig(KEY2_BUTTON_EXTI_PORT_SOURCE, KEY2_BUTTON_EXTI_PIN_SOURCE);
GPIO_EXTILineConfig(KEY3_BUTTON_EXTI_PORT_SOURCE, KEY3_BUTTON_EXTI_PIN_SOURCE);
//選擇中斷線路14,15,5
EXTI_InitStructure.EXTI_Line = KEY1_BUTTON_EXTI_LINE | KEY2_BUTTON_EXTI_LINE | KEY3_BUTTON_EXTI_LINE;
//設置為中斷請求觸發模式
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
//設置為下降沿觸發
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//下降沿觸發
//設置為使能中斷線
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
//調用庫函數,初始化中斷
EXTI_Init(&EXTI_InitStructure);
}
示例5: EXTI_Config
void EXTI_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//EXTI IN GPIO Config
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4; //PB3-Pitch PB4-Yaw
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //Set to Inpit
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //GPIO Speed
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource3);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource4);
EXTI_InitStructure.EXTI_Line = EXTI_Line3 | EXTI_Line4;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_GenerateSWInterrupt(EXTI_Line3 | EXTI_Line4);
EXTI_ClearITPendingBit(EXTI_Line3 | EXTI_Line4);
NVIC_EnableIRQ(EXTI3_IRQn); // Enable interrupt
NVIC_EnableIRQ(EXTI4_IRQn); // Enable interrupt
}
示例6: EXTI_Configuration
/**
* @brief Configures the different EXTI lines.
* @param None
* @retval None
*/
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
#ifdef STM32F10X_HD_VL
/* Select the EXTI Line11 the GPIO pin source */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOF, GPIO_PinSource11);
#else
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource11);
#endif
/* EXTI line11 configuration -----------------------------------------------*/
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_Line = EXTI_Line11;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Select the EXTI Line15 the GPIO pin source */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource15);
/* EXTI line15 configuration -----------------------------------------------*/
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_Line = EXTI_Line15;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
示例7: EXTIX_Init
//外部中斷初始化程序
//初始化PA0,PA13,PA15為中斷輸入.
void EXTIX_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
//NVIC_InitTypeDef NVIC_InitStructure;
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); //關閉jtag
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);
//init GPIOA.13,GPIOA.15 上拉輸入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//init GPIOA.0 下拉輸入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//GPIOA.13
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource13);
EXTI_InitStructure.EXTI_Line=EXTI_Line13;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
//GPIOA.15
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource15);
EXTI_InitStructure.EXTI_Line=EXTI_Line15;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
//GPIOA.0
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0);
EXTI_InitStructure.EXTI_Line=EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
// NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //使能按鍵所在的外部中斷通道
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //先占優先級4位,共16級
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01; //先占優先級0位,從優先級4位
// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中斷通道
// NVIC_Init(&NVIC_InitStructure);
// NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //使能按鍵所在的外部中斷通道
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //先占優先級4位,共16級
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02; //先占優先級0位,從優先級4位
// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中斷通道
// NVIC_Init(&NVIC_InitStructure);
}
示例8: EXTI_Configuration
/*******************************************************************************
* unction Name : EXTI_Configuration.
* Description : Configure the EXTI lines for Key and Tamper push buttons.
* Input : None.
* Output : None.
* Return value : The direction value.
******************************************************************************/
void EXTI_Configuration(void)
{
/* Connect Button EXTI Line to Button GPIO Pin */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource14); //GPIOb14
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource8);
/* Configure EXTI_Line8 line to generate an interrupt on rising & falling edges */
EXTI_InitStructure.EXTI_Line = EXTI_Line8;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Clear the EXTI_Line1 line pending bit */
EXTI_ClearITPendingBit(EXTI_Line8);
/* Configure EXTI_Line14 line to generate an interrupt on rising & falling edges */
EXTI_InitStructure.EXTI_Line = EXTI_Line14;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Clear the EXTI_Line1 line pending bit */
EXTI_ClearITPendingBit(EXTI_Line14);
}
示例9: EXTIX_Init
/**
* @brief Configure PA.13 in interrupt mode
* @param None
* @retval None
*/
void EXTIX_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); //關閉jtag
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);
//初始化 KEY0-->GPIOA.13,KEY1-->GPIOA.15 上拉輸入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 初始化 WK_UP-->GPIOA.0 下拉輸入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//GPIOA.13 中斷線以及中斷初始化配置
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource13);
EXTI_InitStructure.EXTI_Line=EXTI_Line13;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure); //根據EXTI_InitStruct中指定的參數初始化外設EXTI寄存器
//GPIOA.15 中斷線以及中斷初始化配置
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource15);
EXTI_InitStructure.EXTI_Line=EXTI_Line15;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure); //根據EXTI_InitStruct中指定的參數初始化外設EXTI寄存器
//GPIOA.0 中斷線以及中斷初始化配置
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0);
EXTI_InitStructure.EXTI_Line=EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure); //根據EXTI_InitStruct中指定的參數初始化外設EXTI寄存器
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //使能按鍵所在的外部中斷通道
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //搶占優先級2,
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01; //子優先級1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中斷通道
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //使能按鍵所在的外部中斷通道
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //搶占優先級2
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02; //子優先級2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中斷通道
NVIC_Init(&NVIC_InitStructure); //根據NVIC_InitStruct中指定的參數初始化外設NVIC寄存器
}
示例10: EXTIX_Init
void EXTIX_Init(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
KEY_Init(); //IO口初始化
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); //打開AFIO時鍾以操作中斷配置寄存器?
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource13); //PC3 映射到中斷線EXTI13上
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource0); //PE0 映射到中斷線exti0上
//初始化外部中斷線
EXTI_InitStructure.EXTI_Line = 0x2000; //使用線路為:13,
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //中斷
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //下降沿
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line0; //使用線路為:0,
EXTI_Init(&EXTI_InitStructure);
//=設置中斷優先級
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //外部中斷線15-10中斷
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //外部中斷線0中斷
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_Init(&NVIC_InitStructure);
}
示例11: EXTI_Configuration
static void EXTI_Configuration()
{
/* key1, key2 */
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(key1_rcc, ENABLE);
RCC_APB2PeriphClockCmd(key2_rcc, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = key1_pin;
GPIO_Init(key1_gpio, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = key2_pin;
GPIO_Init(key2_gpio, &GPIO_InitStructure);
}
GPIO_EXTILineConfig(key1_portsource, key1_pinsource);
GPIO_EXTILineConfig(key2_portsource, key2_pinsource);
/* Configure EXTI */
EXTI_Enable(1, 1);
EXTI_Enable(2, 1);
}
示例12: EXTI_Configuration
/*******************************************************************************
* Function Name : EXTI_Configuration.
* Description : Configure the EXTI lines for Key and Tamper push buttons.
* Input : None.
* Output : None.
* Return value : The direction value.
*******************************************************************************/
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
/* Configure gpio as input : Button Left-WKUP */
/* Connect EXTI Line to gpio pin */
GPIO_EXTILineConfig(GPIO_PORTSOURCE_KEY, GPIO_PINSOURCE_KEY1);
/* Configure EXTI Line to generate an interrupt */
EXTI_InitStructure.EXTI_Line = GPIO_EXTI_Line_KEY1;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Configure gpio as input : Button Right-USER */
/* Connect EXTI Line to gpio pin */
GPIO_EXTILineConfig(GPIO_PORTSOURCE_KEY, GPIO_PINSOURCE_KEY2);
/* Configure EXTI Line to generate an interrupt */
EXTI_InitStructure.EXTI_Line = GPIO_EXTI_Line_KEY2;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
示例13: KEY_Initialize
void KEY_Initialize (void)
{
/******************** Clock Enable ********************/
/* Enable GPIOA clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/******************** GPIO configure ********************/
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure gpio as input : Button WKUP & USER */
GPIO_InitStructure.GPIO_Pin = GPIO_KEY1_PIN | GPIO_KEY2_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIO_KEY, &GPIO_InitStructure);
/******************** Fuction configure ********************/
EXTI_InitTypeDef EXTI_InitStructure;
/* Configure gpio as input : Button Left-WKUP */
/* Connect EXTI Line to gpio pin */
GPIO_EXTILineConfig(GPIO_PORTSOURCE_KEY, GPIO_PINSOURCE_KEY1);
/* Configure EXTI Line to generate an interrupt */
EXTI_InitStructure.EXTI_Line = GPIO_EXTI_Line_KEY1;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Configure gpio as input : Button Right-USER */
/* Connect EXTI Line to gpio pin */
GPIO_EXTILineConfig(GPIO_PORTSOURCE_KEY, GPIO_PINSOURCE_KEY2);
/* Configure EXTI Line to generate an interrupt */
EXTI_InitStructure.EXTI_Line = GPIO_EXTI_Line_KEY2;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/******************** Interrupt configure ********************/
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the EXTI0 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the EXTI1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
示例14: SENSOR_EXTI_Configuration
/********************
- 傳感器IO中斷設置
*********************/
void SENSOR_EXTI_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
// RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, ENABLE);
// RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO,DISABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE);//PB1 ACCER_INT2
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);//PA6 GYRO_DR
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_ResetBits(GPIOB, GPIO_Pin_1);
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;//PB1 ACCER_INT2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;//PA6 GYRO_DR
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
EXTI_DeInit();
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource1);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource6);
EXTI_InitStructure.EXTI_Line = EXTI_Line1;//參考手冊9.2.5節
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line6;//參考手冊9.2.5節
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_GenerateSWInterrupt(EXTI_Line1);
EXTI_GenerateSWInterrupt(EXTI_Line6);
}
示例15: init_key
/*************************************************************
初始化按鍵和蜂鳴器
*************************************************************/
void init_key(void)
{
uint8 x;
NVIC_InitTypeDef NVIC_InitStructure;
//=====================下麵初始化開關量的狀態讀取函數==============
key1.read_start = Read_Key1;
key2.read_start = Read_Key2;
key3.read_start = Read_Key3;
l_lidi.read_start = Read_L_LIDI;
r_lidi.read_start = Read_R_LIDI;
charge_dc.read_start = Read_Charge_Dc;
charge_seat.read_start = Read_Charge_Seat;
s_current.read_start = Read_S_Current;
l_bump.read_start = Read_L_Bump;
r_bump.read_start = Read_R_Bump;
for(x=0; x<4; x++)
{ //當有按鍵時為1,那麽開始就為0
hightaction[x]->sign = 0;
hightaction[x]->number = 0;
hightaction[x]->key = 0;
}
for(x=0; x<6; x++)
{ //當有按鍵時為0,那麽開始就為1
lowaction[x]->sign = 1;
lowaction[x]->number = 0;
lowaction[x]->key = 1;
}
key_time = FALSE;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource1);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource2);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource11);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource12);
EXTI->FTSR |= 0xe;
EXTI->RTSR |= 0x1800;
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 13;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQChannel;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQChannel;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQChannel;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel;
NVIC_Init(&NVIC_InitStructure);
}