Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion adafruit_platformdetect/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@
ODROID_C2 = "ODROID_C2"
ODROID_N2 = "ODROID_N2"

FTDI_FT232H = "FT232H"
FTDI_FT232H = "FTDI_FT232H"
DRAGONBOARD_410C = "DRAGONBOARD_410C"

SIFIVE_UNLEASHED = "SIFIVE_UNLEASHED"

MICROCHIP_MCP2221 = "MICROCHIP_MCP2221"

# pylint: enable=bad-whitespace

#OrangePI
Expand Down Expand Up @@ -333,6 +335,8 @@ def id(self):
board_id = self._tegra_id()
elif chip_id == ap_chip.HFU540:
board_id = self._sifive_id()
elif chip_id == ap_chip.MCP2221:
board_id = MICROCHIP_MCP2221
return board_id
# pylint: enable=invalid-name

Expand Down Expand Up @@ -492,6 +496,11 @@ def ftdi_ft232h(self):
"""Check whether the current board is an FTDI FT232H."""
return self.id == FTDI_FT232H

@property
def microchip_mcp2221(self):
"""Check whether the current board is a Microchip MCP2221."""
return self.id == MICROCHIP_MCP2221

def __getattr__(self, attr):
"""
Detect whether the given attribute is the currently-detected board. See list
Expand Down
30 changes: 18 additions & 12 deletions adafruit_platformdetect/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
GENERIC_X86 = "GENERIC_X86"
FT232H = "FT232H"
HFU540 = "HFU540"
MCP2221 = "MCP2221"

class Chip:
"""Attempt detection of current chip / CPU."""
Expand All @@ -36,18 +37,23 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-s
except KeyError: # no forced chip, continue with testing!
pass

# Special case, if we have an environment var set, we could use FT232H
try:
if os.environ['BLINKA_FT232H']:
from pyftdi.usbtools import UsbTools # pylint: disable=import-error
# look for it based on PID/VID
count = len(UsbTools.find_all([(0x0403, 0x6014)]))
if count == 0:
raise RuntimeError('BLINKA_FT232H environment variable' + \
'set, but no FT232H device found')
return FT232H
except KeyError: # no FT232H environment var
pass
# Special cases controlled by environment var
if os.environ.get('BLINKA_FT232H'):
from pyftdi.usbtools import UsbTools # pylint: disable=import-error
# look for it based on PID/VID
count = len(UsbTools.find_all([(0x0403, 0x6014)]))
if count == 0:
raise RuntimeError('BLINKA_FT232H environment variable ' + \
'set, but no FT232H device found')
return FT232H
if os.environ.get('BLINKA_MCP2221'):
import hid # pylint: disable=import-error
# look for it based on PID/VID
for dev in hid.enumerate():
if dev['vendor_id'] == 0x04D8 and dev['product_id'] == 0x00DD:
return MCP2221
raise RuntimeError('BLINKA_MCP2221 environment variable ' + \
'set, but no MCP2221 device found')

platform = sys.platform
if platform == "linux" or platform == "linux2":
Expand Down
2 changes: 2 additions & 0 deletions bin/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
print("Is this a SiFive Unleashed? ", detector.board.SIFIVE_UNLEASHED)
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
print("Is this an OS environment variable special case?", detector.board.FTDI_FT232H |
detector.board.MICROCHIP_MCP2221 )

if detector.board.any_raspberry_pi:
print("Raspberry Pi detected.")
Expand Down