TCA6424A

Driver for TCA6424A 24-bit I2C IO pin expander.

Public Functions

Type

Name

TCA6424A (uint8_t address)

void

initialize (PinName sda, PinName scl)

bool

readPin (uint16_t pin)

uint8_t

readBank (uint8_t bank)

bool

readAll (uint8_t * banks)

bool

readAll (uint8_t * bank0, uint8_t * bank1, uint8_t * bank2)

bool

getPinOutputLevel (uint16_t pin)

uint8_t

getBankOutputLevel (uint8_t bank)

void

getAllOutputLevel (uint8_t * banks)

void

getAllOutputLevel (uint8_t * bank0, uint8_t * bank1, uint8_t * bank2)

void

writePin (uint16_t pin, bool value)

void

writeBank (uint8_t bank, uint8_t value)

void

writeAll (uint8_t * banks)

void

writeAll (uint8_t bank0, uint8_t bank1, uint8_t bank2)

bool

getPinPolarity (uint16_t pin)

uint8_t

getBankPolarity (uint8_t bank)

void

getAllPolarity (uint8_t * banks)

void

getAllPolarity (uint8_t * bank0, uint8_t * bank1, uint8_t * bank2)

void

setPinPolarity (uint16_t pin, bool polarity)

void

setBankPolarity (uint8_t bank, uint8_t polarity)

void

setAllPolarity (uint8_t * banks)

void

setAllPolarity (uint8_t bank0, uint8_t bank1, uint8_t bank2)

bool

getPinDirection (uint16_t pin)

uint8_t

getBankDirection (uint8_t bank)

void

getAllDirection (uint8_t * banks)

void

getAllDirection (uint8_t * bank0, uint8_t * bank1, uint8_t * bank2)

void

setPinDirection (uint16_t pin, bool direction)

void

setBankDirection (uint8_t bank, uint8_t direction)

void

setAllDirection (uint8_t * banks)

void

setAllDirection (uint8_t bank0, uint8_t bank1, uint8_t bank2)

Public Functions Documentation

function TCA6424A

TCA6424A::TCA6424A ()

Default constructor, uses default I2C address.

See also:

TCA6424A_DEFAULT_ADDRESS

function TCA6424A

TCA6424A::TCA6424A (
    uint8_t address
)

Specific address constructor.

Parameters:

  • address I2C address

See also:

TCA6424A_DEFAULT_ADDRESS

See also:

TCA6424A_ADDRESS_ADDR_LOW

See also:

TCA6424A_ADDRESS_ADDR_HIGH

function initialize

void TCA6424A::initialize (
    PinName sda,
    PinName scl
)

Power on and prepare for general usage. The TCA6424A I/O expander requires no preparation after power-on. All pins will be default to INPUT mode, and the device is ready for usage immediately. This is an empty function for consistency and/or future expansion.

bool TCA6424A::testConnection ()

Verify the I2C connection. Make sure the device is connected and responds as expected.

Returns:

True if connection is valid, false otherwise

function readPin

bool TCA6424A::readPin (
    uint16_t pin
)

Get a single INPUT pin's logic level.

Returns:

Pin logic level (0 or 1)

function readBank

uint8_t TCA6424A::readBank (
    uint8_t bank
)

Get all pin logic levels from one bank.

Parameters:

  • bank Which bank to read (0/1/2 for P0*, P1*, P2* respectively)

Returns:

8 pins' logic levels (0 or 1 for each pin)

function readAll

bool TCA6424A::readAll (
    uint8_t * banks
)

Get all pin logic levels from all banks. Reads into single 3-byte data container.

Parameters:

  • banks Container for all bank's pin values (P00-P27)

function readAll

bool TCA6424A::readAll (
    uint8_t * bank0,
    uint8_t * bank1,
    uint8_t * bank2
)

Get all pin logic levels from all banks. Reads into individual 1-byte containers.

Parameters:

  • bank0 Container for Bank 0's pin values (P00-P07)

  • bank1 Container for Bank 1's pin values (P10-P17)

  • bank2 Container for Bank 2's pin values (P20-P27)

bool TCA6424A::getPinOutputLevel (
    uint16_t pin
)

Get a single OUTPUT pin's setting. Note that this returns the level set in the flip-flop, and does not necessarily represent the actual logic level present at the pin.

Returns:

Pin output setting (0 or 1)

uint8_t TCA6424A::getBankOutputLevel (
    uint8_t bank
)

Get all pin output settings from one bank. Note that this returns the level set in the flip-flop, and does not necessarily represent the actual logic level present at the pin.

Parameters:

  • bank Which bank to read (0/1/2 for P0*, P1*, P2* respectively)

Returns:

8 pins' output settings (0 or 1 for each pin)

void TCA6424A::getAllOutputLevel (
    uint8_t * banks
)

Get all pin output settings from all banks. Reads into single 3-byte data container.

Parameters:

  • banks Container for all bank's pin values (P00-P27)

void TCA6424A::getAllOutputLevel (
    uint8_t * bank0,
    uint8_t * bank1,
    uint8_t * bank2
)

Get all pin output settings from all banks. Reads into individual 1-byte containers. Note that this returns the level set in the flip-flop, and does not necessarily represent the actual logic level present at the pin.

Parameters:

  • bank0 Container for Bank 0's pin values (P00-P07)

  • bank1 Container for Bank 1's pin values (P10-P17)

  • bank2 Container for Bank 2's pin values (P20-P27)

function writePin

void TCA6424A::writePin (
    uint16_t pin,
    bool value
)

Set a single OUTPUT pin's logic level.

Parameters:

  • pin Which pin to write (0-23)

  • value New pin output logic level (0 or 1)

