esp-rs / esp32-hal

A hardware abstraction layer for the esp32 written in Rust.
Apache License 2.0
192 stars 28 forks source link

Add into_analog to GPIO #12

Closed Gasper closed 4 years ago

Gasper commented 4 years ago

This PR implements the Analog mode on GPIO, which had a struc already, but had no matching into_analog function.

To summarize what it does, is connect pads/pins, which have some analog functionality, to RTC IO_MUX instead of standard IO_MUX, as shown on Figure 7 of technical reference manual: image

Besides this, it disables RTC input/output/pull-up/pull-down functionality on the pins, following initialization done in Espressif's IDF HAL. The list of pins comes from section 4.11 "RTC_MUX Pin List" of TRM. Such pins can then be used for ADC/DAC (e.g. https://github.com/Gasper/esp32-hal/blob/feature-adc-example/examples/adc.rs#L51).

Please feel free to provide feedback on any architectural/contextual/style errors that you might notice.

MabezDev commented 4 years ago

This is awesome! Thank you, perfect PR, no issues here.

Looks like you have the ADC working or nearly working too?

Gasper commented 4 years ago

Looks like you have the ADC working or nearly working too?

Yes! ADC, DAC and Hall sensors are working, but the code still needs some love and testing. Some things, such as cosine-wave generator on DAC, will probably be missing in the first PR, since I currently don't have access to oscilloscope to even see if it's working...

MabezDev commented 4 years ago

Awesome! If it wasn't for corona I could test it at work :/, but having all the other stuff would be amazing!