GPIO Support — Details
pin = CYGHWR_HAL_LM3S_GPIO(
The LM3S 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 port to which the pin is attached. Ports are identified by letters from A to F.
- This gives the bit or pin number within the port. These are numbered from 0 to 8.
This defines the drive level for the external pad. It may be
8mA. It may also be set to
8mASto add slew rate control.
This defines the mode in which the pin is to be used. The following values are currently defined:
IN_PULLUPdefines the pin as a GPIO input with a pull up resistor,
IN_PULLDOWNdefines the pin as a GPIO input with a pull down resistor,
OUT_OPENDRAINdefines the pin as a GPIO output with an open drain,
ALT_DIGITALdefines the pin as a digital line under the control of a peripheral.
ALT_ODdefines the pin as a digital open drain line under the control of a peripheral.
ALT_ODPUdefines the pin as a digital open drain line with pull up under the control of a peripheral.
ALT_ODPDdefines the pin as a digital open drain line with pull down under the control of a peripheral.
ALT_PPdefines the pin as a digital pushpull line under the control of a peripheral.
ALT_PPPUdefines the pin as a digital pushpull line with pull up under the control of a peripheral.
ALT_PPPDdefines the pin as a digital pushpull line with pull down under the control of a peripheral. This set may be extended as further requirements emerge, so check the sources for new definitions.
The following examples show how this macro may be used:
// Define port A pin 0 as a digital device pin with 2mA drive level #define CYGHWR_HAL_LM3S_UART0_RX CYGHWR_HAL_LM3S_GPIO( A, 0, 2mA, ALT_DIGITAL )
Additionally, the macro
CYGHWR_HAL_LM3S_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_LM3S_GPIO_OUT sets the
output to the value of the least significant bit of the
val argument. The
val argument of
CYGHWR_HAL_LM3S_GPIO_IN should be a pointer
to an int, which will be set to 0 if the pin input is
zero, and 1 otherwise.
|2018-07-06||eCosPro Non-Commercial Public License|