Skip to content

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

Merged
tannewt merged 1 commit intoadafruit:10.1.xfrom
dhalbert:atmel-samd-deinit-fix
Mar 9, 2026
Merged

atmel-samd SPI: don't mark_deinit before resetting pin#10874
tannewt merged 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.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@tannewt tannewt merged commit a674b8c into adafruit:10.1.x Mar 9, 2026
128 checks passed
@dhalbert dhalbert deleted the atmel-samd-deinit-fix branch March 9, 2026 17:12
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.

2 participants