Circuitpython: esp32s2: spi (and other peripherals?) don't claim pins properly

Created on 18 Nov 2020  路  7Comments  路  Source: adafruit/circuitpython

I noticed that it was possible to create a DigitalIO from some pin while the pin was already in use by an SPI instance:

>>> spi = busio.SPI(board.IO0, board.IO1, board.IO2)
>>> import digitalio
>>> pin = digitalio.DigitalInOut(board.IO0)
>>> pin
<DigitalInOut>

tested on a kaluga with a 6.1-ish firmware

bug esp32s2 help wanted

Most helpful comment

@microDev1 found it, it was a variable size issue with in pin claiming mask operations.

All 7 comments

I can confirm this bug to be present on other peripherals and not just related to spi.

Almost certainly related to #3643

Actually, looks like I misread - the reset problem will cause conflicts pins that have been released, but it shouldn't allow pins in the claimed array to be claimed again. This could be an issue with the bit shifting in the pin claiming system.

@microDev1 can you point out specific modules where you have also had this problem? Turns out this was just that the SPI module didn't have pin claiming in it. The other Busio modules have it, as does DigitalIO and AnalogIO, but if you've encountered it elsewhere I can fold a fix into my PR.

@hierophect I am able to see this on basically all of the io modules.

repl-test

Update... Pin claiming seems to work until IO7 after which pins aren't claimed properly.

@microDev1 found it, it was a variable size issue with in pin claiming mask operations.

Was this page helpful?
0 / 5 - 0 ratings