void
ACC_TEMP_EXTI_Configuration(void)
{
GPIO_InitTypeDef
GPIO_InitStructure;
NVIC_InitTypeDef
NVIC_InitStructure;
EXTI_InitTypeDef
EXTI_InitStructure;
/* 使能A、B、C、D IO口的時鐘,注意要使能IO複用時鐘 */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA
| RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC \
|
RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO ,ENABLE); //使能PA、PB、PC時鐘
/* ACC(即WK_UP)引腳初始化,喚醒引腳 */
/* 設置GPIOA屬性 */
GPIO_InitStructure.GPIO_Pin =
GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* 設置 EXTI_line0 為中斷源mode and enable */
EXTI_InitStructure.EXTI_Line =
EXTI_Line0; //外部中斷線
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
//中斷模式
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
//中斷觸發方式為邊沿觸發
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
//打開中斷
EXTI_Init(&EXTI_InitStructure);
/* 設置PA0為中斷引腳 for EXTI_line0 */
/* 設置PA0為中斷引腳 for EXTI_line0 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,
GPIO_PinSource0); //選擇 GPIO管腳用作外部中斷線路
/* 設置嵌套中斷向量表屬性 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH ,
NVIC_OFFSET);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
// 搶佔式優先順序別
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //指定中斷源
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
// 指定回應優先順序別1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#if 1
/* PB3 IO口初始化 */
GPIO_InitStructure.GPIO_Pin
= GPIO_Pin_3; // 部分參數沿用前次GPIOA 定義
GPIO_Init(GPIOB,
&GPIO_InitStructure);
/* PB3 外部中斷初始化 */
EXTI_InitStructure.EXTI_Line
= EXTI_Line3;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; /* 檢測腳平時是高電平,檢測到低電平是說明收到int 信號 */
EXTI_Init(&EXTI_InitStructure); // 部分參數沿用前次GPIOA 定義
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource3); //選擇
GPIO管腳用作外部中斷線路
/* PB3 檢測外部中斷初始化 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
// 搶佔式優先順序別
NVIC_InitStructure.NVIC_IRQChannel =
EXTI3_IRQn; //指定中斷源
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
// 指定回應優先順序別2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#endif
#if 1
/* PC11 檢測IO口初始化 */
GPIO_InitStructure.GPIO_Pin
= GPIO_Pin_11;
GPIO_Init(GPIOC,
&GPIO_InitStructure); // 部分參數沿用前次GPIOA 定義
/* PC11 檢測外部中斷初始化 */
EXTI_InitStructure.EXTI_Line
= EXTI_Line11;
EXTI_InitStructure.EXTI_Trigger
= EXTI_Trigger_Rising_Falling; /* 檢測腳由高到低說明收到信號,由低到高說明消除 */
EXTI_Init(&EXTI_InitStructure); // 部分參數沿用前次GPIOA 定義
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource11); //選擇
GPIO管腳用作外部中斷線路
/* PC11 檢測外部中斷初始化 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); // 搶佔式優先順序別
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //指定中斷源
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // 指定回應優先順序別2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/**************************************************************/
/* PC12 檢測IO口初始化 */
GPIO_InitStructure.GPIO_Pin
= GPIO_Pin_12;
GPIO_Init(GPIOC,
&GPIO_InitStructure); // 部分參數沿用前次GPIOA 定義
/* PC12 檢測外部中斷初始化 */
EXTI_InitStructure.EXTI_Line
= EXTI_Line12;
EXTI_InitStructure.EXTI_Trigger
= EXTI_Trigger_Rising_Falling; /* 檢測腳由高到低說明收到信號,由低到高說明消除 */
EXTI_Init(&EXTI_InitStructure); // 部分參數沿用前次GPIOA 定義
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource12); //選擇
GPIO管腳用作外部中斷線路
/* PC12 檢測外部中斷初始化 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
// 搶佔式優先順序別
NVIC_InitStructure.NVIC_IRQChannel =
EXTI15_10_IRQn; //指定中斷源
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
// 指定回應優先順序別2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#endif
#if 1
/* PD2 檢測IO口初始化 */
GPIO_InitStructure.GPIO_Pin
= GPIO_Pin_2;
GPIO_Init(GPIOD,
&GPIO_InitStructure); // 部分參數沿用前次GPIOA 定義
/* PD2 檢測外部中斷初始化 */
EXTI_InitStructure.EXTI_Line
= EXTI_Line2;
EXTI_InitStructure.EXTI_Trigger
= EXTI_Trigger_Rising_Falling; /* 檢測腳由高到低說明收到信號,由低到高說明消除 */
EXTI_Init(&EXTI_InitStructure); // 部分參數沿用前次GPIOA 定義
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource2); //選擇
GPIO管腳用作外部中斷線路
/* PD2 檢測外部中斷初始化 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
// 搶佔式優先順序別
NVIC_InitStructure.NVIC_IRQChannel =
EXTI2_IRQn; //指定中斷源
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
// 指定回應優先順序別2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#endif
}
沒有留言:
張貼留言