From 4946bf03d1cbe465bfc5ef819ae23b3c5ce99a2c Mon Sep 17 00:00:00 2001 From: ThinkPad-T460P Date: Wed, 6 Jan 2021 12:25:02 +0800 Subject: [PATCH] add exti4(sys_reset_pin) --- Core/Inc/main.h | 1 + Core/Src/gpio.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Core/Inc/main.h b/Core/Inc/main.h index d784fff..ca5352e 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -176,6 +176,7 @@ void ISP_Judge(); #define SYS_SWO_GPIO_Port GPIOB #define SOM_SYS_RESET_Pin GPIO_PIN_4 #define SOM_SYS_RESET_GPIO_Port GPIOB +#define SOM_SYS_RESET_EXTI_IRQn EXTI4_IRQn #define SOM_MOD_SLEEP_Pin GPIO_PIN_5 #define SOM_MOD_SLEEP_GPIO_Port GPIOB #define IIC1_SCL_Pin GPIO_PIN_8 diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 424b57c..a3f8f32 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -6,7 +6,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2021 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -79,9 +79,6 @@ void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOD, SOM_SLEEP_WAKE_Pin|SOM_FORCE_RECOVERY_Pin, GPIO_PIN_SET); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port, SOM_SYS_RESET_Pin, GPIO_PIN_SET); - /*Configure GPIO pins : PEPin PEPin PEPin PEPin PEPin */ GPIO_InitStruct.Pin = SYS_POWER_LED_CTL_Pin|PMB_PS_ON_Pin|SYS_FAN_CTL_1_Pin|SYS_FAN_CTL_2_Pin @@ -131,9 +128,9 @@ void MX_GPIO_Init(void) HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pins : PBPin PBPin PBPin PBPin - PBPin PBPin PBPin */ + PBPin PBPin */ GPIO_InitStruct.Pin = IIC2_SCL_Pin|IIC2_SDA_Pin|USB2_VBUS_CTL_1_Pin|USB2_VBUS_CTL_2_Pin - |USB2_VBUS_CTL_3_Pin|USB2_VBUS_CTL_4_Pin|SOM_SYS_RESET_Pin; + |USB2_VBUS_CTL_3_Pin|USB2_VBUS_CTL_4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; @@ -171,22 +168,18 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(SOM_SHUTDOWN_REQ_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : PtPin */ + GPIO_InitStruct.Pin = SOM_SYS_RESET_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(SOM_SYS_RESET_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = SOM_MOD_SLEEP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(SOM_MOD_SLEEP_GPIO_Port, &GPIO_InitStruct); - /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI0_IRQn); - - HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI3_IRQn); - - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); - } /* USER CODE BEGIN 2 */