]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Set the I2C and SPI singletons only if pins are set
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 20:03:14 +0000 (13:03 -0700)
committerMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 20:03:14 +0000 (13:03 -0700)
src/board.py

index 45eaed6c3ac79596cd4b053ac555ebd191c493b2..9de41722cd9b9eb015c5a120383dc068fa4d89be 100755 (executable)
@@ -224,16 +224,19 @@ elif "sphinx" in sys.modules:
 else:
     raise NotImplementedError("Board not supported {}".format(board_id))
 
 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)