]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - src/adafruit_blinka/microcontroller/generic_linux/i2c.py
successfuly tested and added copyright info
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / generic_linux / i2c.py
index 7be7514a9426af43188158b0da31bfa423501405..b6f2fa36885c46a6f53c3aaceff0af42f0b7833d 100644 (file)
@@ -1,9 +1,18 @@
+# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
 """Generic Linux I2C class using PureIO's smbus class"""
 """Generic Linux I2C class using PureIO's smbus class"""
-import Adafruit_PureIO.smbus as smbus
+
+import warnings
+from Adafruit_PureIO import smbus
 
 
 class I2C:
 
 
 class I2C:
-    """I2C class"""
+    """
+    I2C class
+
+    Baudrate has no effect on Linux systems. The argument is only there for compatibility.
+    """
 
     MASTER = 0
     SLAVE = 1
 
     MASTER = 0
     SLAVE = 1
@@ -17,8 +26,10 @@ class I2C:
             raise NotImplementedError("Only I2C Master supported!")
         _mode = self.MASTER
 
             raise NotImplementedError("Only I2C Master supported!")
         _mode = self.MASTER
 
-        # if baudrate != None:
-        #    print("I2C frequency is not settable in python, ignoring!")
+        if baudrate is not None:
+            warnings.warn(
+                "I2C frequency is not settable in python, ignoring!", RuntimeWarning
+            )
 
         try:
             self._i2c_bus = smbus.SMBus(bus_num)
 
         try:
             self._i2c_bus = smbus.SMBus(bus_num)
@@ -69,7 +80,7 @@ class I2C:
         out_end=None,
         in_start=0,
         in_end=None,
         out_end=None,
         in_start=0,
         in_end=None,
-        stop=False
+        stop=False,
     ):
         """Write data from buffer_out to an address and then
         read data from an address and into buffer_in
     ):
         """Write data from buffer_out to an address and then
         read data from an address and into buffer_in