Mimic 8 bit wide data-bus using dedicated gpio
Posted: Thu Oct 19, 2023 7:00 am
I have to achieve data bus behavior on ESP32 S3 using dedicated gpio. The goal is to make the same 8 pins with bi-directional capabilities on request. However, making an 8 pins bundle (for example with input enabled) returns handle on that bundle which is fine for reading. Is it possible to reconfigure the same bundle for output purpose (when needed) without destroying such a handle or I have to destroy (reading bundle) and recreate (writing bundle on the same pins) every time I have to read/write on data bus? Keep in mind that any reading or writing to those 8 pads "simulating" the data bus must be performed within a same clock cycle.
(For documentation: The VSCode examples for dedicated gpio are all with pads of fixed behavior. Some pads are output and some are inputs but they do not change their direction behavior at runtime. So those examples are not the best representative which effectively shows those usual things related to data bus like, making data bus for reading, reading byte, making it for writing and writing byte. I understand that it could be done by creating/destroying dedicated gpio bundle every time data bus has to be read/write but it doesn't look as the most efficient way. It is simply too many operations for such a basic thing and any bi-directional communication in between ESP32 and other peripheral chips, using data bus would suffer if switching from in/out direction would cost such a huge amount of clock cycles)
What is the best approach to solve that problem? Is it possible to have, at the same time, two different bundles (using the same pads) where one created handle is for reading and another handle for writing and leaving them permanent all the time and using one when reading from data bus is required and another for writing to data bus?
(For documentation: The VSCode examples for dedicated gpio are all with pads of fixed behavior. Some pads are output and some are inputs but they do not change their direction behavior at runtime. So those examples are not the best representative which effectively shows those usual things related to data bus like, making data bus for reading, reading byte, making it for writing and writing byte. I understand that it could be done by creating/destroying dedicated gpio bundle every time data bus has to be read/write but it doesn't look as the most efficient way. It is simply too many operations for such a basic thing and any bi-directional communication in between ESP32 and other peripheral chips, using data bus would suffer if switching from in/out direction would cost such a huge amount of clock cycles)
What is the best approach to solve that problem? Is it possible to have, at the same time, two different bundles (using the same pads) where one created handle is for reading and another handle for writing and leaving them permanent all the time and using one when reading from data bus is required and another for writing to data bus?