Raspberry Pi
  • Introduction
  • Raspberry Pi
    • Cover
    • Raspberry Pi
    • Documentation
      • Embedded Linux Wiki
      • Adafruit
    • Education
      • HelloWorld
      • HackSpace
      • MagPi
    • Raspberry Pi Foundation
    • Sandbox
  • Embedded Linux
    • Introduction
    • Initialization
      • System Information
      • Kernel Ring Buffer
      • Root Directory
      • User Directory
      • Kernel Modules
      • Filesystem
        • DebugFs
        • SysFs
        • ProcFs
        • TmpFs
      • Memory
      • Processes
      • Interfaces
      • Software Configuration Tool
    • Subsystem
      • Peripheral I/O
        • GPIO
        • PWM
        • I2C
        • SPI
        • UART
      • Bluetooth
  • Services
    • Docker
    • Home Assistant
  • XunanKab
    • Untitled
  • Bitol
    • Untitled
Powered by GitBook
On this page
  • Kernel Ring Buffer
  • SysFs
  1. Embedded Linux
  2. Subsystem
  3. Peripheral I/O

GPIO

PreviousPeripheral I/ONextPWM

Last updated 7 years ago

General-purpose input/output (GPIO) is a generic pin on an integrated circuit or computer board whose behavior—including whether it is an input or output pin—is controllable by the user at run time.

Hardware Perspective

One powerful feature of the Raspberry Pi is the row of GPIO (general purpose input/output) pins along the top edge of the board.

The comprehensive GPIO Pinout guide for the Raspberry Pi.

The Raspberry Pi offers up its GPIO over a standard male header on the board. Over the years the header has expanded from 26 pins to 40 pins while maintaining the original pinout.

One of the great things about the Raspberry Pi is that it has a GPIO connector to which you can attach external hardware.

The Raspberry Pi GPIOs can be controlled using many programming languages.

Operating System Perspective

Kernel Ring Buffer

pi@raspberrypi:~ $ dmesg | grep -i gpio
[    0.080031] uart-pl011 3f201000.serial: could not find pctldev for node /soc/gpio@7e200000/uart0_pins, deferring probe
[    3.524055] gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
pi@raspberrypi:~ $

SysFs

GPIO Sysfs Interface for Userspace. Platforms which use the "gpiolib" implementors framework may choose to configure a sysfs user interface to GPIOs. This is different from the debugfs interface, since it provides control over GPIO direction and value instead of just showing a gpio state summary. Plus, it could be present on production systems without debugging support.

pi@raspberrypi:~ $ cd /sys/class/gpio/
pi@raspberrypi:/sys/class/gpio $ tree -L 1
.
├── export
├── gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
├── gpiochip100 -> ../../devices/gpiochip2/gpio/gpiochip100
├── gpiochip128 -> ../../devices/gpiochip1/gpio/gpiochip128
└── unexport

3 directories, 2 files
pi@raspberrypi:/sys/class/gpio $
Wikipedia
Homepage
Pinout Homepage
Sparkfun Raspberry gPIo
Adafruit GPIO Setup
ELinux RPi GPIO Code Samples
Linux Kernel GPIO Documentation
LWN GPIO In The Kernel: An Introduction
Wikipedia GPIO