STM32 LLD for UART with bus idle detection
Posted: Wed Oct 04, 2017 4:38 pm
Hello Giovanni,
I would like to upvote this feature also as we need free bus detection for our RS-485 implementation.
In addition to checking USART_SR_IDLE, it would be necessary to check the BUSY flag (bit 16) in USART_ISR register also, since USART_SR_IDLE is only set by hardware once an idle condition is present and is not cleared in case the bus becomes busy in the meantime. So, I would propose:
BUSY flag is hardcoded (0x10000U) since CMSIS header does not provide it.
What do you think?
I would like to upvote this feature also as we need free bus detection for our RS-485 implementation.
In addition to checking USART_SR_IDLE, it would be necessary to check the BUSY flag (bit 16) in USART_ISR register also, since USART_SR_IDLE is only set by hardware once an idle condition is present and is not cleared in case the bus becomes busy in the meantime. So, I would propose:
Code: Select all
/* Timeout interrupt source is only checked if enabled in CR1 and if BUSY flag is not set.*/
if ((sr & USART_ISR_IDLE) && (cr1 & USART_CR1_IDLEIE) && (sr & 0x10000U) {
_uart_timeout_isr_code(uartp);
}
BUSY flag is hardcoded (0x10000U) since CMSIS header does not provide it.
What do you think?