Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Switch GPIO direction on Raspberry Pi using ioctl()



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).

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.

Sincerely,

--
William D. Jones

Home | Main Index | Thread Index | Old Index