Status indication through gpi lines – ThingMagic Mercury xPRESS Platform v1.7 User Manual
Page 69

Status Indication Through GPI Lines
A D I V I S I O N O F T R I M B L E
Using the Optional Modules
69
Status Indication Through GPI Lines
Most XBee modules provide GPO status outputs, which we can monitor through xPRESS
GPI inputs..
Common functionality in the GPI manager includes:
Configuring GPI pins; i.e., calling gpio_configure_pin with the appropriate
arguments
Monitoring the state of a GPI, either by regular polling or by registering interrupt
handlers
Detecting state changes
You can print debug messages every time a GPI state changes
You can also call callbacks if some other code wants to be triggered when a GPI
state changes
Measuring frequency of state changes
For example, the RN-42 Bluetooth module blinks its GPIO5 at different rates,
depending on its internal state. This rate measurement could be useful in
other places, too, so we don’t limit its association to the Bluetooth driver.
Consumers of the GPI manager API can use the following subroutines to obtain the
status of a GPI input.
To monitor a pin: GPIMGR_registerPin(GPIO_IDX)
To stop monitoring a pin: GPIMGR_unregisterPin(GPIO_IDX)
The current state of a pin: GPIMGR_getValue(GPIO_IDX)
The current frequency of a pin’s blinking: GPIMGR_getTogglePeriodMs(GPIO_IDX)
To call back on state changes: GPIMGR_addStateListener(GPIO_IDX,
my_handler)
The GPI Manager runs in interrupt mode and the functions listed below are added as part
of the GPI Manager implementation.
bool GPIMGR_registerPin(uint32_t gpio_idx)
Used to register the GPI line that is being monitored
For the Bluetooth module, it is used to monitor connection status and the toggle
period