]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/board.py
Merge pull request #372 from scottamain/pwmbug
[Adafruit_Blinka-hackapet.git] / src / board.py
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2017 cefn for adafruit industries
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22 """
23 `board` - Define ids for available pins
24 =================================================
25
26 See `CircuitPython:board` in CircuitPython for more details.
27
28 * Author(s): cefn
29 """
30 import sys
31
32 import adafruit_platformdetect.constants.boards as ap_board
33 from adafruit_blinka.agnostic import board_id, detector
34
35 # pylint: disable=wildcard-import,unused-wildcard-import,ungrouped-imports
36 # pylint: disable=import-outside-toplevel
37
38 if board_id == ap_board.FEATHER_HUZZAH:
39     from adafruit_blinka.board.feather_huzzah import *
40
41 elif board_id == ap_board.NODEMCU:
42     from adafruit_blinka.board.nodemcu import *
43
44 elif board_id == ap_board.PYBOARD:
45     from adafruit_blinka.board.pyboard import *
46
47 elif detector.board.any_raspberry_pi_40_pin:
48     from adafruit_blinka.board.raspberrypi.raspi_40pin import *
49
50 elif detector.board.any_raspberry_pi_cm:
51     from adafruit_blinka.board.raspberrypi.raspi_cm import *
52
53 elif detector.board.RASPBERRY_PI_B_REV1:
54     from adafruit_blinka.board.raspberrypi.raspi_1b_rev1 import *
55
56 elif detector.board.RASPBERRY_PI_A or detector.board.RASPBERRY_PI_B_REV2:
57     from adafruit_blinka.board.raspberrypi.raspi_1b_rev2 import *
58
59 elif board_id == ap_board.BEAGLEBONE_BLACK:
60     from adafruit_blinka.board.beagleboard.beaglebone_black import *
61
62 elif board_id == ap_board.BEAGLEBONE_GREEN:
63     from adafruit_blinka.board.beagleboard.beaglebone_black import *
64
65 elif board_id == ap_board.BEAGLEBONE_BLACK_INDUSTRIAL:
66     from adafruit_blinka.board.beagleboard.beaglebone_black import *
67
68 elif board_id == ap_board.BEAGLEBONE_GREEN_WIRELESS:
69     from adafruit_blinka.board.beagleboard.beaglebone_black import *
70 elif board_id == ap_board.BEAGLEBONE_BLACK_WIRELESS:
71     from adafruit_blinka.board.beagleboard.beaglebone_black import *
72 elif board_id == ap_board.BEAGLEBONE_POCKETBEAGLE:
73     from adafruit_blinka.board.beagleboard.beaglebone_pocketbeagle import *
74
75 elif board_id == ap_board.ORANGE_PI_PC:
76     from adafruit_blinka.board.orangepi.orangepipc import *
77
78 elif board_id == ap_board.ORANGE_PI_R1:
79     from adafruit_blinka.board.orangepi.orangepir1 import *
80
81 elif board_id == ap_board.ORANGE_PI_ZERO:
82     from adafruit_blinka.board.orangepi.orangepizero import *
83
84 elif board_id == ap_board.ORANGE_PI_ONE:
85     from adafruit_blinka.board.orangepi.orangepipc import *
86
87 elif board_id == ap_board.ORANGE_PI_PC_PLUS:
88     from adafruit_blinka.board.orangepi.orangepipc import *
89
90 elif board_id == ap_board.ORANGE_PI_LITE:
91     from adafruit_blinka.board.orangepi.orangepipc import *
92
93 elif board_id == ap_board.ORANGE_PI_PLUS_2E:
94     from adafruit_blinka.board.orangepi.orangepipc import *
95
96 elif board_id == ap_board.ORANGE_PI_2:
97     from adafruit_blinka.board.orangepi.orangepipc import *
98
99 elif board_id == ap_board.BANANA_PI_M2_ZERO:
100     from adafruit_blinka.board.bananapi.bpim2zero import *
101
102 elif board_id == ap_board.GIANT_BOARD:
103     from adafruit_blinka.board.giantboard import *
104
105 elif board_id == ap_board.JETSON_TX1:
106     from adafruit_blinka.board.nvidia.jetson_tx1 import *
107
108 elif board_id == ap_board.JETSON_TX2:
109     from adafruit_blinka.board.nvidia.jetson_tx2 import *
110
111 elif board_id == ap_board.JETSON_XAVIER:
112     from adafruit_blinka.board.nvidia.jetson_xavier import *
113
114 elif board_id == ap_board.JETSON_NANO:
115     from adafruit_blinka.board.nvidia.jetson_nano import *
116
117 elif board_id == ap_board.JETSON_NX:
118     from adafruit_blinka.board.nvidia.jetson_nx import *
119
120 elif board_id == ap_board.CLARA_AGX_XAVIER:
121     from adafruit_blinka.board.nvidia.clara_agx_xavier import *
122
123 elif board_id == ap_board.CORAL_EDGE_TPU_DEV:
124     from adafruit_blinka.board.coral_edge_tpu import *
125
126 elif board_id == ap_board.ODROID_C2:
127     from adafruit_blinka.board.hardkernel.odroidc2 import *
128
129 elif board_id == ap_board.ODROID_C4:
130     from adafruit_blinka.board.hardkernel.odroidc4 import *
131
132 elif board_id == ap_board.ODROID_N2:
133     from adafruit_blinka.board.hardkernel.odroidn2 import *
134
135 elif board_id == ap_board.ODROID_XU4:
136     from adafruit_blinka.board.hardkernel.odroidxu4 import *
137
138 elif board_id == ap_board.DRAGONBOARD_410C:
139     from adafruit_blinka.board.dragonboard_410c import *
140
141 elif board_id == ap_board.FTDI_FT232H:
142     from adafruit_blinka.board.ftdi_ft232h import *
143
144 elif board_id == ap_board.BINHO_NOVA:
145     from adafruit_blinka.board.binho_nova import *
146
147 elif board_id == ap_board.MICROCHIP_MCP2221:
148     from adafruit_blinka.board.microchip_mcp2221 import *
149
150 elif board_id == ap_board.GREATFET_ONE:
151     from adafruit_blinka.board.greatfet_one import *
152
153 elif board_id == ap_board.SIFIVE_UNLEASHED:
154     from adafruit_blinka.board.hifive_unleashed import *
155
156 elif board_id == ap_board.PINE64:
157     from adafruit_blinka.board.pine64 import *
158
159 elif board_id == ap_board.PINEH64:
160     from adafruit_blinka.board.pineH64 import *
161
162 elif board_id == ap_board.SOPINE:
163     from adafruit_blinka.board.soPine import *
164
165 elif board_id == ap_board.CLOCKWORK_CPI3:
166     from adafruit_blinka.board.clockworkcpi3 import *
167
168 elif board_id == ap_board.ONION_OMEGA2:
169     from adafruit_blinka.board.onion.omega2 import *
170
171 elif board_id == ap_board.ROCK_PI_S:
172     from adafruit_blinka.board.radxa.rockpis import *
173
174 elif board_id == ap_board.UDOO_X86:
175     from adafruit_blinka.board.udoo_x86ultra import *
176
177 elif board_id == ap_board.STM32MP157C_DK2:
178     from adafruit_blinka.board.stm32.stm32mp157c_dk2 import *
179
180 elif "sphinx" in sys.modules:
181     pass
182
183 else:
184     raise NotImplementedError("Board not supported {}".format(board_id))
185
186
187 def I2C():
188     """The singleton I2C interface"""
189     import busio
190
191     return busio.I2C(SCL, SDA)
192
193
194 def SPI():
195     """The singleton SPI interface"""
196     import busio
197
198     return busio.SPI(SCLK, MOSI, MISO)