adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.12k stars 1.22k forks source link

I2CTarget not being deinited properly on soft restart #9809

Closed dhalbert closed 4 days ago

dhalbert commented 1 week ago

CircuitPython version

Adafruit CircuitPython 9.2.0 on 2024-10-28; Raspberry Pi Pico with rp2040

Code/REPL

import board
from i2ctarget import I2CTarget
device = I2CTarget(board.GP3, board.GP2, (0x40,))

Behavior

Do the above once, then do ctrl-D, then do it again.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I2C peripheral in use

Without looking at all, I'm thinking switching to a finaliser will fix this. Should also check other ports.