20
20
GENERIC_X86 = "GENERIC_X86"
21
21
FT232H = "FT232H"
22
22
HFU540 = "HFU540"
23
+ MCP2221 = "MCP2221"
23
24
24
25
class Chip :
25
26
"""Attempt detection of current chip / CPU."""
@@ -36,18 +37,23 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-s
36
37
except KeyError : # no forced chip, continue with testing!
37
38
pass
38
39
39
- # Special case, if we have an environment var set, we could use FT232H
40
- try :
41
- if os .environ ['BLINKA_FT232H' ]:
42
- from pyftdi .usbtools import UsbTools # pylint: disable=import-error
43
- # look for it based on PID/VID
44
- count = len (UsbTools .find_all ([(0x0403 , 0x6014 )]))
45
- if count == 0 :
46
- raise RuntimeError ('BLINKA_FT232H environment variable' + \
47
- 'set, but no FT232H device found' )
48
- return FT232H
49
- except KeyError : # no FT232H environment var
50
- pass
40
+ # Special cases controlled by environment var
41
+ if os .environ .get ('BLINKA_FT232H' ):
42
+ from pyftdi .usbtools import UsbTools # pylint: disable=import-error
43
+ # look for it based on PID/VID
44
+ count = len (UsbTools .find_all ([(0x0403 , 0x6014 )]))
45
+ if count == 0 :
46
+ raise RuntimeError ('BLINKA_FT232H environment variable ' + \
47
+ 'set, but no FT232H device found' )
48
+ return FT232H
49
+ if os .environ .get ('BLINKA_MCP2221' ):
50
+ import hid # pylint: disable=import-error
51
+ # look for it based on PID/VID
52
+ for dev in hid .enumerate ():
53
+ if dev ['vendor_id' ] == 0x04D8 and dev ['product_id' ] == 0x00DD :
54
+ return MCP2221
55
+ raise RuntimeError ('BLINKA_MCP2221 environment variable ' + \
56
+ 'set, but no MCP2221 device found' )
51
57
52
58
platform = sys .platform
53
59
if platform == "linux" or platform == "linux2" :
0 commit comments