What is the state of the GPIOs when power is applied? eg High, Low, Hi-Z?
Also does any OS change the state of any GPIOs when it loads? Hopefully not.
|
|
I have found the answer here thanks to russellstrong. I quote the relevant part below
|
|||||
|
|
When started using the recommended Debian distro for RPi, GPIO is disabled. You have to enable each pin individually. If you're doing it via /sys you will find "Paths in Sysfs" interesting (search within http://www.kernel.org/doc/Documentation/gpio.txt). In particular, you would be enabling a pin by "exporting" it. Any commands below assume you are running as root privileges (sudo or otherwise) or you have changed the permissions/ownership of the virtual files being modified.
This enables the GPIO pin #4 which then causes /sys/class/gpio/gpio4 to exist, which contains several virtual files. Those files include "direction" which defines whether it's an input or an output pin, "value" which is either read-only for input or writable for output and contains the current value, and others.
Of course you'll probably prefer to use some preexisting library to do GPIO supplied with or compatible with your language of choice. But if you're wanting something simple, you can just interface directly with sysfs to do very basic GPIO. |
|||||||||||
|