Since the u2if firmware uses standard HID and CDC interfaces for communicating with the host PC, it can potentially run on any Raspberry Pi RP2040 based board, not just the Pico. The main code changes needed are:
- Provide appropriate USB PID and VID.
- Change pin mappings to specific RP2040 based board.
We've done that for several Adafruit RP2040 based boards. Details for each are provided below. For each, install the provided UF2 firmware, set the environment variable:
BLINKA_U2IF=1
and then launch Python. The board will be auto detected based on USB PID and VID.
Use the firmware file u2if_feather.uf2 from the latest release.
Pico Firmware USB IDs:
USB_VID = 0x239A
USB_PID = 0x00F1
Example check-if-found test code:
import hid device = hid.device() device.open(0x239A, 0x00F1)
Here is what you should see if you list the board
pins:
$ python3 Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import board >>> dir(board) ['A0', 'A1', 'A2', 'D0', 'D1', 'D10', 'D11', 'D12', 'D13', 'D24', 'D25', 'D4', 'D5', 'D6', 'D9', 'I2C', 'MISO', 'MOSI', 'SCK', 'SCL', 'SCLK', 'SDA', 'SPI', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin', 'sys'] >>>
Here is an example that scans for connected I2C devices. Make sure something is actually connected to the SCL/SDA pins or the STEMMA QT connector.
import board i2c = board.I2C() i2c.try_lock() i2c.scan() i2c.unlock()
Use the firmware file u2if_itsybitsy.uf2 from the latest release.
Pico Firmware USB IDs:
USB_VID = 0x239A
USB_PID = 0x00FD
Example check-if-found test code:
import hid device = hid.device() device.open(0x239A, 0x00FD)
Here is what you should see if you list the board
pins:
$ python3 Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import board >>> dir(board) ['A0', 'A1', 'A2', 'BUTTON', 'D0', 'D1', 'D10', 'D11', 'D12', 'D13', 'D2', 'D24', 'D25', 'D3', 'D4', 'D5', 'D7', 'D9', 'I2C', 'MISO', 'MOSI', 'NEOPIXEL', 'NEOPIXEL_POWER', 'SCK', 'SCL', 'SCLK', 'SDA', 'SPI', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin', 'sys'] >>>
Here is a simple example program that reads the state of the BOOT button.
import time import board import digitalio button = digitalio.DigitalInOut(board.BUTTON) button.direction = digitalio.Direction.INPUT while True: # value is False when button is pressed if not button.value: print("Button pressed!") time.sleep(0.1)
Use the firmware file u2if_qtpy.uf2 from the latest release.
Pico Firmware USB IDs:
USB_VID = 0x239A
USB_PID = 0x00F7
Example check-if-found test code:
import hid device = hid.device() device.open(0x239A, 0x00F7)
Here is what you should see if you list the board
pins:
$ python3 Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import board >>> dir(board) ['A1', 'A2', 'A3', 'BUTTON', 'D0', 'D1', 'D10', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'I2C', 'MISO', 'MOSI', 'NEOPIXEL', 'NEOPIXEL_POWER', 'SCK', 'SCL', 'SCL1', 'SCLK', 'SDA', 'SDA1', 'SPI', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin', 'sys'] >>>
And here is a simple example to light the onboard NeoPixel:
import board import digitalio import neopixel pixel = neopixel.NeoPixel(board.NEOPIXEL, 1) neopwr = digitalio.DigitalInOut(board.NEOPIXEL_POWER) neopwr.direction = digitalio.Direction.OUTPUT neopwr.value = True pixel.fill(0xADAF00)
Use the firmware file u2if_trinkey.uf2 from the latest release.
Pico Firmware USB IDs:
USB_VID = 0x239A
USB_PID = 0x0109
Example check-if-found test code:
import hid device = hid.device() device.open(0x239A, 0x0109)
Here is what you should see if you list the board
pins:
$ python3 Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import board >>> dir(board) ['BUTTON', 'I2C', 'NEOPIXEL', 'SCL', 'SDA', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin', 'sys'] >>>
Here is a simple example program that reads the state of the BOOT button.
import time import board import digitalio button = digitalio.DigitalInOut(board.BUTTON) button.direction = digitalio.Direction.INPUT while True: # value is False when button is pressed if not button.value: print("Button pressed!") time.sleep(0.1)
Text editor powered by tinymce.