VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
vitroio::sdk::impl::IOExpander Class Reference

#include <io_expander.h>

Public Member Functions

 IOExpander (PinName sda_pin, PinName scl_pin)
 Creates instance of IOExpander class. More...
 
 ~IOExpander ()
 Destructor for IOExpander class. More...
 
int configurePort (int address, uint8_t port_number, char config)
 Function configures IOs direction of port to output or input state. Each IO of given port can be configured independently. More...
 
int readInputPort (int address, uint8_t port_number, char *portState)
 Function reads state of given input port. More...
 
int writeOutputPort (int address, uint8_t port_number, char data)
 Function writes state to given output port. More...
 

Constructor & Destructor Documentation

◆ IOExpander()

vitroio::sdk::impl::IOExpander::IOExpander ( PinName  sda_pin,
PinName  scl_pin 
)

Creates instance of IOExpander class.

Parameters
sda_pinSDA pin of I2C.
scl_pinSCL pin of I2C.

◆ ~IOExpander()

vitroio::sdk::impl::IOExpander::~IOExpander ( )

Destructor for IOExpander class.

Member Function Documentation

◆ configurePort()

int vitroio::sdk::impl::IOExpander::configurePort ( int  address,
uint8_t  port_number,
char  config 
)

Function configures IOs direction of port to output or input state. Each IO of given port can be configured independently.

Parameters
addressI2C address of IO Expander.
port_numberPort number which will be configured. This variable can only take value 0x00 or 0x01.
configDirection of each IO in configured port. 0 means output, 1 means input.
Returns
Function returns 0 on success or appropriate error code otherwise.

◆ readInputPort()

int vitroio::sdk::impl::IOExpander::readInputPort ( int  address,
uint8_t  port_number,
char *  portState 
)

Function reads state of given input port.

Parameters
addressI2C address of IO Expander.
port_numberPort number which will be read. This variable can only take value 0x00 or 0x01.
portStateIf read successfully, this variable contains state of each input of read port.
Returns
Function returns 0 on success or appropriate error code otherwise.

◆ writeOutputPort()

int vitroio::sdk::impl::IOExpander::writeOutputPort ( int  address,
uint8_t  port_number,
char  data 
)

Function writes state to given output port.

Parameters
addressI2C address of IO Expander.
port_numberPort number which will be written. This variable can only take value 0x00 or 0x01.
dataData which will be written to port. Each bit corresponds to an output IO number.
Returns
Function returns 0 on success or appropriate error code otherwise.