usb_host – USB Host

The usb_host module allows you to manage USB host ports. To communicate with devices use the usb module that is a subset of PyUSB’s API.

Available on these boards
  • 0xCB Helios
  • 42. Keebs Frood
  • Adafruit Feather RP2040
  • Adafruit Feather RP2040 CAN
  • Adafruit Feather RP2040 DVI
  • Adafruit Feather RP2040 Prop-Maker
  • Adafruit Feather RP2040 RFM
  • Adafruit Feather RP2040 Scorpio
  • Adafruit Feather RP2040 ThinkInk
  • Adafruit Feather RP2040 USB Host
  • Adafruit Floppsy RP2040
  • Adafruit ItsyBitsy RP2040
  • Adafruit KB2040
  • Adafruit Macropad RP2040
  • Adafruit Metro RP2040
  • Adafruit QT Py RP2040
  • Adafruit QT2040 Trinkey
  • Arduino Nano RP2040 Connect
  • BBQ20KBD
  • BLOK
  • COSMO-Pico
  • Challenger NB RP2040 WiFi
  • Challenger RP2040 LTE
  • Challenger RP2040 LoRa
  • Challenger RP2040 SD/RTC
  • Challenger RP2040 SubGHz
  • Challenger RP2040 WiFi
  • Challenger RP2040 WiFi/BLE
  • Cytron EDU PICO W
  • Cytron Maker Nano RP2040
  • Cytron Maker Pi RP2040
  • Cytron Maker Uno RP2040
  • Datanoise PicoADK
  • E-Fidget
  • ELECFREAKS PICO:ED
  • Electrolama minik
  • EncoderPad RP2040
  • Fig Pi
  • HEIA-FR Picomo V2
  • Hack Club Sprig
  • LILYGO T-DISPLAY
  • Maple Computing Elite-Pi
  • Melopero Shake RP2040
  • Oak Dev Tech BREAD2040
  • Oak Dev Tech Cast-Away RP2040
  • Pajenicko PicoPad
  • Pimoroni Badger 2040
  • Pimoroni Badger 2040 W
  • Pimoroni Inky Frame 5.7
  • Pimoroni Inky Frame 7.3
  • Pimoroni Interstate 75
  • Pimoroni Keybow 2040
  • Pimoroni Motor 2040
  • Pimoroni PGA2040
  • Pimoroni Pico DV Base W
  • Pimoroni Pico LiPo (16MB)
  • Pimoroni Pico LiPo (4MB)
  • Pimoroni Pico dv Base
  • Pimoroni PicoSystem
  • Pimoroni Plasma 2040
  • Pimoroni Plasma 2040W
  • Pimoroni Servo 2040
  • Pimoroni Tiny 2040 (2MB)
  • Pimoroni Tiny 2040 (8MB)
  • PyKey 18 Numpad
  • PyKey 44 Ergo
  • PyKey 60
  • PyKey 87 TKL
  • RP2.65-F
  • RP2040 Stamp
  • Raspberry Breadstick
  • Raspberry Pi Pico
  • Raspberry Pi Pico W
  • Seeeduino XIAO RP2040
  • Silicognition LLC RP2040-Shim
  • SparkFun MicroMod RP2040 Processor
  • SparkFun Pro Micro RP2040
  • SparkFun Teensy MicroMod Processor
  • SparkFun Thing Plus - RP2040
  • Teensy 4.1
  • VCC-GND Studio YD RP2040
  • W5100S-EVB-Pico
  • W5500-EVB-Pico
  • Waveshare RP2040-LCD-0.96
  • Waveshare RP2040-LCD-1.28
  • Waveshare RP2040-Plus (16MB)
  • Waveshare RP2040-Plus (4MB)
  • Waveshare RP2040-TOUCH-LCD-1.28
  • Waveshare RP2040-Tiny
  • Waveshare RP2040-Zero
  • WeAct Studio Pico
  • WeAct Studio Pico 16MB
  • WisdPi Ardu2040M
  • WisdPi Tiny RP2040
  • iMX RT 1050 EVKB
  • iMX RT 1060 EVK
  • iMX RT 1060 EVKB
  • nullbits Bit-C PRO
  • splitkb.com Liatris
  • takayoshiotake Octave RP2040
  • uGame22

usb_host.set_user_keymap(keymap: circuitpython_typing.ReadableBuffer, /) None

Set the keymap used by a USB HID keyboard in kernel mode

The keymap consists of 256 or 384 1-byte entries that map from USB keycodes to ASCII codes. The first 128 entries are for unmodified keys, the next 128 entries are for shifted keys,and the next optional 128 entries are for altgr-modified keys.

The values must all be ASCII (32 through 126 inclusive); other values are not valid.

The values at index 0, 128, and 256 (if the keymap has 384 entries) must be 0; other values are reserved for future expansion to indicate alternate keymap formats.

At other indices, the value 0 is used to indicate that the normal definition is still used. For instance, the entry for HID_KEY_ARROW_UP (0x52) is usually 0 so that the default behavior of sending an escape code is preserved.

This function is a CircuitPython extension not present in PyUSB

class usb_host.Port(dp: microcontroller.Pin, dm: microcontroller.Pin)

USB host port. Also known as a root hub port.

Create a USB host port on the given pins. Access attached devices through the usb module.

The resulting object lives longer than the CircuitPython VM so that USB devices such as keyboards can continue to be used. Subsequent calls to this constructor will return the same object and not reinitialize the USB host port. It will raise an exception when given different arguments from the first successful call.

Parameters:
  • dp (Pin) – The data plus pin

  • dm (Pin) – The data minus pin