Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoReconfigure HAL UART baud rates without port teardown
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
uartSetBaudRate() went through uartReconfigure(), which starts with HAL_UART_DeInit(). That releases the peripheral and its pins, and the line noise it leaves behind is read as data by whatever is on the other end. A u-blox receiver stops taking input for about a second after hearing it, which is long enough to swallow the commands that follow. On a bench with a NEO-F10N, a sequence that only changed the port's rate before speaking to the receiver reached it 3 times out of 10; with the configuration done in place it reached it 10 times out of 10. Everything but the tear-down is now in uartConfigure(), which HAL_UART_Init() is happy to be called with again: it reconfigures a port that is already open and leaves the pins alone. Opening a port and changing its mode or options still go through the full reconfigure. A port reprogrammed in place still has its interrupts enabled, so they are masked for the duration: one taken while the HAL has the handle marked busy would find the peripheral half written. The function enables them again at its end, as it already did. A port being opened has no handle yet and nothing to mask. Only the HAL families are affected. The F4 and AT32 drivers already disable the peripheral and reprogram it without releasing anything.
12eac16 to
2a3be52
Compare
|
Good catch, thank you. The interrupt sources are now masked before the peripheral is reprogrammed, and enabled again at the end of the same function, which it already did for the rest. A port being opened has no handle yet, so there is nothing to mask and the masking is skipped. Measured again on the bench after the change, with a NEO-F10N on an H743: ten baud rate changes out of ten, no timeouts. |
What this fixes
uartSetBaudRate()goes throughuartReconfigure(), which starts withHAL_UART_DeInit().That releases the peripheral and its pins, and the line noise it leaves behind is read as
data by whatever is on the other end.
A u-blox receiver stops taking input for about a second after hearing it. On an H743 bench
with a NEO-F10N, a sequence that only stepped the port through other rates before speaking
to the receiver at its own rate reached it 3 times out of 10. With the port reconfigured in
place, the same sequence reached it 10 times out of 10.
Anything else INAV changes the rate of is exposed to the same noise, including the SRXL2 ESC
driver, which raises the bus to 400000 once the handshake is done.
What I changed
Everything but the tear-down now lives in
uartConfigure().HAL_UART_Init()is happy to becalled on a port that is already open: it reconfigures the peripheral and leaves the pins
alone. Opening a port, and changing its mode or options, still go through the full
reconfigure, tear-down included.
Only the HAL families are affected. The F4 and AT32 drivers already disable the peripheral
and reprogram it without releasing anything.
Testing
Bench measurement above, on an H743 with a NEO-F10N. Built for F722 and H743; F405 and AT32
are untouched by this change but were built as well.