Comments (13)
I ran into a similar problem and decided to write my own library over esp-idf-sys.
You can find it here: https://crates.io/crates/esp-idf-servo
from esp-idf-hal.
I found the esp32 crate which seems to have this. However I am assuming that should not be used at the same time as this crate due to the crates having their own individual locks?
from esp-idf-hal.
Correct, this crate utilizes esp-idf functions and creates safe Rust wrappers around them. If you would like to try, you can create a wrapper around the MCPWM api and submit a PR (happy to review & mentor if you need some help). If not, someone will implement this eventually :).
from esp-idf-hal.
Maybe I will give it a try if I get time. Thanks! :)
from esp-idf-hal.
Do you think looking at something like ledc.rs and its correlation to the idf would be a good starting point for how to design the api?
from esp-idf-hal.
Do you think looking at something like ledc.rs and its correlation to the idf would be a good starting point for how to design the api?
Yes! I would definitely spend some time looking at LEDC, and some other peripherals just to get a feel of how to use the esp-idf functions within Rust, then you can start to think about how to safely wrap the MCPWM API in Rust :).
Feel free to join the matrix chat if you want: https://matrix.to/#/#esp-rs:matrix.org
from esp-idf-hal.
Am I missing something or are there no mcpwm related functions such as mcpwm_init in esp_idf_sys?
from esp-idf-hal.
So we don't produce bindings for everything in esp-idf, we have a whitelist in this file, inside esp-idf-sys. What you'll need to do is modify esp-idf-sys to include the mcpwm headers.
// binding.h
#include "driver/mcpwm.h"
Hopefully, that should be fairly simple! Let me know if you run into any issues or need some help :).
from esp-idf-hal.
Thanks a lot. I will try to take a look :)
from esp-idf-hal.
As far as I can see #include "driver/mcpwm.h"
is already present in that file (just below the inclusion of driver/ledc.h
).
When searching for ledc in the repo I can not find any more places than the file mentioned above (exept for what I believe is the corresponding file for the esp8266) where ledc is mentioned.
from esp-idf-hal.
Did you actually try to use the MCPWM functions in the HAL? I think the docs are built for the esp32c3, which doesn't have the MCPWM peripheral so it won't show up there.
from esp-idf-hal.
Oh, just checked locally and yes esp_idf_sys::mcpwm_init
and friends are there.
from esp-idf-hal.
@MabezDev do you think an API that would allow you to write something roughly like this would make sense?
let peripherals = Peripherals::take().unwrap();
let config = OperatorConfig::default().frequency(25.kHz().into());
let mcpwm = Mcpwm::new(peripherals.mcpwm0.mcpwm)?;
let mut operator = Operator::new(
peripherals.mcpwm0.operator0,
&mcpwm,
&config,
peripherals.pins.gpio4,
peripherals.pins.gpio5,
)?;
operator.set_duty_a(my_duty_percentage_a)?;
operator.set_duty_b(my_duty_percentage_b)?;
see #93, or do you have any other suggestions :)
from esp-idf-hal.
Related Issues (20)
- rmt_neopixel no longer works (on esp32c6) HOT 3
- Mutating struct in ISR HOT 1
- Error: dangerous relocation: call8: call target out of range:(xtensa-esp32s3-espidf) HOT 3
- Transport(Failed to load system certs: No valid certificate found) (xtensa-esp32s3-espidf/STD) HOT 4
- need uart dtr, for rs485 control HOT 1
- SpiBusDriver is not Send HOT 1
- 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
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.