Comments (9)
Is there an example on how to read from an analog pin? I don't understand how to use b8657d8
from esp-idf-hal.
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.
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.
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 theesp-idf-hal
crate with theulp
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 ofesp-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 theAnalog
typestate- The
Channel
andOneShot
traits imply thatADC1
andADC2
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.
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.
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.
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.
ADC support is now implemented as part of b8657d8.
DAC & PWM are tracked in #13 and #28.
from esp-idf-hal.
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)
- I2C default baudrate too high, is 1M, using this parameter is likely to be wrong HOT 2
- Problem with CHANGELOG.md in v0.43.0 release: Unable to find valid link for esp-ulp-riscv-hal crate. HOT 2
- Spi has some problems. or clk needs to pull up resistors、or other...(esp32c2 rust-std) HOT 3
- spi async need some config in the Cargo.toml and sdkconfig.defaults?
- Example uart_loopback does not compile. TX buffer managment in Uart is broken sending garbage characters. HOT 1
- Pin Direction Change compiles but does not seem to be working and produces weird Info Log messages that I can not supress: HOT 6
- I2C timeout calculated wrong for MCU !esp32 HOT 2
- AsyncCanDriver is not Sync HOT 7
- ESP32C6 analog read working wonky HOT 4
- Potential wrong core type conversion in cpu.rs
- [Discussed] SPI DMA,can it be used now? HOT 1
- UART read line example HOT 1
- esp32 - Spi Drivers freeze app and triggers TG1WDT_SYS_RESET
- LEDC on ESP32: `SpeedMode` is currently a config, but it should actually be modelled as a peripheral HOT 2
- esp32c2 doesn't define XTAL_CFK_FREQ in esp-idf HOT 1
- esp32c2 generated bindgen doesn't include APB_CLK_FREQ correctly
- Uart rx buffer length error HOT 8
- Zigbee Support HOT 4
- rmt_neopixel.rs example doesn't work on ESP32-C3-DevKitC-02 when used in esp32-idf-template HOT 1
- When `feature = "std"` is enabled, implement std::io::Read and/or std::io::Write for all drivers where this makes sense HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-idf-hal.