Hi
Does anyone know is there is a version of the TWR code ported to esp-idf? I have the Arduino version running but would like to develop the code in native esp-idf framework.
I just ported the DW3000 driver to ESP-IDF. While it’s not intended to be open-sourced I can give you some advices/things I’ve found :
You are now fighting with freeRTOS’ preemptive task handling. Chances that your code doesn’t work as intended are great. You have to follow these simple rules:
Use interrupts if possible. If not make it possible.
Follow this method to make sure your SPI transactions will run smoothly.
Use polling SPI transactions.
This way you’ll be able to keep POLL_RX_TO_RESP_TX_DLY_UUS pretty low (around 550~600 if used w/ wifi, 450 w/out but on DW3000 it may differ).
Beware of too high SPI transfer rate. I don’t know about the DW1000 but I can’t make the SPI bus run faster than 33MHz with the DW3000. It’s said to work at 38MHz but it won’t.
Pin all task related to SPI to core 0. On core 1 there’s some overhead making it unusable.
If you use wifi pin wifi task to core 1 (in menu config) or you’ll suffer bad performances and lost packets.
There’s no need to raise the tick rate above 100Hz for this purpose only. But you can still do f you need to.
I still didn’t bother to optimize SPI transactions w/ DMA so you can save it for later. It will work event if you don’t align data correctly to work w/ DMA.
Make sure you know your way around tasks, queue and concurrency in general.