SatCat5
satcat5::device::i2c::Tca9548 Class Reference

Detailed Description

Device driver for PCA9548A / TCA9548A I2C switches.

The NXP Semiconductors PCA9548A and the Texas Instruments TCA9548A are pin-compatible devices that connect one I2C master to one of eight I2C channels. This driver controls either device, allowing for channel selection and then presenting an I2C interface for downstream devices to use.

Reference: https://www.nxp.com/docs/en/data-sheet/PCA9548A.pdf Reference: https://www.ti.com/product/TCA9548A

Definition at line 28 of file i2c_tca9548.h.

#include <i2c_tca9548.h>

Inheritance diagram for satcat5::device::i2c::Tca9548:
[legend]
Collaboration diagram for satcat5::device::i2c::Tca9548:
[legend]

Public Member Functions

 Tca9548 (satcat5::cfg::I2cGeneric *i2c, const satcat5::util::I2cAddr &devaddr)
 Constructor links to the specified I2C bus.
 
bool select_mask (u8 mask)
 Select a channel or channel(s). More...
 
bool select_channel (unsigned n)
 Shortcut for selecting a specific channel. More...
 
bool busy () override
 Is the I2C controller currently busy?
 
bool read (const satcat5::util::I2cAddr &devaddr, u8 regbytes, u32 regaddr, u8 nread, satcat5::cfg::I2cEventListener *callback=0) override
 Add a read operation to the queue. More...
 
bool write (const satcat5::util::I2cAddr &devaddr, u8 regbytes, u32 regaddr, u8 nwrite, const u8 *data, satcat5::cfg::I2cEventListener *callback=0) override
 Add a write operation to the queue. More...
 

Protected Member Functions

void i2c_done (bool noack, const satcat5::util::I2cAddr &devaddr, u32 regaddr, unsigned nread, const u8 *rdata) override
 
unsigned cb_wridx () const
 

Protected Attributes

satcat5::cfg::I2cGeneric *const m_parent
 
const satcat5::util::I2cAddr m_devaddr
 
unsigned m_cb_count
 
unsigned m_cb_rdidx
 
satcat5::cfg::I2cEventListenerm_cb_queue [SATCAT5_I2C_MAXCMD]
 

Member Function Documentation

◆ read()

bool Tca9548::read ( const satcat5::util::I2cAddr devaddr,
u8  regbytes,
u32  regaddr,
u8  nread,
satcat5::cfg::I2cEventListener callback = 0 
)
overridevirtual

Add a read operation to the queue.

  • If regbytes = 0: Start - Addr(R) - Read - Read - Stop
  • If regbytes > 0: Start - Addr(W) - Addr - Addr Start - Addr(R) - Data - Data - Stop Returns true if the command was added to the queue. Returns false if the user should try again later. (Child class MUST implement this method.

Implements satcat5::cfg::I2cGeneric.

Definition at line 35 of file i2c_tca9548.cc.

◆ select_channel()

bool satcat5::device::i2c::Tca9548::select_channel ( unsigned  n)
inline

Shortcut for selecting a specific channel.

See also
select_mask

Definition at line 45 of file i2c_tca9548.h.

◆ select_mask()

bool Tca9548::select_mask ( u8  mask)

Select a channel or channel(s).

Due to limited buffer space, the caller is responsible for retrying commands that cannot be queued immediately.

Returns
True on success, false for retry.

Definition at line 23 of file i2c_tca9548.cc.

◆ write()

bool Tca9548::write ( const satcat5::util::I2cAddr devaddr,
u8  regbytes,
u32  regaddr,
u8  nwrite,
const u8 *  data,
satcat5::cfg::I2cEventListener callback = 0 
)
overridevirtual

Add a write operation to the queue.

  • If regbytes = 0: Start - Addr(W) - Data - Data - Stop
  • If regbytes > 0: Start - Addr(W) - Addr - Addr - Data - Data - Stop Returns true if the command was added to the queue. Returns false if the user should try again later. (Child class MUST implement this method.

Implements satcat5::cfg::I2cGeneric.

Definition at line 51 of file i2c_tca9548.cc.


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