Skip to content

Commit

Permalink
platforms/blackpill-f4: define user button port and pin
Browse files Browse the repository at this point in the history
  • Loading branch information
lenvm authored and dragonmux committed Oct 29, 2023
1 parent fd9beb1 commit 3aad9ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/platforms/common/blackpill-f4/blackpill-f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/common/blackpill-f4/blackpill-f4.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,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
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/common/blackpill-f4/usbdfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3aad9ee

Please sign in to comment.