-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multipurpose (Input & Output) GPIO #26
Comments
Thanks for your question! And nice to see you are working on these libraries using Pi4J! As you can see in https://github.com/Pi4J/pi4j-v2/tree/master/pi4j-core/src/main/java/com/pi4j/io/gpio/digital currently we only have input or output types. Would it be an idea to reconfigure the I/O in your library itself between each action? I've not done this myself before so no idea what the behavior would be and if this happens fast enough. FYI, under the hood, Pi4J V2 is using http://abyz.me.uk/rpi/pigpio/ so anything supported by that library should also be available in Pi4J or could be added. |
I remember something like this in Pi4J V1. We probably should consider this for V2 as well. |
Thanks for your comments @savageautomate & @FDelporte . It looks like pigpio would support Multipurpose GPIOs through its gpioGetMode and gpioSetMode methods. An unscoped code search for GpioPinDigitalMultipurpose reveal broad use-cases that would motivate such a feature in pi4j-v2. In particular matrix keypad drivers -- at least the more sophisticated ones -- need to switch between input and output modes while scanning for keypresses. The driver I ported to pi4j-v2 seems to be working OK just leaving the transfer line in input mode and ignoring the spec to switch it to output mode while reading from the chipset buffer. So there is no direct need from my end. However, I'd be happy to test any implementation on the driver I ported as well as on a matrix keypad that I have from on old project. |
…pport. TODO: PIGPIO provider for Digital Multipurpose not implemented yet.
I have added API support for Multipurpose pins in this branch:
|
Added PIGPIO plugin implementation for Multipurpose GPIO pins. TODO: Still needs to be tested on hardware. |
Thanks for all the hard work implementing the feature so quickly @savageautomate. I started to test it, but then ran into unhandled signal 11 errors, especially on aarch64 systems. Yesterday I saw that you had addressed a similar issue in the master branch. This morning I ran tests on the driver I'm implementing using the following pi4j-v2 libraries:
No more unhandled signal 11 errors and anecdotally my driver seems to function more robustly. In my particular use case switching the MultipurposePin from Input to Output (low) asserts that buffers aren't updated before the I2C read operation completes. Looking at the implementation of the python driver, they switch the GPIO back to input (PULL_UP) after the I2C read operation completes. I noticed that on your API I can switch to the DigitalMultipurpose back to input
but am wondering if this configuration persists even after switching the multipurpose pin between input and output. |
Just a note on The following will if you run from an
This may not matter to you since you are working on
That's a good question. Pi4J V2 will only explicitly configure the digital input pin with its PULL config at the time of initialization. Switching to OUTPUT mode then back to INPUT does not re-apply the PULL config (or DEBOUNCE config) ... at least not in Pi4J code. Lines 94 to 116 in b406d7f
So I don't technically know if the mode change by the underlying PiGPIO library will modify PULL resistance or the DEBOUNCE settings. Do you think we should just go ahead and manually re-apply these settings anytime the multipurpose pin is returned to the INPUT mode? |
…pport. TODO: PIGPIO provider for Digital Multipurpose not implemented yet.
…pport. TODO: PIGPIO provider for Digital Multipurpose not implemented yet.
…pport. TODO: PIGPIO provider for Digital Multipurpose not implemented yet.
The Context
I'm in the process of porting the libraries of Skywriter & Flick I2C gesture sensing boards from python to Java/pi4j. Both boards utilise the MGC3130 chipset.
The Problem
The MGC3130 chipset requires the transfer pin (BCM 27) to be used as both input and output within each polling cycle. At the start of the cycle the library waits for a low transfer line (input). However, the library then reconfigures the same pin (BCM27) as a low output to assert that the MGC3130 does not update data buffers before reading from them.
The Issue
Does pi4j-v2 support Multipurpose GPIO that can be reconfigured to work as input and output?
The text was updated successfully, but these errors were encountered: