|
39 | 39 | # imports
|
40 | 40 | import os
|
41 | 41 | import re
|
42 |
| -from adafruit_platformdetect.constants import boards, chips, u2if |
| 42 | +from adafruit_platformdetect.constants import boards, chips |
43 | 43 |
|
44 | 44 | __version__ = "0.0.0-auto.0"
|
45 | 45 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PlatformDetect.git"
|
@@ -159,16 +159,8 @@ def id(self):
|
159 | 159 | board_id = self._stm32mp1_id()
|
160 | 160 | elif chip_id == chips.MT8167:
|
161 | 161 | board_id = boards.CORAL_EDGE_TPU_DEV_MINI
|
162 |
| - elif chip_id == u2if.PICO_U2IF: |
163 |
| - board_id = u2if.PICO_U2IF |
164 |
| - elif chip_id == u2if.FEATHER_U2IF: |
165 |
| - board_id = u2if.FEATHER_U2IF |
166 |
| - elif chip_id == u2if.ITSYBITSY_U2IF: |
167 |
| - board_id = u2if.ITSYBITSY_U2IF |
168 |
| - elif chip_id ==u2if.QTPY_U2IF: |
169 |
| - board_id = u2if.QTPY_U2IF |
170 |
| - elif chip_id == u2if.QT2040_TRINKEY_U2IF: |
171 |
| - board_id = u2if.QT2040_TRINKEY_U2IF |
| 162 | + elif chip_id == chips.RP2040_U2IF: |
| 163 | + board_id = self._rp2040_u2if_id() |
172 | 164 | self._board_id = board_id
|
173 | 165 | return board_id
|
174 | 166 |
|
@@ -468,6 +460,32 @@ def _allwinner_variants_id(self):
|
468 | 460 | # TODO: Add other specifc board contexts here
|
469 | 461 | return board
|
470 | 462 |
|
| 463 | + def _rp2040_u2if_id(self): |
| 464 | + import hid |
| 465 | + |
| 466 | + # look for it based on PID/VID |
| 467 | + for dev in hid.enumerate(): |
| 468 | + # Raspberry Pi Pico |
| 469 | + vendor = dev["vendor_id"] |
| 470 | + product = dev["product_id"] |
| 471 | + if vendor == 0xCAFE and product == 0x4005: |
| 472 | + return boards.PICO_U2IF |
| 473 | + if vendor == 0x239A: |
| 474 | + # Feather RP2040 |
| 475 | + if product == 0x00F1: |
| 476 | + return boards.FEATHER_U2IF |
| 477 | + # Itsy Bitsy RP2040 |
| 478 | + if product == 0x00FD: |
| 479 | + return boards.ITSYBITSY_U2IF |
| 480 | + # QT Py RP2040 |
| 481 | + if product == 0x00F7: |
| 482 | + return boards.QTPY_U2IF |
| 483 | + # QT2040 Trinkey |
| 484 | + if product == 0x0109: |
| 485 | + return boards.QT2040_TRINKEY_U2IF |
| 486 | + # Will only reach here if a device was added in chip.py but here. |
| 487 | + raise RuntimeError("RP2040_U2IF device was added to chip but not board.") |
| 488 | + |
471 | 489 | @property
|
472 | 490 | def any_nanopi(self):
|
473 | 491 | """Check whether the current board is any defined Nano Pi."""
|
@@ -618,27 +636,27 @@ def microchip_mcp2221(self):
|
618 | 636 | @property
|
619 | 637 | def pico_u2if(self):
|
620 | 638 | """Check whether the current board is a RPi Pico w/ u2if."""
|
621 |
| - return self.id == u2if.PICO_U2IF |
| 639 | + return self.id == boards.PICO_U2IF |
622 | 640 |
|
623 | 641 | @property
|
624 | 642 | def feather_u2if(self):
|
625 | 643 | """Check whether the current board is a Feather RP2040 w/ u2if."""
|
626 |
| - return self.id == u2if.FEATHER_U2IF |
| 644 | + return self.id == boards.FEATHER_U2IF |
627 | 645 |
|
628 | 646 | @property
|
629 | 647 | def itsybitsy_u2if(self):
|
630 | 648 | """Check whether the current board is a Itsy Bitsy w/ u2if."""
|
631 |
| - return self.id == u2if.ITSYBITSY_U2IF |
| 649 | + return self.id == boards.ITSYBITSY_U2IF |
632 | 650 |
|
633 | 651 | @property
|
634 | 652 | def qtpy_u2if(self):
|
635 | 653 | """Check whether the current board is a QT Py w/ u2if."""
|
636 |
| - return self.id == u2if.QTPY_U2IF |
| 654 | + return self.id == boards.QTPY_U2IF |
637 | 655 |
|
638 | 656 | @property
|
639 | 657 | def qt2040_trinkey_u2if(self):
|
640 | 658 | """Check whether the current board is a QT Py w/ u2if."""
|
641 |
| - return self.id == u2if.QT2040_TRINKEY_U2IF |
| 659 | + return self.id == boards.QT2040_TRINKEY_U2IF |
642 | 660 |
|
643 | 661 | @property
|
644 | 662 | def binho_nova(self):
|
|
0 commit comments