From: Melissa LeBlanc-Williams Date: Thu, 6 May 2021 21:40:34 +0000 (-0700) Subject: Merge pull request #458 from makermelissa/master X-Git-Tag: 6.7.0 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/2e59a655e5bcd4057cd4eaf4130305110c6afe05?hp=f118a92cca62ce29f669d170648e03839f82e401 Merge pull request #458 from makermelissa/master Set the I2C and SPI singletons conditionally if pins exist --- diff --git a/src/board.py b/src/board.py index 45eaed6..9cdd379 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" in locals() and "SDA" in locals(): -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" in locals() and "MOSI" in locals() and "MISO" in locals(): - return busio.SPI(SCLK, MOSI, MISO) + def SPI(): + """The singleton SPI interface""" + import busio + + return busio.SPI(SCLK, MOSI, MISO)