function writeBank

void TCA6424A::writeBank (
    uint8_t bank,
    uint8_t value
)

Set all OUTPUT pins' logic levels in one bank.

Parameters:

  • bank Which bank to write (0/1/2 for P0*, P1*, P2* respectively)

  • value New pins' output logic level (0 or 1 for each pin)

function writeAll

void TCA6424A::writeAll (
    uint8_t * banks
)

Set all OUTPUT pins' logic levels in all banks.

Parameters:

  • banks All pins' new logic values (P00-P27) in 3-byte array

function writeAll

void TCA6424A::writeAll (
    uint8_t bank0,
    uint8_t bank1,
    uint8_t bank2
)

Set all OUTPUT pins' logic levels in all banks.

Parameters:

  • bank0 Bank 0's new logic values (P00-P07)

  • bank1 Bank 1's new logic values (P10-P17)

  • bank2 Bank 2's new logic values (P20-P27)

bool TCA6424A::getPinPolarity (
    uint16_t pin
)

Get a single pin's polarity (normal/inverted) setting.

Returns:

Pin polarity setting (0 or 1)

uint8_t TCA6424A::getBankPolarity (
    uint8_t bank
)

Get all pin polarity (normal/inverted) settings from one bank.

Parameters:

  • bank Which bank to read (0/1/2 for P0*, P1*, P2* respectively)

Returns:

8 pins' polarity settings (0 or 1 for each pin)

void TCA6424A::getAllPolarity (
    uint8_t * banks
)

Get all pin polarity (normal/inverted) settings from all banks. Reads into single 3-byte data container.

Parameters:

  • banks Container for all bank's pin values (P00-P27)

void TCA6424A::getAllPolarity (
    uint8_t * bank0,
    uint8_t * bank1,
    uint8_t * bank2
)

Get all pin polarity (normal/inverted) settings from all banks. Reads into individual 1-byte containers.

Parameters:

  • bank0 Container for Bank 0's pin values (P00-P07)

  • bank1 Container for Bank 1's pin values (P10-P17)

  • bank2 Container for Bank 2's pin values (P20-P27)

void TCA6424A::setPinPolarity (
    uint16_t pin,
    bool polarity
)

Set a single pin's polarity (normal/inverted) setting.

Parameters:

  • pin Which pin to write (0-23)

  • polarity New pin polarity setting (0 or 1)

void TCA6424A::setBankPolarity (
    uint8_t bank,
    uint8_t polarity
)

Set all pin polarity (normal/inverted) settings in one bank.

Parameters:

  • bank Which bank to write (0/1/2 for P0*, P1*, P2* respectively)

Returns:

New pins' polarity settings (0 or 1 for each pin)

void TCA6424A::setAllPolarity (
    uint8_t * banks
)

Set all pin polarity (normal/inverted) settings in all banks.

Parameters:

  • banks All pins' new logic values (P00-P27) in 3-byte array

void TCA6424A::setAllPolarity (
    uint8_t bank0,
    uint8_t bank1,
    uint8_t bank2
)

Set all pin polarity (normal/inverted) settings in all banks.

Parameters:

  • bank0 Bank 0's new polarity values (P00-P07)

  • bank1 Bank 1's new polarity values (P10-P17)

  • bank2 Bank 2's new polarity values (P20-P27)

bool TCA6424A::getPinDirection (
    uint16_t pin
)

Get a single pin's direction (I/O) setting.

Returns:

Pin direction setting (0 or 1)

uint8_t TCA6424A::getBankDirection (
    uint8_t bank
)

Get all pin direction (I/O) settings from one bank.

Parameters:

  • bank Which bank to read (0/1/2 for P0*, P1*, P2* respectively)

Returns:

8 pins' direction settings (0 or 1 for each pin)

void TCA6424A::getAllDirection (
    uint8_t * banks
)

Get all pin direction (I/O) settings from all banks. Reads into single 3-byte data container.

Parameters:

  • banks Container for all bank's pin values (P00-P27)

void TCA6424A::getAllDirection (
    uint8_t * bank0,
    uint8_t * bank1,
    uint8_t * bank2
)

Get all pin direction (I/O) settings from all banks. Reads into individual 1-byte containers.

Parameters:

  • bank0 Container for Bank 0's pin values (P00-P07)

  • bank1 Container for Bank 1's pin values (P10-P17)

  • bank2 Container for Bank 2's pin values (P20-P27)

void TCA6424A::setPinDirection (
    uint16_t pin,
    bool direction
)

Set a single pin's direction (I/O) setting.

Parameters:

  • pin Which pin to write (0-23)

  • direction Pin direction setting (0 or 1)

void TCA6424A::setBankDirection (
    uint8_t bank,
    uint8_t direction
)

Set all pin direction (I/O) settings in one bank.

Parameters:

  • bank Which bank to read (0/1/2 for P0*, P1*, P2* respectively)

  • direction New pins' direction settings (0 or 1 for each pin)

void TCA6424A::setAllDirection (
    uint8_t * banks
)

Set all pin direction (I/O) settings in all banks.

Parameters:

  • banks All pins' new direction values (P00-P27) in 3-byte array

void TCA6424A::setAllDirection (
    uint8_t bank0,
    uint8_t bank1,
    uint8_t bank2
)

Set all pin direction (I/O) settings in all banks.

Parameters:

  • bank0 Bank 0's new direction values (P00-P07)

  • bank1 Bank 1's new direction values (P10-P17)

  • bank2 Bank 2's new direction values (P20-P27)

The documentation for this class was generated from the following file: D:/w/hw-libs/\_libs\_/libraries/TCA6424A.h

Last updated