diff --git a/src/platforms/common/blackpill-f4/blackpill-f4.c b/src/platforms/common/blackpill-f4/blackpill-f4.c index db3433143d1..225f6d830b2 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_KEY_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, USER_BUTTON_KEY_PIN); /* Check the USER button */ - if (!gpio_get(GPIOA, GPIO0) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { + if (!gpio_get(USER_BUTTON_KEY_PORT, USER_BUTTON_KEY_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 649b6d83a63..137430df9cf 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_KEY_PORT GPIOA +#define USER_BUTTON_KEY_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..b32afce068d 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_KEY_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, USER_BUTTON_KEY_PIN); - if (!gpio_get(GPIOA, GPIO0) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { + if (!gpio_get(USER_BUTTON_KEY_PORT, USER_BUTTON_KEY_PIN) || (magic[0] == BOOTMAGIC0 && magic[1] == BOOTMAGIC1)) { magic[0] = 0; magic[1] = 0; } else