Skip to content

Commit

Permalink
blackpill-f4: Enable internal weak pull-up on nRST, simplify set_val
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Feb 2, 2025
1 parent f4e79b6 commit 9394c34
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/platforms/common/blackpill-f4/blackpill-f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ void platform_init(void)
gpio_set(TRST_PORT, TRST_PIN);
gpio_mode_setup(TRST_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, TRST_PIN);
gpio_set_output_options(TRST_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, TRST_PIN);
/* Pull up nRST pin */
gpio_set(NRST_PORT, NRST_PIN);
gpio_mode_setup(NRST_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, NRST_PIN);
gpio_set_output_options(NRST_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, NRST_PIN);

/* Set up LED pins */
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_IDLE_RUN | LED_ERROR);
Expand Down Expand Up @@ -144,14 +148,7 @@ void platform_init(void)

void platform_nrst_set_val(bool assert)
{
if (assert) {
gpio_mode_setup(NRST_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, NRST_PIN);
gpio_set_output_options(NRST_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, NRST_PIN);
gpio_clear(NRST_PORT, NRST_PIN);
} else {
gpio_mode_setup(NRST_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, NRST_PIN);
gpio_set(NRST_PORT, NRST_PIN);
}
gpio_set_val(NRST_PORT, NRST_PIN, !assert);
}

bool platform_nrst_get_val(void)
Expand Down

0 comments on commit 9394c34

Please sign in to comment.