CircuitPython version and board name
Code/REPL
Behavior
There are a number of inconsistencies across ports regarding the i2cioexpander module. Also, the behavior is not as intended:
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.
- 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.
- 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
CircuitPython version and board name
mainCode/REPL
Behavior
There are a number of inconsistencies across ports regarding the i2cioexpander module. Also, the behavior is not as intended:
CIRCUITPY_I2CIOEXPANDERdefaults to0for all ports except raspberrypi. That port sets the value to=1(instead of?=1), so it is impossible to override it in ampconfigboard.mkfile. While this sounds like just another module for the raspberrypi port, it also changes behavior as a side effect. SettingCIRCUITPY_I2CIOEXPANDERprevents resetting the board I2C bus (seereset_board_buses()inshared-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.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.(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 callcommon_hal_busio_i2c_never_reset(), likecommon_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