Skip to content

Commit 31d30ad

Browse files
committed
blackpill-f4: Enable internal weak pull-up on nRST, simplify set_val
1 parent 2112748 commit 31d30ad

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/platforms/common/blackpill-f4/blackpill-f4.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ void platform_init(void)
112112
gpio_set(TRST_PORT, TRST_PIN);
113113
gpio_mode_setup(TRST_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, TRST_PIN);
114114
gpio_set_output_options(TRST_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, TRST_PIN);
115+
/* Pull up nRST pin */
116+
gpio_set(NRST_PORT, NRST_PIN);
117+
gpio_mode_setup(NRST_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, NRST_PIN);
118+
gpio_set_output_options(NRST_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, NRST_PIN);
115119

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

145149
void platform_nrst_set_val(bool assert)
146150
{
147-
if (assert) {
148-
gpio_mode_setup(NRST_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, NRST_PIN);
149-
gpio_set_output_options(NRST_PORT, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, NRST_PIN);
150-
gpio_clear(NRST_PORT, NRST_PIN);
151-
} else {
152-
gpio_mode_setup(NRST_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, NRST_PIN);
153-
gpio_set(NRST_PORT, NRST_PIN);
154-
}
151+
gpio_set_val(NRST_PORT, NRST_PIN, !assert);
155152
}
156153

157154
bool platform_nrst_get_val(void)

0 commit comments

Comments
 (0)