Skip to content

atmel-samd SPI: don't mark_deinit before resetting pin#10874

Open
dhalbert wants to merge 1 commit intoadafruit:10.1.xfrom
dhalbert:atmel-samd-deinit-fix
Open

atmel-samd SPI: don't mark_deinit before resetting pin#10874
dhalbert wants to merge 1 commit intoadafruit:10.1.xfrom
dhalbert:atmel-samd-deinit-fix

Conversation

@dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Mar 6, 2026

atmel-samd SPI objects were not being deinited properly. The clock pin was set to NO_PIN prematurely, and the pin The second time this program ran, after a ctrl-C and restart, it would stop with SCK in use.

It has to be being used by a FourWire; just creating spi does not provoke the bug. FourWire makes the SPI bus pins "never reset", and the "never reset" state was not being cleared.

import board
import busio
import displayio
from fourwire import FourWire
import os
import time

from adafruit_hx8357 import HX8357

displayio.release_displays()

print("starting in 3 seconds")
time.sleep(3)
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

display_bus = FourWire(spi, command=board.D10, chip_select=board.D9, reset=None)
display = HX8357(display_bus, width=480, height=320)

for i in range(1000):
    print(i)
    time.sleep(1)

The // Mark as deinit early in case we are used in an interrupt. should not be necessary. That was taken from espressif, and I don't believe it is applicable here.

I looked at the other ports and I didn't see a similar bug, so I think this is just atmel-samd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant