HAL_ChibiOS: implement set_RTS/CTS_pin methods

This commit is contained in:
Andrew Tridgell 2021-07-08 16:35:58 +10:00
parent 162cecadec
commit 4ed0b03f35
2 changed files with 45 additions and 0 deletions

View File

@ -1699,6 +1699,44 @@ void UARTDriver::uart_info(ExpandingString &str)
_last_stats_ms = now_ms;
}
/*
software control of the CTS pin if available. Return false if
not available
*/
bool UARTDriver::set_CTS_pin(bool high)
{
if (_flow_control != FLOW_CONTROL_DISABLE) {
// CTS pin is being used
return false;
}
if (sdef.cts_line == 0) {
// we don't have a CTS pin on this UART
return false;
}
palSetLineMode(sdef.cts_line, 1);
palWriteLine(sdef.cts_line, high?1:0);
return true;
}
/*
software control of the RTS pin if available. Return false if
not available
*/
bool UARTDriver::set_RTS_pin(bool high)
{
if (_flow_control != FLOW_CONTROL_DISABLE) {
// RTS pin is being used
return false;
}
if (sdef.rts_line == 0) {
// we don't have a RTS pin on this UART
return false;
}
palSetLineMode(sdef.rts_line, 1);
palWriteLine(sdef.rts_line, high?1:0);
return true;
}
#if HAL_USE_SERIAL_USB == TRUE
/*
initialise the USB bus, called from both UARTDriver and stdio for startup debug

View File

@ -107,6 +107,13 @@ public:
void configure_parity(uint8_t v) override;
void set_stop_bits(int n) override;
/*
software control of the CTS/RTS pins if available. Return false if
not available
*/
bool set_RTS_pin(bool high) override;
bool set_CTS_pin(bool high) override;
/*
return timestamp estimate in microseconds for when the start of
a nbytes packet arrived on the uart. This should be treated as a