]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Strategy for board module being conditionally populated based on platform detection
authorCefn Hoile <github.com@cefn.com>
Thu, 15 Feb 2018 16:51:41 +0000 (16:51 +0000)
committerCefn Hoile <github.com@cefn.com>
Thu, 15 Feb 2018 16:51:41 +0000 (16:51 +0000)
python/board/__init__.py [new file with mode: 0644]
python/boards/esp8266.py [new file with mode: 0644]
python/boards/pyboard.py [new file with mode: 0644]

diff --git a/python/board/__init__.py b/python/board/__init__.py
new file mode 100644 (file)
index 0000000..c539725
--- /dev/null
@@ -0,0 +1,39 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2017 cefn for adafruit industries
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+"""
+`board` - Define ids for available pins
+=================================================
+Conditionally imports and re-exports a submodule, such as boards.esp8266 based on 
+platform introspection
+
+* Author(s): cefn
+"""
+
+import sys
+
+__version__ = "0.0.0-auto.0"
+__repo__ = "https://github.com/adafruit/Adafruit_Micropython_Blinka.git"
+
+if sys.platform == "esp8266":
+    from boards.esp8266 import *
+elif sys.platform == "pyboard":
+    from boards.pyboard import *
diff --git a/python/boards/esp8266.py b/python/boards/esp8266.py
new file mode 100644 (file)
index 0000000..b6aa436
--- /dev/null
@@ -0,0 +1,27 @@
+# note GPIO0 and GPIO2 have built-in pull-ups on common ESP8266
+# breakout boards making them suitable for I2C SDA and SCL
+
+D0 = 16
+D1 = 5
+D2 = 4
+D3 = 0
+D4 = 2
+D5 = 14
+D6 = 12
+D7 = 13
+D8 = 15
+D9 = 3
+D10 = 1
+
+TX1 = D4
+"""Transmit pin from second (transmit-only) UART """
+
+CLK = D5
+"""SPI clock pin"""
+MISO = D6
+"""SPI MISO (Master in, Slave out)"""
+MOSI = D7
+"""SPI MOSI (Master out, Slave in)"""
+
+RX0 = D9
+TX0 = D10
diff --git a/python/boards/pyboard.py b/python/boards/pyboard.py
new file mode 100644 (file)
index 0000000..c98444f
--- /dev/null
@@ -0,0 +1 @@
+raise Error("Not yet implemented")