Skip to content

i2cioexpander inconsistencies and problems #11049

@bablokb

Description

@bablokb

CircuitPython version and board name

main

Code/REPL

n.a.

Behavior

There are a number of inconsistencies across ports regarding the i2cioexpander module. Also, the behavior is not as intended:

  1. CIRCUITPY_I2CIOEXPANDER defaults to 0 for all ports except raspberrypi. That port sets the value to =1 (instead of ?=1), so it is impossible to override it in a mpconfigboard.mk file. While this sounds like just another module for the raspberrypi port, it also changes behavior as a side effect. Setting CIRCUITPY_I2CIOEXPANDER prevents resetting the board I2C bus (see reset_board_buses() in shared-module/board/__init__.c. So none of the raspberrypi boards reset the board I2C bus, while all espressif boards except the yotas do the reset.
  2. The coding in reset_board_buses() has two additional problems. It silently assumes that the ioexpander is an internal peripheral and not just a normal external i2c device. This assumption can be wrong.
  3. Major problem: not resetting the bus in this way does not prevent resetting the SCL/SDA pins. So although the bus is not explicitely reset, it is still unusable after the cleanup routines from main.c.

(1) is easy to solve.
(2) is debateble: treating ioexpanders as something special is possible, but the current implementation treats them differently if they are not on the board I2C bus.
(3) common_hal_i2cioexpander_ioexpander_construct() could call common_hal_busio_i2c_never_reset(), like common_hal_i2cdisplaybus_i2cdisplaybus_construct() does. As an alternative, this can be added to all boards that create an ioexpander and treat all ioexpander instances created from user code as "normal" i2c devices.

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions