From a58d17000e8ade8090c27d170f09f0d321ab83c9 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Sat, 19 Jun 2021 23:59:43 +0800 Subject: [PATCH] Add ADC lost drivers --- src/ISKv1/Core/Src/gpio.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 43 insertions(+), 1 deletions(-) diff --git a/src/ISKv1/Core/Src/gpio.c b/src/ISKv1/Core/Src/gpio.c index de202e6..ae10027 100644 --- a/src/ISKv1/Core/Src/gpio.c +++ b/src/ISKv1/Core/Src/gpio.c @@ -45,8 +45,8 @@ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, W1Dat_Pin|Relay_Pin, GPIO_PIN_RESET); @@ -56,6 +56,12 @@ /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, GreenLed_Pin|BlueLed_Pin|SysLed_Pin, GPIO_PIN_SET); + + /*Configure GPIO pins : PAPin PAPin */ + GPIO_InitStruct.Pin = Key1_Pin|Key2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = W1Dat_Pin; @@ -77,6 +83,22 @@ GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(RedLed_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : PtPin */ + GPIO_InitStruct.Pin = Key3_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(Key3_GPIO_Port, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI0_IRQn); + + HAL_NVIC_SetPriority(EXTI1_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI1_IRQn); + + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); } @@ -131,6 +153,26 @@ HAL_GPIO_WritePin(Relay_GPIO_Port, Relay_Pin, level); } +/* Description: Key1, Key2, Key3 IRQ Handler callback function.*/ +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) +{ + switch( GPIO_Pin ) + { + case Key1_Pin: + blink_led(RedLed, 500); + break; + + case Key2_Pin: + blink_led(GreenLed, 500); + break; + + case Key3_Pin: + blink_led(BlueLed, 500); + break; + } + +} + /* USER CODE END 2 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ -- Gitblit v1.9.1