Merge pull request #12237 from mprse/stm_serial_free_fix

STM serial free: Set pin function only if pin is defined (not NC)
pull/12245/head
Martin Kojtal 2020-01-15 13:02:20 +01:00 committed by GitHub
commit 88f48d240e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -355,8 +355,13 @@ void serial_free(serial_t *obj)
#endif /* DUAL_CORE */
// Configure GPIOs
pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
if (obj_s->pin_tx != NC) {
pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
}
if (obj_s->pin_rx != NC) {
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
}
serial_irq_ids[obj_s->index] = 0;
}