Adafruit_Learning_System_Gu.../CircuitPython_Essentials/SPI_Test_Script/code.py
2022-02-23 13:44:48 -05:00

23 lines
571 B
Python

# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""CircuitPython Essentials Hardware SPI pin verification script"""
import board
import busio
def is_hardware_spi(clock_pin, data_pin):
try:
p = busio.SPI(clock_pin, data_pin)
p.deinit()
return True
except ValueError:
return False
# Provide the two pins you intend to use.
if is_hardware_spi(board.A1, board.A2):
print("This pin combination is hardware SPI!")
else:
print("This pin combination isn't hardware SPI.")