upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Types | Public Member Functions
TCA9548A Class Reference

API TCA9548A Multiplexer Breakout. More...

Detailed Description

The TCA9548A device has eight bidirectional translating switches that can be controlled through the I2C bus. The SCL/SDA upstream pair fans out to eight downstream pairs, or channels. Any individual SCn/SDn channel or combination of channels can be selected, determined by the contents of the programmable control register.

The TCA9548A Multiplexer Breakout enables to get - up to 8 same-address I2C devices hooked up to one microcontroller - or up to 8 independent I2C buses. This multiplexer acts as a gatekeeper, shuttling the commands to the selected set of I2C pins with your command. The TCA9548A multiplexer is interesting in that it has an I2C address (0x70 by default) - and you basically send it a command to tell it which I2C multiplexed output you want to talk to, then you can address the board you want to address. You simply write a single byte with the desired multiplexed output number to that port, and bam - any future I2C packets will get sent to that port.

The TCA9548A Multiplexer provides three pins (A0-A1-A2) that enable to change its address in case 0x70 address is used by another sensor on the same bus. By connecting one of the Ax pin to Vin you change its value from 0 to 1, these values change the value of the three first bits of the address :

Address 0b01110-A2-A1-A0 No wiring A2=0 A1=0 A0=0 Address 0b01110000 0x70 A0 wired A2=0 A1=0 A0=1 Address 0b01110000 0x71 A2 wired A2=1 A1=0 A0=0 Address 0b01110100 0x74 Any address between 0x70 and 0x77 can be selected.

Tested with Adafriut TCA9548A board.

tca9548a.jpg

Public Types

enum  TCA9548A_PORT_STATE { DISABLED = 0, ENABLED = 1 }
 boolean enum containing port state
 
enum  TCA9548A_PORT_MODE { EXCLUSIVE = 0, INCLUSIVE = 1 }
 boolean enum containing port access mode
 

Public Member Functions

 TCA9548A (int bus, uint8_t address=0x70)
 
 ~TCA9548A ()
 
std::string name ()
 
bool getPort (int port)
 
void setPort (int port, TCA9548A_PORT_STATE state, TCA9548A_PORT_MODE mode)
 
void disableAllPorts ()
 
void enableAllPorts ()
 

Constructor & Destructor Documentation

TCA9548A ( int  bus,
uint8_t  address = 0x70 
)

TCA9548A constructor

Parameters
address.Device address. Default is 0x70.

Here is the caller graph for this function:

~TCA9548A ( )

TCA9548A destructor

Member Function Documentation

std::string name ( )
inline

Returns the name of the switch

Here is the call graph for this function:

bool getPort ( int  port)

Returns the status of a port as configured in the multiplexer.

Parameters
portSwitch port to check

Here is the caller graph for this function:

void setPort ( int  port,
TCA9548A_PORT_STATE  state,
TCA9548A_PORT_MODE  mode 
)

Configure an individual port on the multiplexer

Parameters
portPort to configure
enabledSet to true to enable the port, false to disable the port.
exclusiveSet to true to disable all other ports, false to leave existing port config untouched. When exclusive is set to false, an additional i2c read is required to read the current port setting.

Here is the caller graph for this function:

void disableAllPorts ( )

Disables all ports on the multiplexer.

Here is the caller graph for this function:

void enableAllPorts ( )

Enables all ports on the multiplexer. Useful when the multiplexer is used to electrically extend the bus rather than resolve address conflicts.

Here is the caller graph for this function:


The documentation for this class was generated from the following files: