Difference between revisions of "Unit RPIGPIOEXPANDER"
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Raspberry Pi Firmware GPIO Expander Driver''' | + | '''Raspberry Pi Firmware GPIO Expander Driver unit''' |
− | As of February 2017 the Raspberry Pi firmware contains a mailbox interface to allow control of the GPIO expander on the Raspberry Pi 3 and Compute Module 3. | + | As of February 2017 the Raspberry Pi firmware contains a mailbox interface to allow control of the GPIO expander on the Raspberry Pi 3/4 and Compute Module 3/4. |
Unlike the earlier virtual GPIO interface this mailbox service now supports most GPIO functionality including getting and setting a pin value, getting and changing the pin function and getting or changing the pull up/down options. | Unlike the earlier virtual GPIO interface this mailbox service now supports most GPIO functionality including getting and setting a pin value, getting and changing the pin function and getting or changing the pull up/down options. | ||
Line 13: | Line 13: | ||
This driver implements most of the functionality available in the new mailbox service as a standard Ultibo GPIO device and also provides direct mailbox calls to allow access to any additional options not covered by the GPIO device API. | This driver implements most of the functionality available in the new mailbox service as a standard Ultibo GPIO device and also provides direct mailbox calls to allow access to any additional options not covered by the GPIO device API. | ||
− | When included in a project this driver replaces the Virtual GPIO functions provided by the PlatformRPi2 | + | When included in a project this driver replaces the Virtual GPIO functions provided by the PlatformRPi2, PlatformRPi3, PlatformRPi4 units. |
According to /arch/arm/boot/dts/bcm2710-rpi-3-b.dts the following pin assignments are known: | According to /arch/arm/boot/dts/bcm2710-rpi-3-b.dts the following pin assignments are known: | ||
Line 21: | Line 21: | ||
* GPIO_PIN_7 = Power LED (Input / Active Low) | * GPIO_PIN_7 = Power LED (Input / Active Low) | ||
− | Note that this driver requires | + | For the Raspberry Pi 3B+ the assignments shown in /arch/arm/boot/dts/bcm2710-rpi-3-b.dts have changed as follows: |
+ | |||
+ | *GPIO_PIN_2 = Power LED (Active Low) | ||
+ | *GPIO_PIN_4 = HDMI Detect (Input / Active Low) | ||
+ | |||
+ | For the Raspberry Pi 4B the assignments shown in /arch/arm/boot/dts/bcm2711-rpi-4-b.dts are: | ||
+ | |||
+ | *GPIO_PIN_0 = Bluetooth Power (Active High) (BT_ON) | ||
+ | *GPIO_PIN_1 = WiFi Power Sequencer (Active Low) (WL_ON) | ||
+ | *GPIO_PIN_2 = Power LED (Active Low) (PWR_LED_OFF) | ||
+ | *GPIO_PIN_3 = (GLOBAL_RESET) (ANT1 on CM4) | ||
+ | *GPIO_PIN_4 = SDIO 1.8V regulator (Active High) (VDD_SD_IO_SEL) | ||
+ | *GPIO_PIN_5 = CAM1 regulator (Active High) (CAM_GPIO) | ||
+ | *GPIO_PIN_6 = SD VCC regulator (Active High) (SD_PWR_ON) | ||
+ | *GPIO_PIN_7 = (SD_OC_N) (ANT2 on CM4) | ||
+ | |||
+ | The Pi 400 and CM4 files at bcm2711-rpi-400.dts and bcm2711-rpi-cm4.dts show identical assignments as the Pi 4B. | ||
+ | |||
+ | Note that this driver requires recent firmware (later than February 2017) and has been tested successfully with the firmware release from 8 October 2020. | ||
The latest version of the firmware is available from https://github.com/raspberrypi/firmware | The latest version of the firmware is available from https://github.com/raspberrypi/firmware | ||
Line 28: | Line 46: | ||
---- | ---- | ||
− | '' | + | |
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''RPiGPIO expander specific constants''' <code> RPIGPIOEXP_GPIO_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_DESCRIPTION = 'Raspberry Pi Firmware GPIO Expander';</code> | ||
+ | | Description of RPiGPIO Expander device | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_MIN_PIN = GPIO_PIN_0;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_MAX_PIN = GPIO_PIN_7;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_PIN_COUNT = 8;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_PIN_OFFSET = 128;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_MAX_LEVEL = GPIO_LEVEL_HIGH;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_MAX_PULL = GPIO_PULL_DOWN;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_MIN_FUNCTION = GPIO_FUNCTION_IN;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>RPIGPIOEXP_GPIO_MAX_FUNCTION = GPIO_FUNCTION_OUT;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Type definitions === | === Type definitions === | ||
---- | ---- | ||
− | '' | + | |
+ | '''RPiGPIO expander specific types''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PRPiGPIOExpander = ^TRPiGPIOExpander;</code> | ||
+ | |||
+ | <code>TRPiGPIOExpander = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''GPIO Properties'' | ||
+ | |- | ||
+ | | <code>GPIO:TGPIODevice;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |colspan="2"|''RPiGPIO Expander Properties'' | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
Line 43: | Line 130: | ||
---- | ---- | ||
− | |||
+ | '''Initialization functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure RPiGPIOExpanderInit;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the RPiGPIO Expander unit and create, register and start the device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Called only during system startup | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''RPiGPIO expander GPIO functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderStart(GPIO:PGPIODevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODeviceStart API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODeviceStart instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderStop(GPIO:PGPIODevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODeviceStop API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODeviceStop instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODeviceInputGet API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODeviceInputGet instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODeviceOutputSet API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODeviceOutputSet instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderPullGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODevicePullGet API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODevicePullGet instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderPullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODevicePullSelect API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODevicePullSelect instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODeviceFunctionGet API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODeviceFunctionGet instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of GPIODeviceFunctionSelect API for RPiGPIO Expander</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Not intended to be called directly by applications, use GPIODeviceFunctionSelect instead. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''RTL virtual GPIO functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysVirtualGPIOInputGet(Pin:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current state of a virtual GPIO input pin</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to get the state for (eg VIRTUAL_GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Return | ||
+ | | The current state (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysVirtualGPIOOutputSet(Pin,Level:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the state of a virtual GPIO output pin</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to set the state for (eg GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Level | ||
+ | | The state to set the pin to (eg GPIO_LEVEL_HIGH) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysVirtualGPIOFunctionGet(Pin:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current function of a virtual GPIO pin</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to get the function for (eg GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Return | ||
+ | | The current function of the pin (eg GPIO_FUNCTION_IN) or GPIO_FUNCTION_UNKNOWN on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function SysVirtualGPIOFunctionSelect(Pin,Mode:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the function of a virtual GPIO pin</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to change the function for (eg GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Mode | ||
+ | | The function to set for the pin (eg GPIO_FUNCTION_OUT) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''RPiGPIO expander helper functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderGetState(GPIO:LongWord; var State:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Raspberry Pi Firmware Mailbox call for Get GPIO State</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderSetState(GPIO,State:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Raspberry Pi Firmware Mailbox call for Set GPIO State</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderGetConfig(GPIO:LongWord; var Direction,Polarity,Terminator,PullUp:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Raspberry Pi Firmware Mailbox call for Get GPIO Config</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function RPiGPIOExpanderSetConfig(GPIO,Direction,Polarity,Terminator,PullUp,State:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Raspberry Pi Firmware Mailbox call for Set GPIO Config</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
Return to [[Unit_Reference|Unit Reference]] | Return to [[Unit_Reference|Unit Reference]] |
Latest revision as of 05:19, 17 June 2021
Return to Unit Reference
Description
Raspberry Pi Firmware GPIO Expander Driver unit
As of February 2017 the Raspberry Pi firmware contains a mailbox interface to allow control of the GPIO expander on the Raspberry Pi 3/4 and Compute Module 3/4.
Unlike the earlier virtual GPIO interface this mailbox service now supports most GPIO functionality including getting and setting a pin value, getting and changing the pin function and getting or changing the pull up/down options.
This driver implements most of the functionality available in the new mailbox service as a standard Ultibo GPIO device and also provides direct mailbox calls to allow access to any additional options not covered by the GPIO device API.
When included in a project this driver replaces the Virtual GPIO functions provided by the PlatformRPi2, PlatformRPi3, PlatformRPi4 units.
According to /arch/arm/boot/dts/bcm2710-rpi-3-b.dts the following pin assignments are known:
- GPIO_PIN_2 = Activity LED
- GPIO_PIN_4 = HDMI Detect (Input / Active Low)
- GPIO_PIN_7 = Power LED (Input / Active Low)
For the Raspberry Pi 3B+ the assignments shown in /arch/arm/boot/dts/bcm2710-rpi-3-b.dts have changed as follows:
- GPIO_PIN_2 = Power LED (Active Low)
- GPIO_PIN_4 = HDMI Detect (Input / Active Low)
For the Raspberry Pi 4B the assignments shown in /arch/arm/boot/dts/bcm2711-rpi-4-b.dts are:
- GPIO_PIN_0 = Bluetooth Power (Active High) (BT_ON)
- GPIO_PIN_1 = WiFi Power Sequencer (Active Low) (WL_ON)
- GPIO_PIN_2 = Power LED (Active Low) (PWR_LED_OFF)
- GPIO_PIN_3 = (GLOBAL_RESET) (ANT1 on CM4)
- GPIO_PIN_4 = SDIO 1.8V regulator (Active High) (VDD_SD_IO_SEL)
- GPIO_PIN_5 = CAM1 regulator (Active High) (CAM_GPIO)
- GPIO_PIN_6 = SD VCC regulator (Active High) (SD_PWR_ON)
- GPIO_PIN_7 = (SD_OC_N) (ANT2 on CM4)
The Pi 400 and CM4 files at bcm2711-rpi-400.dts and bcm2711-rpi-cm4.dts show identical assignments as the Pi 4B.
Note that this driver requires recent firmware (later than February 2017) and has been tested successfully with the firmware release from 8 October 2020.
The latest version of the firmware is available from https://github.com/raspberrypi/firmware
Constants
RPIGPIOEXP_GPIO_*
RPIGPIOEXP_GPIO_DESCRIPTION = 'Raspberry Pi Firmware GPIO Expander';
|
Description of RPiGPIO Expander device |
RPIGPIOEXP_GPIO_MIN_PIN = GPIO_PIN_0;
|
|
RPIGPIOEXP_GPIO_MAX_PIN = GPIO_PIN_7;
|
|
RPIGPIOEXP_GPIO_PIN_COUNT = 8;
|
|
RPIGPIOEXP_GPIO_PIN_OFFSET = 128;
|
|
RPIGPIOEXP_GPIO_MAX_LEVEL = GPIO_LEVEL_HIGH;
|
|
RPIGPIOEXP_GPIO_MAX_PULL = GPIO_PULL_DOWN;
|
|
RPIGPIOEXP_GPIO_MIN_FUNCTION = GPIO_FUNCTION_IN;
|
|
RPIGPIOEXP_GPIO_MAX_FUNCTION = GPIO_FUNCTION_OUT;
|
Type definitions
RPiGPIO expander specific types
PRPiGPIOExpander = ^TRPiGPIOExpander;
TRPiGPIOExpander = record
GPIO Properties | |
GPIO:TGPIODevice;
|
|
RPiGPIO Expander Properties | |
Public variables
None defined
Function declarations
Initialization functions
procedure RPiGPIOExpanderInit;
Note | Called only during system startup |
---|
RPiGPIO expander GPIO functions
function RPiGPIOExpanderStart(GPIO:PGPIODevice):LongWord;
Note | Not intended to be called directly by applications, use GPIODeviceStart instead. |
---|
function RPiGPIOExpanderStop(GPIO:PGPIODevice):LongWord;
Note | Not intended to be called directly by applications, use GPIODeviceStop instead. |
---|
function RPiGPIOExpanderInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | Not intended to be called directly by applications, use GPIODeviceInputGet instead. |
---|
function RPiGPIOExpanderOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
Note | Not intended to be called directly by applications, use GPIODeviceOutputSet instead. |
---|
function RPiGPIOExpanderPullGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | Not intended to be called directly by applications, use GPIODevicePullGet instead. |
---|
function RPiGPIOExpanderPullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Note | Not intended to be called directly by applications, use GPIODevicePullSelect instead. |
---|
function RPiGPIOExpanderFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | Not intended to be called directly by applications, use GPIODeviceFunctionGet instead. |
---|
function RPiGPIOExpanderFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Note | Not intended to be called directly by applications, use GPIODeviceFunctionSelect instead. |
---|
RTL virtual GPIO functions
function SysVirtualGPIOInputGet(Pin:LongWord):LongWord;
Pin | The pin to get the state for (eg VIRTUAL_GPIO_PIN_1) |
---|---|
Return | The current state (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure |
function SysVirtualGPIOOutputSet(Pin,Level:LongWord):LongWord;
Pin | The pin to set the state for (eg GPIO_PIN_1) |
---|---|
Level | The state to set the pin to (eg GPIO_LEVEL_HIGH) |
Return | ERROR_SUCCESS if completed successfully or another error code on failure |
function SysVirtualGPIOFunctionGet(Pin:LongWord):LongWord;
Pin | The pin to get the function for (eg GPIO_PIN_1) |
---|---|
Return | The current function of the pin (eg GPIO_FUNCTION_IN) or GPIO_FUNCTION_UNKNOWN on failure |
function SysVirtualGPIOFunctionSelect(Pin,Mode:LongWord):LongWord;
Pin | The pin to change the function for (eg GPIO_PIN_1) |
---|---|
Mode | The function to set for the pin (eg GPIO_FUNCTION_OUT) |
Return | ERROR_SUCCESS if completed successfully or another error code on failure |
RPiGPIO expander helper functions
function RPiGPIOExpanderGetState(GPIO:LongWord; var State:LongWord):LongWord;
Note | None documented |
---|
function RPiGPIOExpanderSetState(GPIO,State:LongWord):LongWord;
Note | None documented |
---|
function RPiGPIOExpanderGetConfig(GPIO:LongWord; var Direction,Polarity,Terminator,PullUp:LongWord):LongWord;
Note | None documented |
---|
function RPiGPIOExpanderSetConfig(GPIO,Direction,Polarity,Terminator,PullUp,State:LongWord):LongWord;
Note | None documented |
---|
Return to Unit Reference