From ec3ddd9f3e7a2e6f7114ba2f74448198134b3672 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 6 May 2021 13:03:14 -0700 Subject: [PATCH] Set the I2C and SPI singletons only if pins are set --- src/board.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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) -- 2.49.0