From: Melissa LeBlanc-Williams Date: Thu, 6 May 2021 20:03:14 +0000 (-0700) Subject: Set the I2C and SPI singletons only if pins are set X-Git-Tag: 6.7.0^2~5 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/ec3ddd9f3e7a2e6f7114ba2f74448198134b3672?ds=inline Set the I2C and SPI singletons only if pins are set --- diff --git a/src/board.py b/src/board.py index 45eaed6..9de4172 100755 --- a/src/board.py +++ b/src/board.py @@ -224,16 +224,19 @@ elif "sphinx" in sys.modules: else: raise NotImplementedError("Board not supported {}".format(board_id)) +if SCL and SDA: -def I2C(): - """The singleton I2C interface""" - import busio + def I2C(): + """The singleton I2C interface""" + import busio - return busio.I2C(SCL, SDA) + return busio.I2C(SCL, SDA) -def SPI(): - """The singleton SPI interface""" - import busio +if SCLK and MOSI and MISO: - return busio.SPI(SCLK, MOSI, MISO) + def SPI(): + """The singleton SPI interface""" + import busio + + return busio.SPI(SCLK, MOSI, MISO)