GPIO Support — Details
cyg_uint32 pin = CYGHWR_HAL_MPC83XX_GPIO(
This section describes how to use macros provided by eCos to manage GPIO functionality on the MPC83XX processors.
The MPC83XX HAL provides a number of macros to support the encoding of GPIO pin identity and configuration into a single 32 bit descriptor. This is useful to drivers and other packages that need to configure and use different lines for different devices.
A descriptor is created with
bit, mode) which takes the following arguments:
- This identifies the GPIO controller to which the pin is attached. It may take the value 1 or 2.
- This gives the bit or pin number within the port. These are numbered from 0 to 32. Note that the bit numbers conform to the Freescale big-endian numbering scheme.
This defines the mode in which the pin is to be used. There are
4 main options:
INPUTsets the pin as an input,
OUTPUTsets it as an output.
OUTPUT_OPENDRAINset it as input or output with an open drain.
The following examples show how this macro may be used:
// Define controller 1 pin 10 as an input #define CYGHWR_HAL_MPC8309_PIN1 CYGHWR_HAL_MPC83XX_GPIO( 1, 10, INPUT ) // Define controller 2 pin 23 as an open drain output #define CYGHWR_HAL_MPC8309_PIN23 CYGHWR_HAL_MPC83XX_GPIO( 2, 23, OUTPUT_OPENDRAIN )
Additionally, the macro
CYGHWR_HAL_MPC83XX_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.
The remaining macros all take a GPIO pin descriptor as an
configures the pin according to the descriptor and must be called
before any other
CYGHWR_HAL_MPC83XX_GPIO_OUT sets the
output to the value of the least significant bit of the
val argument. The
val argument of
CYGHWR_HAL_MPC83XX_GPIO_IN should be a pointer
to an int, which will be set to 0 if the pin input is
zero, and 1 otherwise.
|2019-09-17||eCosPro Non-Commercial Public License|