Platform-specific layer provides a consistent GPIO API to upper layers of the driver.
Standard GPIO API Overview
This API contains the functions to configure and control the standard
GPIOs of the programmable XBee devices.
- GPIO configuration functions:
- gpio_config()
- GPIO functions to read/write the standard GPIOs:
- gpio_get()
- gpio_set()
Platform-specific layer provides a consistent MACROS API to upper layers of the driver.
Standard GPIO Macros
The gpio_config() function needs as second parameter a byte containing the
configuration masks for the GPIO. These masks are defined with macros and
they are the following:
- Macros to configure the GPIO \b type:
- \b GPIO_CFG_INPUT : Configures the standard GPIO as
input.
- \b GPIO_CFG_OUTPUT : Configures the standard GPIO as
output.
- Macros to configure the \b pullup resistors:
- \b GPIO_CFG_PULL_UP_DIS : Disables the GPIO Pull-up resistor.
- \b GPIO_CFG_PULL_UP_EN : Enables the GPIO Pull-up resistor.
- Macros to configure the \b slew \b rate:
- \b GPIO_CFG_SLEW_RATE_DIS : Disables the GPIO slew rate.
- \b GPIO_CFG_SLEW_RATE_EN : Enables the GPIO slew rate.
- Macros to configure the \b drive \b strength:
- \b GPIO_CFG_DRV_STR_LOW : Configures the drive strength to low.
- \b GPIO_CFG_DRV_STR_HIGH : Configures the drive strength to high.
Usage example:
gpio_config(
XPIN_7, GPIO_CFG_INPUT | GPIO_CFG_PULL_UP_EN | GPIO_CFG_SLEW_RATE_EN | GPIO_CFG_DRV_STR_LOW);
- Warning
- It is recommended not to use these macros, they are used by the XBee Project Smart Editor of the XBee extensions.
Configures the selected pin as a standard GPIO.
- Parameters
-
[in] | pin | the XBee pin to configure. |
[in] | cfg | a byte containing the configuration masks for the GPIO. See the Standard GPIO Macros for more information. |
- Return values
-
0 | on success |
EINVAL | invalid xpin_t parameter (not standard GPIO capable pin). |
Configures pin as input or output.
- Parameters
-
[in] | pin | the XBee pin to configure. |
[in] | dir | pin data direction, defined macros may be used. |
Gets the value of the specified pin.
- Parameters
-
[in] | pin | the XBee pin to get the value from. |
- Return values
-
bool_t | 1 if the pin is in high level, 0 if it is in low level. |
Sets the specified pin in high or low level. Notice the XBee pin must be configured as output to be able to set it.
- Parameters
-
[in] | pin | the XBee pin to set. |
[in] | val | 1 to set the pin in high level, 0 to set it in low level. |
- Return values
-
void gpio_toggle |
( |
xpin_t |
pin | ) |
|
Inverts the value of a pin.
- Parameters
-
[in] | pin | the XBee pin to toggle. |
- Return values
-