Skip to content

I2C & SPI pins are not released when modules are initialised with different pins #167

@microbit-carlos

Description

@microbit-carlos

With the update from #112 and #111 we can change the I2C and SPI pins to other pins than 19 and 20. However, the pin modes are not updated.

Using a build from the latest commit in main:
https://github.com/microbit-foundation/micropython-microbit-v2/actions/runs/7565598370

>>> pin19.get_mode()
'i2c'
>>> pin0.get_mode()
'unused'
>>> i2c.init(sda=pin0, scl=pin1)
>>> i2c.scan()
[]
>>> pin0.get_mode()
'unused'
>>> pin0.write_digital(1)
>>> pin19.get_mode()
'i2c'
>>> pin19.write_digital(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Pin 19 in i2c mode
>>> pin13.get_mode()
'unused'
>>> spi.init(sclk=pin13, mosi=pin15, miso=pin14)
>>> pin13.get_mode()
'spi'
>>> spi.init(sclk=pin8, mosi=pin12, miso=pin16)
>>> pin13.get_mode()
'spi'
>>> pin8.get_mode()
'spi'
>>> pin8.write_digital(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function takes 2 positional arguments but 1 were given
>>> pin13.write_digital(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Pin 8 in spi mode
>>> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions