esp-rs / esp-idf-hal

embedded-hal implementation for Rust on ESP32 and ESP-IDF
https://docs.esp-rs.org/esp-idf-hal/
Apache License 2.0
472 stars 171 forks source link

DAC support #28

Open ivmarkov opened 2 years ago

ivmarkov commented 2 years ago

Subject says it all :)

dtimm commented 8 months ago

This would require regenerating bindings with the 5.1 DAC driver files? I would like to work on this, but I'm not sure where to start.

Vollbrecht commented 8 months ago

you would need to add the headers needed to the esp-idf-sys bindings.h file with the appropriate gates.

Than you should be g2g and can start working on a safe wrapper for it.

dtimm commented 8 months ago

Created https://github.com/esp-rs/esp-idf-sys/pull/289 to get this into esp-idf-sys.

iaxon commented 3 months ago

Are there any news as it now is in 'esp-idf-sys'?

kbleeke commented 2 months ago

I'm specifically insterested in continuous mode dac (among other things, I'd like to reproduce the A2DP example

It seems the bindings are there, it just needs an abstraction around it. I will experiment a bit with my project here and submit it when I have something that works.

ivmarkov commented 2 months ago

I have this example in Rust in a project if mine. Used to be private, but oh well, I'll share it shortly. :)

ivmarkov commented 2 months ago

And for a2dp sink you don't need dac, but the i2s peripheral :)

ivmarkov commented 2 months ago

Here it is: https://github.com/ivmarkov/fiat-a2dp Status:

Caution: wifi and classic bt simultaneously running do take a lot of sram. Maybe first try with just BT running.

Also, you should use the original esp32. Later mcus do not support Classic BT but only BLE. Shame, if you ask me.

ivmarkov commented 2 months ago

Forgot to say that this is all async. Not impossible to convert to blocking if you wish to, but I won't bother and I prefer it that way.

kbleeke commented 2 months ago

Oh wow, thanks. I will take a look. The A2DP example has an option of streaming to the DAC instead of i2c, but I guess that should be easy enough to adapt.

Hfp and canbus I don't care about, maybe somebody else will find this useful :)

I was planning wifi and bt simulatinously thanks for the adice on the memory. I have an original esp32 so that's not an issue.

ivmarkov commented 2 months ago

Oh wow, thanks. I will take a look. The A2DP example has an option of streaming to the DAC instead of i2c, but I guess that should be easy enough to adapt.

I don't know what you plan to stream over a2dp, but if that's music, the DACs (and ADCs) of esp32 are famous for their low quality. The DACs in particular are 8bit, while a2dp is 16 bit 44kHz stereo.

That's why I stream over i2s (digital). i2s is basically the way to connect a quality external DAC to the esp32 (which is still usually a cheapo board with a price tag of less than $10 - just like the esp32 itself).