espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.84k stars 7.32k forks source link

TWAI driver with support for minimum inter-frame-delay (µs granularity) (IDFGH-11095) #12267

Open mickeyl opened 1 year ago

mickeyl commented 1 year ago

Many automotive systems (e.g. ISOTP as per ISO 15765-2) require a minimum inter-frame-delay when transmitting consecutive CAN frames.

Since TWAI is using an outgoing queue, it's not possible to achieve this inter-frame-delay outside the TWAI driver, in particular, when µs-granularity is a requirement.

Since work on a new TWAI driver is underway (see post by @wanckl in https://github.com/espressif/esp-idf/issues/10423#issuecomment-1724779541), let me use this opportunity to file an enhancement request for this.

I'll probably hack away, since I have an immediate need for this feature, but official support in the TWAI driver would be nicer.

mickeyl commented 1 year ago

There's a bit of discussion about that going on @ https://www.esp32.com/viewtopic.php?f=12&t=35520

I think I know where to approach that (in twai_handle_tx_buffer_frame), but I'm a bit out of my depth as to how to create a timer that creates the proper IRQ and event so that I can delay the call to twai_hal_set_tx_buffer_and_transmit.

mickeyl commented 1 year ago

Please also see https://github.com/espressif/esp-idf/issues/12316 which indicates very unstable TWAI timing.

r90548039 commented 3 months ago

Is there any progress on this request? Is it possible to use interrupts for reception?