Giter VIP home page Giter VIP logo

Comments (9)

ivmarkov avatar ivmarkov commented on June 16, 2024 2

Is there an example on how to read from an analog pin? I don't understand how to use b8657d8

Yes

from esp-idf-hal.

ivmarkov avatar ivmarkov commented on June 16, 2024 1

Am I correct in understanding that currently one cannot read/write analog values with esp-idf-hal? (e.g. read analog value from a pin and drive something with PWM from an analog pin?)

You are correct. Waiting for somebody to take the lead.

from esp-idf-hal.

lily-mara avatar lily-mara commented on June 16, 2024

I was looking into implementing this myself, but it raised some questions for me. As a user, I assumed this was a wrapper package around the esp-idf C library. Based on the register usage that I saw in the GPIO code, it seems more like a rewrite. Is it intended to be a low-level rewrite, or a higher-level wrapper?

from esp-idf-hal.

ivmarkov avatar ivmarkov commented on June 16, 2024

Hey sorry for following up so late, I just noticed that issue. To address some of your questions/topics:

I was looking into implementing this myself, but it raised some questions for me. As a user, I assumed this was a wrapper package around the esp-idf C library.

It is a high level wrapper around the esp-idf C library.

Based on the register usage that I saw in the GPIO code, it seems more like a rewrite. Is it intended to be a low-level rewrite, or a higher-level wrapper?

Do you mean this one? If yes, then the story is as follows:

  • esp-idf-hal is primarily a type-safe wrapper for the ESP-IDF C library HAL. As in for 99.9% of the cases.
  • However, it has a miniscule register-based implementation - really just a partial impl for the gpio - in the ulp module. This implementation is only triggered when you compile the esp-idf-hal crate with the ulp feature enabled. ULP stands for Ultra Low Power (coprocessor) and is a very tiny little processor that can work while the rest of the ESP32 MCU is basically switched off (all of it - main CPU, RAM, modems, most of the hardware interfaces etc.)
  • It can process some basic GPIO and wake up the main processor if necessary
  • Now, even though this tiny coprocessor only has 8K of RAM for code+data, it is still useful; moreover, in ESP32-S2 and ESP32-S3, this coprocessor is in fact using the rsicv32imc instruction set, so I succeeded in targeting it with Rust a few months ago. Now, the ulp compilation mode of esp-idf-hal gives you a superminimal HAL for this ULP, which is currently just a partial GPIO support. As in allowing you to blink a LED or read a digital input. (not sure if ADC/DAC is supported in ULP mode.)
  • The GpioXX pin structs have no method to convert them to the Analog typestate
  • The Channel and OneShot traits imply that ADC1 and ADC2 newtypes should exist, but they do not
  • The above traits are not implemented for any types

Indeed. The ADC support needs to be implemented, but it is just not there yet. If you are still interested, I'm also willing to help. It is really just about writing safe wrappers around the corresponding ADC functions in ESP-IDF and fighting with the generics-heavy type-state patterns used by the embedded-hal traits & philosophy. :)

from esp-idf-hal.

lily-mara avatar lily-mara commented on June 16, 2024

Ok, thanks for all of that info! I think I might be able to build out the required types, but I'm not going to be able to get started until next week. If someone wants to claim this issue before then, please don't hesitate. I may also need a few rounds of review on my PR as I'm quite unfamiliar with the hardware constraints that come along with embedded programming, and I may need help figuring out which chips should have which types of pins enabled.

from esp-idf-hal.

ivmarkov avatar ivmarkov commented on June 16, 2024

I don't think there is an urgent need to implement the ADC support, and I also don't see a forest of hands willing to claim this work, so take your time.

Multiple reviews is OK, we are all learning.

from esp-idf-hal.

matsimitsu avatar matsimitsu commented on June 16, 2024

Am I correct in understanding that currently one cannot read/write analog values with esp-idf-hal? (e.g. read analog value from a pin and drive something with PWM from an analog pin?)

from esp-idf-hal.

ivmarkov avatar ivmarkov commented on June 16, 2024

ADC support is now implemented as part of b8657d8.

DAC & PWM are tracked in #13 and #28.

from esp-idf-hal.

ericvrp avatar ericvrp commented on June 16, 2024

Is there an example on how to read from an analog pin? I don't understand how to use b8657d8

from esp-idf-hal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.