Skip to content

Commit c877365

Browse files
authored
Merge pull request #13862 from jeromecoutant/PR_RTS_FREE
STM32 SERIAL: free RTS/CTS pins
2 parents 61bed01 + 73d1c63 commit c877365

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

targets/TARGET_STM/TARGET_STM32L4/serial_device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con
667667
if (type == FlowControlRTS) {
668668
// Enable RTS
669669
MBED_ASSERT(pinmap->rx_flow_pin != NC);
670+
obj_s->hw_flow_ctl = UART_HWCONTROL_RTS;
670671
obj_s->pin_rts = pinmap->rx_flow_pin;
671672
// Enable the pin for RTS function
672673
pin_function(pinmap->rx_flow_pin, pinmap->rx_flow_function);

targets/TARGET_STM/serial_api.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,15 @@ void serial_free(serial_t *obj)
355355

356356
pin_function(obj_s->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
357357

358+
#if DEVICE_SERIAL_FC
359+
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));
361+
}
362+
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));
364+
}
365+
#endif
366+
358367
serial_irq_ids[obj_s->index] = 0;
359368
}
360369

0 commit comments

Comments
 (0)