Name
GPIO Support — Details
Synopsis
#include <cyg/hal/hal_io.h>
pin = CYGHWR_HAL_LM3S_GPIO(
port
,
bit
,
drive
,
mode
)
;
CYGHWR_HAL_LM3S_GPIO_SET
(
pin
)
;
CYGHWR_HAL_LM3S_GPIO_OUT
(
pin
,
val
)
;
CYGHWR_HAL_LM3S_GPIO_IN
(
pin
,
*val
)
;
Description
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 CYGHWR_HAL_LM3S_GPIO(port,
bit, mode)
which takes the following arguments:
-
port
- This identifies the GPIO port to which the pin is attached. Ports are identified by letters from A to F.
-
bit
- This gives the bit or pin number within the port. These are numbered from 0 to 8.
-
drive
-
This defines the drive level for the external pad. It may be
set to
2mA
,4mA
or8mA
. It may also be set to8mAS
to add slew rate control. -
mode
-
This defines the mode in which the pin is to be used. The following values are currently defined:
IN_PULLUP
defines the pin as a GPIO input with a pull up resistor,IN_PULLDOWN
defines the pin as a GPIO input with a pull down resistor,OUT_OPENDRAIN
defines the pin as a GPIO output with an open drain,ALT_DIGITAL
defines the pin as a digital line under the control of a peripheral.ALT_OD
defines the pin as a digital open drain line under the control of a peripheral.ALT_ODPU
defines the pin as a digital open drain line with pull up under the control of a peripheral.ALT_ODPD
defines the pin as a digital open drain line with pull down under the control of a peripheral.ALT_PP
defines the pin as a digital pushpull line under the control of a peripheral.ALT_PPPU
defines the pin as a digital pushpull line with pull up under the control of a peripheral.ALT_PPPD
defines 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
argument. CYGHWR_HAL_LM3S_GPIO_SET
configures the pin according to the descriptor and must be called
before any other
macros. 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.
2024-03-18 | eCosPro Non-Commercial Public License |