Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: platforms/blackpill-f4: define user button port and pin #1647

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
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