[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Switch GPIO direction on Raspberry Pi using ioctl()
Am 04.04.15 um 15:07 schrieb William D. Jones:
> Hello all,
> Is it possible to switch GPIO pin directions after setting up a proper
> gpio.conf and securelevel is changed from 0->1? I figured it would be
> possible without recompiling an insecure kernel, but any attempt to
> switch directions after kern.securelevel changes proves fruitless, even
> after I configure a pin using gpio.conf. My use case would be to simply
> change GPIO direction at will, depending on what's attached to my
> breadboard,. Of course, I could always just redo my gpio.conf and
> reboot, but other OSes seem to be able to change GPIO direction through
> userspace programs (run as root).
No, once the securelevel is raised all games are final, the GPIO
configuration can not be changed anymore. That is on purpose.
Whether that rule should be relaxed can be the topic of a discussion. I
could imagine a setting where in runlevel 0 you could specify that
certain pins remain changeable, even after the secure level had been raised.
> On a related note, is it possible to get bidirectional I/O on a single
> pin by using the pullup resistors? The Broadcom2835 GPIO driver itself
> supports pullup and pulldowns (but not inout), and reading and writing
> to individual pins. Since "inout" is not supported, I either have to
> switch the pin direction to get a bidirectional pin on demand, or treat
> logic 1 as an "idle" state, and 0 as "driving the bus/request for
> master". This is how I assume, for instance how the I2C driver over GPIO
> would work on the Pi; contrived example, since the Pi has hardware I2C,
> but I2C reads are not happening without the ability to switch pin
> direction :P.
> Thanks in advance for any help. If anything, at least the provided GPIO
> ioctl() and gpioctl program make it easy to write/test code.
Thanks. You noted there is also a Lua binding to the GPIO subsystem?
> William D. Jones
Main Index |
Thread Index |