import adafruit_platformdetect.constants.boards as ap_board
from adafruit_blinka.agnostic import board_id, detector
+import busio
# pylint: disable=wildcard-import,unused-wildcard-import,ungrouped-imports
-# pylint: disable=import-outside-toplevel
if board_id == ap_board.FEATHER_HUZZAH:
from adafruit_blinka.board.feather_huzzah import *
else:
raise NotImplementedError("Board not supported {}".format(board_id))
-if SCL and SDA:
+try:
+ if SDA and SCL:
- def I2C():
- """The singleton I2C interface"""
- import busio
+ def I2C():
+ """The singleton I2C interface"""
+ return busio.I2C(SCL, SDA)
- return busio.I2C(SCL, SDA)
+ if SCLK:
+ def SPI():
+ """The singleton SPI interface"""
+ return busio.SPI(SCLK, MOSI, MISO)
-if SCLK and MOSI and MISO:
- def SPI():
- """The singleton SPI interface"""
- import busio
-
- return busio.SPI(SCLK, MOSI, MISO)
+except NameError:
+ pass