Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions ports/rp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ if(MICROPY_HW_USB_HOST)
usb_gamepad_mod.c
usb_cdc.c
usb_cdc_mod.c
usb_msc.c
machine_usbdrive.c
)
endif()

Expand Down Expand Up @@ -298,6 +300,7 @@ if(MICROPY_HW_USB_HOST)
${MICROPY_PORT_DIR}/usb_mouse_mod.c
${MICROPY_PORT_DIR}/usb_gamepad_mod.c
${MICROPY_PORT_DIR}/usb_cdc_mod.c
${MICROPY_PORT_DIR}/machine_usbdrive.c
)
endif()
if(MICROPY_HW_ENABLE_XMODEM)
Expand Down Expand Up @@ -479,6 +482,66 @@ if (MICROPY_BLUETOOTH_BTSTACK)
list(APPEND MICROPY_INC_CORE ${BTSTACK_INCLUDE})
endif()

# Bluetooth Classic A2DP source (stream audio out to a Bluetooth speaker),
# the `btaudio` module. Adds just the classic-profile BTstack sources this
# needs (a2dp/avdtp source role + SDP + the SBC encoder) directly to the
# firmware target, rather than linking pico-sdk's pico_btstack_classic
# library -- that would pull in its own copy of hci.c/l2cap.c, duplicating
# the ones micropy_extmod_btstack above already compiles for BLE. Classic and
# LE share ONE BTstack/HCI instance (that's the whole point of dual-mode) --
# hci.c/l2cap.c just need ENABLE_CLASSIC=1 applied to their one compilation,
# which target_compile_definitions on the firmware target itself achieves
# (it applies to every source pulled into this target, including
# micropy_extmod_btstack's INTERFACE sources).
if (MICROPY_HW_ENABLE_BT_A2DP)
if (NOT MICROPY_BLUETOOTH_BTSTACK)
message(FATAL_ERROR "MICROPY_HW_ENABLE_BT_A2DP requires MICROPY_BLUETOOTH_BTSTACK")
endif()

list(APPEND MICROPY_SOURCE_PORT
btaudio.c
${BTSTACK_LIB_DIR}/src/classic/a2dp.c
${BTSTACK_LIB_DIR}/src/classic/a2dp_source.c
${BTSTACK_LIB_DIR}/src/classic/avdtp.c
${BTSTACK_LIB_DIR}/src/classic/avdtp_acceptor.c
${BTSTACK_LIB_DIR}/src/classic/avdtp_initiator.c
${BTSTACK_LIB_DIR}/src/classic/avdtp_source.c
${BTSTACK_LIB_DIR}/src/classic/avdtp_util.c
${BTSTACK_LIB_DIR}/src/classic/sdp_client.c
${BTSTACK_LIB_DIR}/src/classic/sdp_server.c
${BTSTACK_LIB_DIR}/src/classic/sdp_util.c
${BTSTACK_LIB_DIR}/src/classic/btstack_sbc_encoder_bluedroid.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_analysis.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_dct.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_dct_coeffs.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_enc_bit_alloc_mono.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_enc_bit_alloc_ste.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_enc_coeffs.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_encoder.c
${BTSTACK_LIB_DIR}/3rd-party/bluedroid/encoder/srce/sbc_packing.c
)
list(APPEND MICROPY_SOURCE_QSTR ${MICROPY_PORT_DIR}/btaudio.c)

target_compile_definitions(${MICROPY_TARGET} PRIVATE
MICROPY_HW_ENABLE_BT_A2DP=1
ENABLE_CLASSIC=1
)
# Quiets known-noisy but harmless warnings in this vendored code (same
# suppressions pico-sdk's own pico_btstack_classic target applies).
set_source_files_properties(
${BTSTACK_LIB_DIR}/src/classic/a2dp.c
${BTSTACK_LIB_DIR}/src/classic/a2dp_source.c
${BTSTACK_LIB_DIR}/src/classic/avdtp.c
${BTSTACK_LIB_DIR}/src/classic/avdtp_source.c
${BTSTACK_LIB_DIR}/src/classic/sdp_server.c
PROPERTIES COMPILE_OPTIONS "-Wno-cast-qual"
)
set_source_files_properties(
${BTSTACK_LIB_DIR}/src/classic/avdtp_util.c
PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter"
)
endif()

if(MICROPY_BLUETOOTH_NIMBLE)
list(APPEND GIT_SUBMODULES lib/mynewt-nimble)
if(NOT UPDATE_SUBMODULES AND NOT EXISTS ${MICROPY_DIR}/lib/mynewt-nimble/nimble/host/include/host/ble_hs.h)
Expand Down
15 changes: 13 additions & 2 deletions ports/rp2/boards/PICO_COMPUTER_3/USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ over the artwork otherwise) and restore `console()` in a `finally:`. XMODEM
transfers use the serial port directly and work in any mode.

