Reset GPIO pins
Publish date: Oct 22, 2019
Last updated: Apr 22, 2020
Last updated: Apr 22, 2020
- GPIO expanders
- for GPIO pins to connect multiple i2c devices when the number of available on board pins are less
- /RESET
- in schematics means active low
GPIO - General Purpose Input Output
- They are General Purpose Input Output and are pins on various processors that aren’t dedicated to anything.
As a recap, each gpio pin on the BBB has three different numbering schemes associated with it!
- The physical pin location, in the form of
PX_Y (P8_28)
- The gpio name, in the form of
GPIOX_Y (GPIO2_24)
- The gpio number, in the form of $$32*X + Y (88)$$
The Pi’s GPIO ports can be controlled from the command line (i.e. bash), python scripts, and C/C++ programs. There are 17 GPIO ports available on the Pi. Some of them have special purposes or special hardware configurations and should be avoided for normal use.
# Exports pin to userspace
echo "18" > /sys/class/gpio/export
# Sets pin 18 as an output
echo "out" > /sys/class/gpio/gpio18/direction
# Sets pin 18 to high
echo "1" > /sys/class/gpio/gpio18/value
# Sets pin 18 to low
echo "0" > /sys/class/gpio/gpio18/value
How to Reset a sensor via GPIO pin?
Find the sensor register (GPIO Expander)
find / -name '*03f*'
/sys/devices/platform/ocp/4802a000.i2c/i2c-1/1-003f
/sys/bus/i2c/devices/1-003f
gpiochip456 -> ../../devices/platform/ocp/4802a000.i2c/i2c-1/1-003f/gpio/gpiochip456
echo 457 > export
gpio457 -> ../../devices/platform/ocp/4802a000.i2c/i2c-1/1-003f/gpiochip10/gpio/gpio457
cd gpio457
cat value
cat direction
echo 0 > value
echo 1 > value
- Find on FS by register name
- 456 appears to be the first Pin
Need second pin from IO Expander
# RESET ADC /KMD_RESET cd /sys/class/gpio echo 457 > export sleep 1 cd gpio457 find . -maxdepth 1 -type f -exec head {} + echo out > direction echo 1 > value sleep 1 spidev_test --device /dev/spidev0.0 --verbose --cpha --speed 1000000 -p '\x10\x00' echo 0 > value find . -maxdepth 1 -type f -exec head {} + spidev_test --device /dev/spidev0.0 --verbose --cpha --speed 1000000 -p '\x10\x00' cd .. echo 457 > unexport
Questions
- What is the difference between GPIO pin and GPIOchip? *
Footnotes
[^2]: