Page 2 of 2
Re: UART line idle handling.
Posted: Wed Jul 20, 2016 7:46 pm
by barthess
1) User have to explicitly set appropriate flags in CRx registers to get timeout interrupt/callback. If user wants old (without timeout) behaviour than he just fill new fields in config structure to NULL/0 values. No other changes needed.
2) Added it. Any way I do not use synchronous API for UART and can not evaluate its convenience in appliance to timeout. Hope it will be useful.
Re: UART line idle handling.
Posted: Wed Jul 20, 2016 7:54 pm
by Giovanni
Hi,
It looks good so far, thanks, it is a very useful feature.
Giovanni
Re: UART line idle handling.
Posted: Fri Jul 22, 2016 10:57 am
by barthess
@Giovanni
Why this checks needed?
Code: Select all
(cr1 & USART_CR1_IDLEIE) (cr1 & USART_CR1_RTOIE)
They are redundant from my point of view. May be any errata notes I am missed?
Re: UART line idle handling.
Posted: Fri Jul 22, 2016 11:07 am
by Giovanni
We don't want to serve those interrupt flags if not explicitly enabled in CR1. Without those checks you could spuriously call the timeout callback when another kind of error triggers the ISR.
Giovanni
Re: UART line idle handling.
Posted: Sat Jun 03, 2017 7:00 pm
by kimmoli
Noticed that IDLE interrupt mechanism is missing from USARTv1, altough atleast F4 USART has this functionality.
I think adding support would be a simple task (see below). We will test this on monday with DMA reception, but afaiu the callback definition (_uart_timeout_isr_code()) is in the include that is common for both.
https://github.com/kimmoli/ChibiOS/comm ... 89ca7707c7Or am i missing something?
(apologies for necromancing an old thread)
Re: UART line idle handling.
Posted: Sat Jun 03, 2017 8:29 pm
by Giovanni
It should work, it is just missing.
Giovanni
Re: UART line idle handling.
Posted: Mon Jun 05, 2017 2:11 pm
by kimmoli
Although my changes had some errors... missing the timeout_cb from USARTConfig struct, and typo in USART_ISR_IDLE (Should be USART_SR_IDLE)
(
https://github.com/kimmoli/ChibiOS/commits/usartv1_idle)
Re: UART line idle handling.
Posted: Sun Sep 17, 2017 12:20 pm
by Korken
Hi Giovanni,
Will you add this? It does not seems to have been added to trunk.
Re: UART line idle handling.
Posted: Wed Oct 04, 2017 4:13 pm
by michael_s
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 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?
Re: UART line idle handling.
Posted: Wed Oct 04, 2017 4:16 pm
by Giovanni
Hi,
Could you please post it in the "change requests" forum? it is hard to remember all posts.
"bug reports" and "change requests" are actively monitored.
Giovanni