From 31d30ada18862cdf44ae7ed798325cb7366d05e0 Mon Sep 17 00:00:00 2001 From: ALTracer <11005378+ALTracer@users.noreply.github.com> Date: Wed, 29 Jan 2025 21:42:10 +0300 Subject: [PATCH] blackpill-f4: Enable internal weak pull-up on nRST, simplify set_val --- src/platforms/common/blackpill-f4/blackpill-f4.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/platforms/common/blackpill-f4/blackpill-f4.c b/src/platforms/common/blackpill-f4/blackpill-f4.c index 43cc09c1b1e..702e09fc1f0 100644 --- a/src/platforms/common/blackpill-f4/blackpill-f4.c +++ b/src/platforms/common/blackpill-f4/blackpill-f4.c @@ -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); @@ -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)