How to set multiple GPIO pins? #2233
Replies: 3 comments 5 replies
-
You are right - there is no such API and creating such an API in a sane (= safe) way might be challenging. Out of curiosity: what is the use-case where you need the edges in absolute sync? Options which come to my mind
|
Beta Was this translation helpful? Give feedback.
-
I had a similar need some time ago and eventually implemented two options:
I can search that code and send what I have if it will help, don't know if it still compiles today as many changes were made, but it will provide some direction. |
Beta Was this translation helpful? Give feedback.
-
In the ESP-IDF, there is a way to program the interconnect/GPIO-mux so that you can "link" multiple outputs together. For example, you can make two LEDs, on two different pins, change state simultaneously with just one pin write. You can also connect output pins to internal peripherals directly, so that, say, an external LED changes state with the output of the PWM peripheral. This is similar, but different to the example above. But combined together, you can have an internal peripheral update multiple pins automatically. One program I wrote uses the PWM peripheral to generate a timing signal, which is routed to the PCNT counter and an LED, allowing the program to both blink the LED and measure time without a software loop. I've been trying to find a way to replicate this with the esp_hal's How difficult would it be to add support for these kinds of applications? |
Beta Was this translation helpful? Give feedback.
-
I'm currently working with a circuit that has multiple GPIO ports wired up in parallel to a peripheral. I need to set all of them at once using a single write instruction. The C driver I'm using as a reference does this using assignment to the
GPIO.out_w1ts
field.What's the best way to do this in Rust? Just grabbing all the pins from the Io struct and setting them manually seems unlikely to work, since it'll presumably issue multiple writes.
Beta Was this translation helpful? Give feedback.
All reactions