code.py
 1  # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """CircuitPython Essentials Hardware SPI pin verification script"""
 6  import board
 7  import busio
 8  
 9  
10  def is_hardware_spi(clock_pin, data_pin):
11      try:
12          p = busio.SPI(clock_pin, data_pin)
13          p.deinit()
14          return True
15      except ValueError:
16          return False
17  
18  
19  # Provide the two pins you intend to use.
20  if is_hardware_spi(board.A1, board.A2):
21      print("This pin combination is hardware SPI!")
22  else:
23      print("This pin combination isn't hardware SPI.")