Skip to content

Commit 8a938ea

Browse files
committed
STM serial free: Set pin function only if pin is defined (not NC)
1 parent dc63202 commit 8a938ea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

targets/TARGET_STM/serial_api.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,13 @@ void serial_free(serial_t *obj)
355355
#endif /* DUAL_CORE */
356356

357357
// Configure GPIOs
358-
pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
359-
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
358+
if (obj_s->pin_tx != NC) {
359+
pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
360+
}
361+
362+
if (obj_s->pin_rx != NC) {
363+
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
364+
}
360365

361366
serial_irq_ids[obj_s->index] = 0;
362367
}

0 commit comments

Comments
 (0)