From 793b5d239099c44583811f36a02db32ab439d561 Mon Sep 17 00:00:00 2001 From: bookshiyi Date: Mon, 24 Aug 2020 11:36:08 +0800 Subject: [PATCH] add power status check config --- .settings/language.settings.xml | 4 +- Core/Inc/main.h | 9 ++++ Core/Src/gpio.c | 6 +++ Core/Src/stm32f1xx_it.c | 3 ++ NaviKit_stm32.ioc | 77 +++++++++++++++++++++------------ 5 files changed, 69 insertions(+), 30 deletions(-) diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 540387d..15242bb 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/Core/Inc/main.h b/Core/Inc/main.h index ff7b0ae..aea65bf 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -134,6 +134,15 @@ void Error_Handler(void); #define USB3_VBUS_CTL_3_GPIO_Port GPIOD #define USB3_VBUS_CTL_4_Pin GPIO_PIN_15 #define USB3_VBUS_CTL_4_GPIO_Port GPIOD +#define SOC_U3_HOST_PWR_STA_Pin GPIO_PIN_6 +#define SOC_U3_HOST_PWR_STA_GPIO_Port GPIOC +#define SOC_U3_HOST_PWR_STA_EXTI_IRQn EXTI9_5_IRQn +#define SOC_U3_HUB_PWR_STA_Pin GPIO_PIN_7 +#define SOC_U3_HUB_PWR_STA_GPIO_Port GPIOC +#define SOC_U3_HUB_PWR_STA_EXTI_IRQn EXTI9_5_IRQn +#define SOC_U2_HUB_PWR_STA_Pin GPIO_PIN_8 +#define SOC_U2_HUB_PWR_STA_GPIO_Port GPIOC +#define SOC_U2_HUB_PWR_STA_EXTI_IRQn EXTI9_5_IRQn #define USB2_FS_ENUM_CTL_Pin GPIO_PIN_8 #define USB2_FS_ENUM_CTL_GPIO_Port GPIOA #define USB2_FS_DM_Pin GPIO_PIN_11 diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index be58c82..8ad7957 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -151,6 +151,12 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + /*Configure GPIO pins : PCPin PCPin PCPin */ + GPIO_InitStruct.Pin = SOC_U3_HOST_PWR_STA_Pin|SOC_U3_HUB_PWR_STA_Pin|SOC_U2_HUB_PWR_STA_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = USB2_FS_ENUM_CTL_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c index 44ef1aa..07e77e7 100644 --- a/Core/Src/stm32f1xx_it.c +++ b/Core/Src/stm32f1xx_it.c @@ -272,6 +272,9 @@ void EXTI9_5_IRQHandler(void) /* USER CODE END EXTI9_5_IRQn 0 */ HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); /* USER CODE BEGIN EXTI9_5_IRQn 1 */ /* USER CODE END EXTI9_5_IRQn 1 */ diff --git a/NaviKit_stm32.ioc b/NaviKit_stm32.ioc index 2ec2014..d67fb23 100644 --- a/NaviKit_stm32.ioc +++ b/NaviKit_stm32.ioc @@ -111,40 +111,43 @@ Mcu.Pin35=PD12 Mcu.Pin36=PD13 Mcu.Pin37=PD14 Mcu.Pin38=PD15 -Mcu.Pin39=PA8 +Mcu.Pin39=PC6 Mcu.Pin4=PE6 -Mcu.Pin40=PA11 -Mcu.Pin41=PA12 -Mcu.Pin42=PA13 -Mcu.Pin43=PA14 -Mcu.Pin44=PC10 -Mcu.Pin45=PC11 -Mcu.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,6 +325,18 @@ PC5.GPIO_Label=SYS_BUZZ_CTL PC5.Locked=true PC5.PinState=GPIO_PIN_SET PC5.Signal=GPIO_Output +PC6.GPIOParameters=GPIO_Label +PC6.GPIO_Label=SOC_U3_HOST_PWR_STA +PC6.Locked=true +PC6.Signal=GPXTI6 +PC7.GPIOParameters=GPIO_Label +PC7.GPIO_Label=SOC_U3_HUB_PWR_STA +PC7.Locked=true +PC7.Signal=GPXTI7 +PC8.GPIOParameters=GPIO_Label +PC8.GPIO_Label=SOC_U2_HUB_PWR_STA +PC8.Locked=true +PC8.Signal=GPXTI8 PD0.GPIOParameters=GPIO_Label PD0.GPIO_Label=SOC_U3_HUB_PWR_CTL PD0.Locked=true @@ -512,6 +527,12 @@ SH.GPXTI3.0=GPIO_EXTI3 SH.GPXTI3.ConfNb=1 SH.GPXTI5.0=GPIO_EXTI5 SH.GPXTI5.ConfNb=1 +SH.GPXTI6.0=GPIO_EXTI6 +SH.GPXTI6.ConfNb=1 +SH.GPXTI7.0=GPIO_EXTI7 +SH.GPXTI7.ConfNb=1 +SH.GPXTI8.0=GPIO_EXTI8 +SH.GPXTI8.ConfNb=1 UART4.IPParameters=VirtualMode UART4.VirtualMode=Asynchronous USART1.IPParameters=VirtualMode