Skip to content

Commit 20e9235

Browse files
committed
STM32 SERIAL : correct GPIO free
1 parent 10e0759 commit 20e9235

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

targets/TARGET_STM/serial_api.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,15 @@ void serial_free(serial_t *obj)
350350
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, HSEM_CR_COREID_CURRENT);
351351
#endif /* DUAL_CORE */
352352

353-
// Configure GPIOs
354-
pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
355-
356-
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
357-
353+
// Configure GPIOs back to reset value
354+
pin_function(obj_s->pin_tx, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0));
355+
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0));
358356
#if DEVICE_SERIAL_FC
359357
if ( (obj_s->hw_flow_ctl == UART_HWCONTROL_RTS) || (obj_s->hw_flow_ctl == UART_HWCONTROL_RTS_CTS) ) {
360-
pin_function(obj_s->pin_rts, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
358+
pin_function(obj_s->pin_rts, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0));
361359
}
362360
if ( (obj_s->hw_flow_ctl == UART_HWCONTROL_CTS) || (obj_s->hw_flow_ctl == UART_HWCONTROL_RTS_CTS) ) {
363-
pin_function(obj_s->pin_cts, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
361+
pin_function(obj_s->pin_cts, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0));
364362
}
365363
#endif
366364

0 commit comments

Comments
 (0)