Skip to content

Commit 54358c4

Browse files
authored
Merge pull request #152 from caternuson/pico_u2if
Add Pico u2if
2 parents 59edca9 + 1ea89bd commit 54358c4

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

adafruit_platformdetect/board.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def id(self):
151151
board_id = self._stm32mp1_id()
152152
elif chip_id == chips.MT8167:
153153
board_id = boards.CORAL_EDGE_TPU_DEV_MINI
154+
elif chip_id == chips.PICO_U2IF:
155+
board_id = boards.PICO_U2IF
154156

155157
self._board_id = board_id
156158
return board_id
@@ -559,6 +561,11 @@ def microchip_mcp2221(self):
559561
"""Check whether the current board is a Microchip MCP2221."""
560562
return self.id == boards.MICROCHIP_MCP2221
561563

564+
@property
565+
def pico_u2if(self):
566+
"""Check whether the current board is a RPi Pico w/ u2if."""
567+
return self.id == boards.PICO_U2IF
568+
562569
@property
563570
def binho_nova(self):
564571
"""Check whether the current board is an BINHO NOVA."""

adafruit_platformdetect/chip.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ def id(
107107
"BLINKA_MCP2221 environment variable "
108108
+ "set, but no MCP2221 device found"
109109
)
110+
if os.environ.get("BLINKA_PICO_U2IF"):
111+
import hid
112+
113+
# look for it based on PID/VID
114+
for dev in hid.enumerate():
115+
if dev["vendor_id"] == 0xCAFE and dev["product_id"] == 0x4005:
116+
self._chip_id = chips.PICO_U2IF
117+
return self._chip_id
118+
raise RuntimeError(
119+
"BLINKA_PICO_U2IF environment variable "
120+
+ "set, but no Pico device found"
121+
)
110122
if os.environ.get("BLINKA_GREATFET"):
111123
import usb
112124

adafruit_platformdetect/constants/boards.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111

112112
MICROCHIP_MCP2221 = "MICROCHIP_MCP2221"
113113

114+
# Raspberry Pi Pico with u2if firmware
115+
# https://github.com/execuc/u2if
116+
PICO_U2IF = "PICO_U2IF"
117+
114118
BINHO_NOVA = "BINHO_NOVA"
115119

116120
ONION_OMEGA = "ONION_OMEGA"

adafruit_platformdetect/constants/chips.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
STM32MP157 = "STM32MP157"
4343
MT8167 = "MT8167"
4444
ATOM_X5_Z8350 = "X5-Z8350"
45+
PICO_U2IF = "PICO_U2IF"
4546

4647
BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"}

bin/detect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
| detector.board.FTDI_FT2232H
3434
| detector.board.MICROCHIP_MCP2221
3535
| detector.board.BINHO_NOVA
36-
| detector.board.GREATFET_ONE,
36+
| detector.board.GREATFET_ONE
37+
| detector.board.PICO_U2IF,
3738
)
3839

3940
if detector.board.any_raspberry_pi:

0 commit comments

Comments
 (0)