The USB device port is disabled (there is no USB-CDC prompt); the USB port is a
**host** port for keyboards, mice and touch panels.
**host** port for keyboards, mice, touch panels and USB flash drives.

At the prompt you can type Python directly, or use the shell-style helpers
(section 4). To run a program from the SD card or flash:
Expand Down Expand Up @@ -94,7 +94,7 @@ cannot be claimed with `machine.Pin()`.
| PSRAM chip-select | **GP47** | 8 MB PSRAM |
| Wi-Fi / Bluetooth (CYW43) | REG_ON **GP23**, DATA **GP24**, CS **GP25**, CLK **GP29** | wireless chip over PIO-SPI — *reserved* |
| Status LED | CYW43 **GPIO0** | on the wireless chip (not an RP2350 pin) — named pin `"LED"` |
| USB host | native USB port | keyboard / mouse / touch |
| USB host | native USB port | keyboard / mouse / touch / flash drive |

The **status LED** is on the CYW43 wireless chip, not on an RP2350 GPIO. It is
exposed as the named pin `"LED"` (an "extended" pin) and driven like any output —
Expand Down Expand Up @@ -166,6 +166,7 @@ MicroPython v1.29.0 on PICO COMPUTER 2 v0.16 with RP2350B
- **Floats:** double precision (64-bit). Integers are arbitrary precision.
- **Flash filesystem:** 12 MB LittleFS mounted at `/`.
- **SD card:** FAT, mounted at `/sd`, hot-swappable (section 12).
- **USB flash drive:** FAT, mounted at `/usb`, hot-pluggable (section 12).
- **PSRAM:** 8 MB — the Python heap lives here, so large data/images/audio
buffers are fine.

Expand Down Expand Up @@ -1538,6 +1539,16 @@ ls("/sd")
f = open("/sd/data.txt", "w"); f.write("hello"); f.close()
```

A USB flash drive works the same way, mounted at **`/usb`**: plug one into the
host port and it appears (`USB drive mounted at /usb`); unplugging it unmounts
it (`Warning: USB drive removed`). Unlike the SD card, no polling is
involved — USB tells the board directly when a drive appears or disappears.

```python
ls("/usb")
cp("/usb/prog.py", "/sd")
```

---

## 13. File transfer (XMODEM)
Expand Down
6 changes: 6 additions & 0 deletions ports/rp2/boards/PICO_COMPUTER_3/_boot_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@

pcsd.start()

# USB flash drive: mount /usb (if one is already plugged in) and react to
# further plug/unplug events -- see pcusb.py for why this needs no poll.
import pcusb

pcusb.start()

# On-screen console: console() mirrors REPL output to the HDMI screen.
import pcconsole

Expand Down
12 changes: 12 additions & 0 deletions ports/rp2/boards/PICO_COMPUTER_3/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
# runs the hot-swap removal/insertion poll (replicates MMBasic's CheckSDCard).
freeze("$(BOARD_DIR)", "pcsd.py")

# USB flash drive support is provided by the native C machine.USBDrive driver
# (machine_usbdrive.c / usb_msc.c). pcusb.py mounts /usb and reacts to
# USBDrive.on_change -- USB enumeration gives a definitive plug/unplug event,
# so unlike pcsd.py this needs no poll.
freeze("$(BOARD_DIR)", "pcusb.py")

# BLE keyboard/mouse (HID over GATT) support -- scan/pair/connect on demand
# (unlike pcsd.py/pcusb.py, this doesn't auto-start at boot: pairing is a
# deliberate user action). Feeds reports into keyboard.inject_report() /
# mouse.inject_report(), the same decoders USB keyboards/mice use.
freeze("$(BOARD_DIR)", "pcblekbd.py")

# Shell-style REPL helpers (ls, ...), injected into __main__ by _boot.py.
freeze("$(BOARD_DIR)", "pcshell.py")

Expand Down
5 changes: 5 additions & 0 deletions ports/rp2/boards/PICO_COMPUTER_3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ set(MICROPY_PY_NETWORK_CYW43 ON)
set(MICROPY_PY_BLUETOOTH ON)
set(MICROPY_BLUETOOTH_BTSTACK ON)
set(MICROPY_PY_BLUETOOTH_CYW43 ON)
# Classic Bluetooth A2DP source (stream audio out to a Bluetooth speaker),
# the `btaudio` module -- see CMakeLists.txt for why this needs ENABLE_CLASSIC
# on the shared BTstack/HCI instance rather than pico-sdk's separate
# pico_btstack_classic library.
set(MICROPY_HW_ENABLE_BT_A2DP 1)

# Pull in ulab (numpy-like ndarray/linalg) as a user C module for this board.
# ulab's own micropython.cmake defines MODULE_ULAB_ENABLED and links itself into
Expand Down
Loading