From 9f06aad6f54def35140b7a4e9bc3f763b4ef0347 Mon Sep 17 00:00:00 2001 From: IOsetting Date: Thu, 2 Mar 2023 09:42:17 +0800 Subject: [PATCH] refactor: ll remove unused button bsp functions --- Examples/LL/GPIO/EXTI_Toggle/main.c | 1 - Examples/LL/GPIO/LED_Toggle/main.c | 1 - Examples/LL/RCC/HSE_ClockConfigurate/main.c | 1 - .../LL/RCC/HSE_PLL_ClockConfigurate/main.c | 1 - Examples/LL/RCC/HSI_Output/main.c | 1 - Examples/LL/SEGGER_RTT/main.c | 1 - Libraries/BSP_LL/Inc/py32f0xx_bsp_button.h | 80 ------------------- Libraries/BSP_LL/Src/py32f0xx_bsp_button.c | 69 ---------------- 8 files changed, 155 deletions(-) delete mode 100644 Libraries/BSP_LL/Inc/py32f0xx_bsp_button.h delete mode 100644 Libraries/BSP_LL/Src/py32f0xx_bsp_button.c diff --git a/Examples/LL/GPIO/EXTI_Toggle/main.c b/Examples/LL/GPIO/EXTI_Toggle/main.c index 0c423dd..dc5a64b 100644 --- a/Examples/LL/GPIO/EXTI_Toggle/main.c +++ b/Examples/LL/GPIO/EXTI_Toggle/main.c @@ -2,7 +2,6 @@ * Demo: EXTI Interrupt */ #include "main.h" -#include "py32f0xx_bsp_button.h" #include "py32f0xx_bsp_led.h" #include "py32f0xx_bsp_printf.h" diff --git a/Examples/LL/GPIO/LED_Toggle/main.c b/Examples/LL/GPIO/LED_Toggle/main.c index ea86c00..c4fa63d 100644 --- a/Examples/LL/GPIO/LED_Toggle/main.c +++ b/Examples/LL/GPIO/LED_Toggle/main.c @@ -22,7 +22,6 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" -#include "py32f0xx_bsp_button.h" #include "py32f0xx_bsp_led.h" #include "py32f0xx_bsp_printf.h" diff --git a/Examples/LL/RCC/HSE_ClockConfigurate/main.c b/Examples/LL/RCC/HSE_ClockConfigurate/main.c index 5241381..e1f3574 100644 --- a/Examples/LL/RCC/HSE_ClockConfigurate/main.c +++ b/Examples/LL/RCC/HSE_ClockConfigurate/main.c @@ -1,5 +1,4 @@ #include "main.h" -#include "py32f0xx_bsp_button.h" #include "py32f0xx_bsp_led.h" #include "py32f0xx_bsp_printf.h" diff --git a/Examples/LL/RCC/HSE_PLL_ClockConfigurate/main.c b/Examples/LL/RCC/HSE_PLL_ClockConfigurate/main.c index ac22615..e653e8c 100644 --- a/Examples/LL/RCC/HSE_PLL_ClockConfigurate/main.c +++ b/Examples/LL/RCC/HSE_PLL_ClockConfigurate/main.c @@ -1,5 +1,4 @@ #include "main.h" -#include "py32f0xx_bsp_button.h" #include "py32f0xx_bsp_led.h" #include "py32f0xx_bsp_printf.h" diff --git a/Examples/LL/RCC/HSI_Output/main.c b/Examples/LL/RCC/HSI_Output/main.c index 96dd86f..9bef677 100644 --- a/Examples/LL/RCC/HSI_Output/main.c +++ b/Examples/LL/RCC/HSI_Output/main.c @@ -1,5 +1,4 @@ #include "main.h" -#include "py32f0xx_bsp_button.h" #include "py32f0xx_bsp_led.h" #include "py32f0xx_bsp_printf.h" diff --git a/Examples/LL/SEGGER_RTT/main.c b/Examples/LL/SEGGER_RTT/main.c index 2f1481e..def5bb8 100644 --- a/Examples/LL/SEGGER_RTT/main.c +++ b/Examples/LL/SEGGER_RTT/main.c @@ -1,5 +1,4 @@ #include "main.h" -#include "py32f0xx_bsp_button.h" #include "py32f0xx_bsp_led.h" #include "py32f0xx_bsp_printf.h" #include "SEGGER_RTT.h" diff --git a/Libraries/BSP_LL/Inc/py32f0xx_bsp_button.h b/Libraries/BSP_LL/Inc/py32f0xx_bsp_button.h deleted file mode 100644 index f174dd0..0000000 --- a/Libraries/BSP_LL/Inc/py32f0xx_bsp_button.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - ****************************************************************************** - * @file py32f0xx_bsp_button.h - * @author MCU Application Team - * @brief - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef PY32F003_BSP_BUTTON_H -#define PY32F003_BSP_BUTTON_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ - -#include -#include "py32f0xx_ll_rcc.h" -#include "py32f0xx_ll_bus.h" -#include "py32f0xx_ll_system.h" -#include "py32f0xx_ll_exti.h" -#include "py32f0xx_ll_cortex.h" -#include "py32f0xx_ll_utils.h" -#include "py32f0xx_ll_pwr.h" -#include "py32f0xx_ll_dma.h" -#include "py32f0xx_ll_gpio.h" -#include "py32f0xx_ll_usart.h" - -typedef enum -{ - BUTTON_USER = 0, - /* Alias */ - BUTTON_KEY = BUTTON_USER -} Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -} ButtonMode_TypeDef; - - - -#define BUTTONn 1 - -/** - * @brief User push-button - */ -#define USER_BUTTON_PIN LL_GPIO_PIN_12 -#define USER_BUTTON_GPIO_PORT GPIOA -#define USER_BUTTON_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA) -#define USER_BUTTON_GPIO_CLK_DISABLE() LL_IOP_GRP1_DisableClock(LL_IOP_GRP1_PERIPH_GPIOA) -#define USER_BUTTON_EXTI_IRQn EXTI4_15_IRQn -#define USER_BUTTON_EXTI_LINE LL_EXTI_LINE_12 -#define USER_BUTTON_EXTI_LINE_ENABLE() LL_EXTI_EnableIT(USER_BUTTON_EXTI_LINE) -#define USER_BUTTON_EXTI_FALLING_TRIG_ENABLE() LL_EXTI_EnableFallingTrig(USER_BUTTON_EXTI_LINE) -#define USER_BUTTON_IRQHANDLER EXTI4_15_IRQHandler - -/* Aliases */ -#define KEY_BUTTON_PIN USER_BUTTON_PIN -#define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT -#define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE() -#define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE() -#define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn - -#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) USER_BUTTON_GPIO_CLK_ENABLE();} while(0) -#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? USER_BUTTON_GPIO_CLK_DISABLE() : 0) - - -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); -void BSP_PB_DeInit(Button_TypeDef Button); -uint32_t BSP_PB_GetState(Button_TypeDef Button); - -#ifdef __cplusplus -} -#endif - -#endif /* PY32F003_BSP_BUTTON_H */ diff --git a/Libraries/BSP_LL/Src/py32f0xx_bsp_button.c b/Libraries/BSP_LL/Src/py32f0xx_bsp_button.c deleted file mode 100644 index 70169ad..0000000 --- a/Libraries/BSP_LL/Src/py32f0xx_bsp_button.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "py32f0xx_bsp_button.h" - - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT }; -const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN }; -const uint8_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn }; -const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {USER_BUTTON_EXTI_LINE }; - - - -/** - * @brief Configures Button GPIO and EXTI Line. - * @param Button: Specifies the Button to be configured. - * This parameter should be: BUTTON_USER - * @param ButtonMode: Specifies Button mode. - * This parameter can be one of following parameters: - * @arg BUTTON_MODE_GPIO: Button will be used as simple IO - * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt - * generation capability - * @retval None - */ -void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode) -{ - /* Enable the BUTTON Clock */ - BUTTONx_GPIO_CLK_ENABLE(Button); - - /* Configure GPIO for BUTTON */ - LL_GPIO_SetPinMode(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_MODE_INPUT); - LL_GPIO_SetPinPull(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_PULL_NO); - /* LL_GPIO_SetPinSpeed(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_SPEED_FREQ_HIGH); */ - - if(ButtonMode == BUTTON_MODE_EXTI) - { - /* Configure Button pin as input with External interrupt */ - LL_EXTI_EnableIT(BUTTON_EXTI_LINE[Button]); - LL_EXTI_EnableFallingTrig(BUTTON_EXTI_LINE[Button]); - - /* Enable and set Button EXTI Interrupt to the lowest priority */ - NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F); - NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - } -} - -/** - * @brief Push Button DeInit. - * @param Button: Button to be configured - * This parameter should be: BUTTON_USER - * @note PB DeInit does not disable the GPIO clock - * @retval None - */ -void BSP_PB_DeInit(Button_TypeDef Button) -{ - NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); - LL_GPIO_SetPinMode(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_MODE_ANALOG); - /* LL_GPIO_SetPinSpeed(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_SPEED_FREQ_LOW); */ - /* LL_GPIO_SetPinPull(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_PULL_NO); */ - /* LL_GPIO_SetAFPin_8_15(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_AF_0); */ -} - -/** - * @brief Returns the selected Button state. - * @param Button: Specifies the Button to be checked. - * This parameter should be: BUTTON_USER - * @retval Button state. - */ -uint32_t BSP_PB_GetState(Button_TypeDef Button) -{ - return LL_GPIO_IsInputPinSet(BUTTON_PORT[Button], BUTTON_PIN[Button]); -}