pynq.gpio Module¶
The pynq.gpio module is a driver for reading and writing PS GPIO pins on a board. PS GPIO pins are not connected to the PL.
-
class
pynq.gpio.GPIO(gpio_index, direction)[source]¶ Bases:
objectClass to wrap Linux’s GPIO Sysfs API.
This GPIO class does not handle PL I/O.
-
index¶ The index of the GPIO, starting from the GPIO base.
Type: int
-
direction¶ Input/output direction of the GPIO.
Type: str
-
path¶ The path of the GPIO device in the linux system.
Type: str
-
direction str
Type: Direction of the GPIO pin - either ‘in’ or ‘out’
-
static
get_gpio_base()[source]¶ This method returns the GPIO base using Linux’s GPIO Sysfs API.
This is a static method. To use:
>>> from pynq import GPIO
>>> gpio = GPIO.get_gpio_base()
Note
For path ‘/sys/class/gpio/gpiochip138/’, this method returns 138.
Returns: The GPIO index of the base. Return type: int
-
static
get_gpio_pin(gpio_user_index)[source]¶ This method returns a GPIO instance for PS GPIO pins.
Users only need to specify an index starting from 0; this static method will map this index to the correct Linux GPIO pin number.
Note
The GPIO pin number can be calculated using: GPIO pin number = GPIO base + GPIO offset + user index e.g. The GPIO base is 138, and pin 54 is the base GPIO offset. Then the Linux GPIO pin would be (138 + 54 + 0) = 192.
Parameters: gpio_user_index (int) – The index specified by users, starting from 0. Returns: The Linux Sysfs GPIO pin number. Return type: int
-
index int
Type: Index of the GPIO pin
-
path str
Type: Path to the GPIO pin in the filesystem
-