AP_HAL: Add support for parity to Serial passthrough

Add code to reflect USB ACM parity setting to the passthrough port alongside existing support for ACM baud rate changes.  Some use cases for serial passthrough require specific parity settings.

For example, even parity is used and required by the USART protocol used in the STM32 system bootloader. This enhancement allows the use of standard flash programming tools such as STM32CubeProgrammer to flash connected STM based peripherals such as Receivers and Telemetry radios via serial passthrough.  Some examples of such peripherals include the FrSky R9 receivers as well as various other STM based LoRa modules used by the mLRS project.
This commit is contained in:
Brad Bosch authored and Andrew Tridgell committed 2024-06-11 09:24:32 +10:00
1 parent da3a9c1cc6
commit f2f9349419
10 files changed
+57

No files matched your search

+14
View File
@@ -672,6 +672,19 @@ uint32_t UARTDriver::get_usb_baud() const
return 0;
}
/*
get the requested usb parity. Valid if get_usb_baud() returned non-zero.
*/
uint8_t UARTDriver::get_usb_parity() const
{
#if HAL_USE_SERIAL_USB
if (sdef.is_usb) {
return ::get_usb_parity(sdef.endpoint_id);
}
#endif
return 0;
}
uint32_t UARTDriver::_available()
{
if (!_rx_initialised || _uart_owner_thd != chThdGetSelfX()) {
@@ -1429,6 +1442,7 @@ void UARTDriver::configure_parity(uint8_t v)
// not possible
return;
}
UARTDriver::parity = v;
#if HAL_USE_SERIAL == TRUE
// stop and start to take effect
sdStop((SerialDriver*)sdef.serial);