mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-22 00:28:30 -04:00
AP_HAL_ChibiOS: ensure stop bits can be set before UART begin
This commit is contained in:
parent
bd8619a616
commit
5c32007cdf
@ -315,7 +315,9 @@ void UARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
||||
}
|
||||
sercfg.irq_cb = rx_irq_cb;
|
||||
#endif // HAL_UART_NODMA
|
||||
sercfg.cr2 |= USART_CR2_STOP1_BITS;
|
||||
if (!(sercfg.cr2 & USART_CR2_STOP2_BITS)) {
|
||||
sercfg.cr2 |= USART_CR2_STOP1_BITS;
|
||||
}
|
||||
sercfg.ctx = (void*)this;
|
||||
|
||||
sdStart((SerialDriver*)sdef.serial, &sercfg);
|
||||
@ -1303,12 +1305,15 @@ void UARTDriver::set_stop_bits(int n)
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
sercfg.cr2 = _cr2_options | USART_CR2_STOP1_BITS;
|
||||
_cr2_options &= ~USART_CR2_STOP2_BITS;
|
||||
_cr2_options |= USART_CR2_STOP1_BITS;
|
||||
break;
|
||||
case 2:
|
||||
sercfg.cr2 = _cr2_options | USART_CR2_STOP2_BITS;
|
||||
_cr2_options &= ~USART_CR2_STOP1_BITS;
|
||||
_cr2_options |= USART_CR2_STOP2_BITS;
|
||||
break;
|
||||
}
|
||||
sercfg.cr2 = _cr2_options;
|
||||
|
||||
sdStart((SerialDriver*)sdef.serial, &sercfg);
|
||||
#ifndef HAL_UART_NODMA
|
||||
|
Loading…
Reference in New Issue
Block a user