diff --git a/src/platforms/common/blackpill-f4/blackpill-f4.c b/src/platforms/common/blackpill-f4/blackpill-f4.c index db3433143d1..129f47f4aed 100644 --- a/src/platforms/common/blackpill-f4/blackpill-f4.c +++ b/src/platforms/common/blackpill-f4/blackpill-f4.c @@ -51,10 +51,10 @@ void platform_init(void) #ifndef BMP_BOOTLOADER /* Blackpill board has a floating button on PA0. Pull it up and use as active-low. */ - gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO0); + gpio_mode_setup(USER_BUTTON_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, USER_BUTTON_PIN); /* Check the USER button */ - if (!gpio_get(GPIOA, GPIO0) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { + if (!gpio_get(USER_BUTTON_PORT, USER_BUTTON_PIN) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { magic[0] = 0; magic[1] = 0; /* Assert blue LED as indicator we are in the bootloader */ diff --git a/src/platforms/common/blackpill-f4/blackpill-f4.h b/src/platforms/common/blackpill-f4/blackpill-f4.h index 763341c4c65..5654f2aba1b 100644 --- a/src/platforms/common/blackpill-f4/blackpill-f4.h +++ b/src/platforms/common/blackpill-f4/blackpill-f4.h @@ -103,6 +103,9 @@ #define PWR_BR_PORT PINOUT_SWITCH(GPIOA, GPIOB) #define PWR_BR_PIN PINOUT_SWITCH(GPIO1, GPIO9) +#define USER_BUTTON_PORT GPIOA +#define USER_BUTTON_PIN GPIO0 + #define LED_PORT GPIOC #define LED_IDLE_RUN GPIO13 #define LED_ERROR GPIO14 diff --git a/src/platforms/common/blackpill-f4/usbdfu.c b/src/platforms/common/blackpill-f4/usbdfu.c index a116e41e904..4cc0f721956 100644 --- a/src/platforms/common/blackpill-f4/usbdfu.c +++ b/src/platforms/common/blackpill-f4/usbdfu.c @@ -41,9 +41,9 @@ int main(void) rcc_periph_clock_enable(RCC_GPIOA); /* Blackpill board has a floating button on PA0. Pull it up and use as active-low. */ - gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO0); + gpio_mode_setup(USER_BUTTON_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, USER_BUTTON_PIN); - if (!gpio_get(GPIOA, GPIO0) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { + if (!gpio_get(USER_BUTTON_PORT, USER_BUTTON_PIN) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { magic[0] = 0; magic[1] = 0; } else