]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Merge pull request #458 from makermelissa/master 6.7.0
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 21:40:34 +0000 (14:40 -0700)
committerGitHub <noreply@github.com>
Thu, 6 May 2021 21:40:34 +0000 (14:40 -0700)
Set the I2C and SPI singletons conditionally if pins exist

src/board.py

index 45eaed6c3ac79596cd4b053ac555ebd191c493b2..9cdd379bd1e886e97a13593e81757654c74994cd 100755 (executable)
@@ -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)