rpi_io()
Raspberry PI GPIO
DESCRIPTION
The Raspberry PI includes a 40-pin connector with two rows of general-purpose input/output (GPI0) pins. Versions prior to PI 1 Model B+ (2014) had only a 26-pin connector. Some of these pins are used as 3.3 Volt and 5 Volt sources and some are grounds. On the 40-pin connector, 26 pins are available for user defined input or output. The available pins are number 2 through 27. Pins 0 and 1 are reserved for "advanced use" and not available for programming via spec.
Pins can be configured as inputs or outputs. Inputs can be configured with an internal pull-up or pull-down resistor, although pins GPIO2 and GPIO3 have fixed pull-up resistors.
The Raspberry PI allows alternate functions for the pins besides simple input and output. Although spec supports setting the alternate function configuration, spec does not support making use of the alternate function.
See Raspberry PI documentation for details on using the GPIO pins, including a description of how the pins are numbered. For example, see www.raspberrypi.org/documentation/usage/gpio.
BUILT-IN FUNCTIONS
- rpi_io("io_config", val)
- Pins corresponding to bits set in val are enabled for output. Pins corresponding to unset bits are enabled for input.
- rpi_io("pin_config", num, how)
- Configures a single pin num to value how, which can be 0 for input, 1 for output, or one of the other alternate values (from 2 to 7) in the documentation. The alternate configurations are unlikely to be useful from spec.
- rpi_io("get_pin", num)
- Returns 0 or 1 to indicate the state of pin num. The pin must be configured for input.
- rpi_io("set_pin", num)
- Sets pin num high. The pin must be configured for output.
- rpi_io("clr_pin", num)
- Sets pin num low. The pin must be configured for output.
- rpi_io("get_pins")
- Returns a 32-bit value that indicates the state of all input pins.
- rpi_io("set_pins", val)
- Sets output pins high corresponding to bits set in val.
- rpi_io("clr_pins", val)
- Sets output pins low corresponding to bits set in val.
- rpi_io("pull_up", val)
- Enable pull-up for pins corresponding to bits set in val.
- rpi_io("pull_down", val)
- Enable pull-down for pins corresponding to bits set in val.
- rpi_io("pull_off", val)
- Disable pull-up/pull-down for pins corresponding to bits set in val.
HISTORY
The Raspberry PI running Raspbian Linux has been supported as a platform since spec release 6.03.01 from February 2015. The rpi_io() user-level function was added in spec release 6.09.02 from June 2020.