GPIO Support — Use of GPIO
desc = CYGHWR_HAL_VIRTUAL_GPIO(
The HAL contains support for a VirtIO based GPIO controller. This is currently only available when a virtual machine is running under Xvisor.
The HAL provides a number of macros to support the encoding of GPIO pin configuration into a 32 bit descriptor. This is useful to drivers and other packages that need to configure and use different lines for different devices. Pin multiplexing is handled by the hypervisor, and is not considered here.
A GPIO descriptor is created with
pin, dir ) which takes the following arguments:
- This gives the GPIO pin number. The range depends on the number of pins assigned to the GPIO device in the hypervisor.
This defines the direction in which the pin will be
used, either input or output. The value in this argument
is the last element of a macro of the form,
Additionally, the macro
CYGHWR_HAL_VIRTUAL_GPIO_NONE may be used in
place of a pin descriptor and has a value that no valid
descriptor can take. It may therefore be used as a placeholder
where no GPIO pin is present or to be used. It may be passed
to any GPIO macro which takes a descriptor and will be treated
as a no-op.
Most of the remaining macros all take a GPIO descriptor as an
configures the pin according to the descriptor and must be called
before any the following
CYGHWR_HAL_VIRTUAL_GPIO_OUT sets the pin
output to the value of the least significant bit of the
val argument. The
val argument of
CYGHWR_HAL_VIRTUAL_GPIO_IN should be a pointer
to an int, which will be set to 0 if the pin input is
zero, and 1 otherwise.
|2020-06-15||eCosPro Non-Commercial Public License|