]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - src/adafruit_blinka/microcontroller/ftdi_mpsse/mpsse/url.py
Merge branch 'master' of https://github.com/adafruit/Adafruit_Blinka
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / ftdi_mpsse / mpsse / url.py
diff --git a/src/adafruit_blinka/microcontroller/ftdi_mpsse/mpsse/url.py b/src/adafruit_blinka/microcontroller/ftdi_mpsse/mpsse/url.py
new file mode 100644 (file)
index 0000000..c2f2eaf
--- /dev/null
@@ -0,0 +1,31 @@
+"""Support for getting the URL from the BLINKA_FT232H variable."""
+
+import os
+
+
+def get_ft232h_url():
+    """
+    Return the FTDI url to use. If BLINKA_FT232H starts with ftdi:, returns
+    that. Otherwise, returns a default value.
+    """
+
+    url = os.environ.get("BLINKA_FT232H", "1")
+
+    if url.startswith("ftdi:"):
+        return url
+
+    return "ftdi://ftdi:ft232h/1"
+
+
+def get_ft2232h_url(interface_id):
+    """
+    Return the FTDI url to use. If BLINKA_FT2232H_{} starts with ftdi:, returns
+    that. Otherwise, returns a default value.
+    """
+
+    url = os.environ.get("BLINKA_FT2232H_{}".format(interface_id), "1")
+
+    if url.startswith("ftdi:"):
+        return url
+
+    return "ftdi://ftdi:ft2232h/{}".format(interface_id + 1)