From ed698069d37dbea2146960ceda246c07585747c3 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 20 Jul 2019 22:41:45 +0700 Subject: [PATCH] clean up --- hw/bsp/stm32f303disco/board_stm32f303disco.c | 13 +++++++++---- hw/bsp/stm32f411disco/board_stm32f411disco.c | 9 ++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/bsp/stm32f303disco/board_stm32f303disco.c b/hw/bsp/stm32f303disco/board_stm32f303disco.c index 9a103ac6..ce56fa7e 100644 --- a/hw/bsp/stm32f303disco/board_stm32f303disco.c +++ b/hw/bsp/stm32f303disco/board_stm32f303disco.c @@ -29,6 +29,9 @@ #include "stm32f3xx.h" #include "stm32f3xx_hal_conf.h" +#define LED_PORT GPIOE +#define LED_PIN GPIO_PIN_9 + void board_init(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; @@ -60,17 +63,19 @@ void board_init(void) SysTick_Config(SystemCoreClock / 1000); #endif - /* -1- Enable GPIOE Clock (to be able to program the configuration registers) */ + /* -1- Enable GPIO Clock (to be able to program the configuration registers) */ __HAL_RCC_GPIOE_CLK_ENABLE(); /* -2- Configure PE.8 to PE.15 IOs in output push-pull mode to drive external LEDs */ static GPIO_InitTypeDef GPIO_InitStruct; - GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Pin = LED_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct); + + board_led_write(false); #if 0 RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; @@ -97,7 +102,7 @@ void board_init(void) void board_led_write(bool state) { - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, state); + HAL_GPIO_WritePin(LED_PORT, LED_PIN, state); } uint32_t board_button_read(void) diff --git a/hw/bsp/stm32f411disco/board_stm32f411disco.c b/hw/bsp/stm32f411disco/board_stm32f411disco.c index 3f5f9cf8..a4a918b0 100644 --- a/hw/bsp/stm32f411disco/board_stm32f411disco.c +++ b/hw/bsp/stm32f411disco/board_stm32f411disco.c @@ -45,8 +45,7 @@ void board_init(void) HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct); - HAL_GPIO_WritePin(LED_PORT, LED_PIN, GPIO_PIN_RESET); - + board_led_write(false); #if 0 // Init the LED on PD14 @@ -112,11 +111,7 @@ void board_init(void) void board_led_write(bool state) { - if (!state) { - GPIOD->BSRR = GPIO_BSRR_BR14; - } else { - GPIOD->BSRR = GPIO_BSRR_BS14; - } + HAL_GPIO_WritePin(LED_PORT, LED_PIN, state); } uint32_t board_button_read(void)