I/O Expander
Configure an I/O Expander device
- SDK directory:
apps/sensors/io_expander
API Features Demonstrated
Requirements and Prerequisites
This app requires a ZentriOS device, such as an AMWx06-E03 (Moray), connected via the I2C interface to a TCA6416A I/O expander.
Description
This app demonstrates control and monitoring of the I/O Expander, which adds additional Input/Output to a ZentriOS device.
The app configures an input port on the IO Expander to control the value of an output port on the I/O Expander.
If the input pin is wired to a button, and the output pin is wired to a LED, pressing the button turns the LED on, and releasing the button turns the LED off.
Usage Instructions
Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.
Build, download and run the app. The app displays the following on the ZentriOS terminal:
> Initializing ap
Implementation
zn_app_init
- logs the
Initializing ap
message - Calls
configure_pins
configure_pins
- calls io_expander_dir_set_all to set the direction of the button input.
- calls io_expander_pol_set to set the polarity of the LED output.
- calls zn_event_register_periodic to set up an event handler
update_led
to poll the value of the button input.
update_led
- calls io_expander_val_get to get the value of the button input.
- depending on the value of the button input, sets the value of the LED output with io_expander_val_set
Source
See: