Change parity on UART using LL API during runtime / after init
I need to change the UART parity from a FREERTOS task.
I also use interrupt per byte received.
Do I need to disable UART and interrupt before changing the parity?
I use LL API.
So what I do so far:
initialized_ = false; // Set initialized to false so interrupt handler will not touch flags which causes a hang
LL_USART_DisableIT_RXNE(uartHandle_); // Disable interrupt
LL_USART_Disable(uartHandle_);
auto parity = evenParity ? LL_USART_PARITY_EVEN : LL_USART_PARITY_NONE;
LL_USART_SetParity(uartHandle_, parity);
LL_USART_Enable(uartHandle_);
LL_USART_EnableIT_RXNE(uartHandle_); // Enable interrupt again
currentIndex_ = 0;
initialized_ = true;interrupt handler:
void Process()
{
if (!initialized_ || !LL_USART_IsActiveFlag_RXNE(uartHandle_) || !LL_USART_IsEnabledIT_RXNE(uartHandle_))
return;
// do stuff
}Am I overdoing it ? Code docs say nothing about how to change these parameters "on the fly" after the program is initialized and running, and I can't find any documentation what it takes to make the changes go into effect in a graceful way.
Thanks! :)
