summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-07-20 22:41:45 +0700
committerhathach <[email protected]>2019-07-20 22:41:45 +0700
commited698069d37dbea2146960ceda246c07585747c3 (patch)
treec4c20c51119238dc6c8a09925f338b2f8853bb10
parent6ec87071ed4329b9ff7a220176ed008885e81ebe (diff)
clean up
-rw-r--r--hw/bsp/stm32f303disco/board_stm32f303disco.c13
-rw-r--r--hw/bsp/stm32f411disco/board_stm32f411disco.c9
2 files changed, 11 insertions, 11 deletions
diff --git a/hw/bsp/stm32f303disco/board_stm32f303disco.c b/hw/bsp/stm32f303disco/board_stm32f303disco.c
index 9a103ac60..ce56fa7e2 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 3f5f9cf87..a4a918b05 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)