summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2026-05-12fix: CI build failures on non-RP2040 platformsSaulo Veríssimo
- Use UINT32_C(1) instead of 1u for bit shifts >= 16 in midi2_device.c to avoid shift-count-overflow on 16-bit platforms (MSP430) - Add Makefiles for midi2_device and midi2_host examples with family guard (skip if FAMILY != rp2040). These examples require Pico SDK and board-specific hardware - Restrict midi2_device CMakeLists.txt to rp2040 family (matching midi2_host)
2026-05-12fix: address PR review feedback for MIDI 2.0 driversSaulo Veríssimo
Host driver (midi2_host.c): - midih2_open() now returns actual parsed length instead of max_len, preventing composite device interface conflicts - Parsers (alt0/alt1) refactored to return const uint8_t* end pointer following midi_host.c switch/case pattern - Alt 1 CS Endpoint now parses MIDI 2.0 layout (bNumGrpTrmBlk at offset 3 with MIDI_CS_ENDPOINT_GENERAL_2_0 subtype check) instead of reusing MIDI 1.0 struct (bNumEmbMIDIJack) - midih2_set_config() now issues SET_INTERFACE control request via tuh_interface_set() before completing configuration. Falls back to alt 0 if SET_INTERFACE fails - Extracted midih2_set_config_complete() and midih2_set_interface_cb() for async SET_INTERFACE handling Device driver (midi2_device.c): - midi2d_open() skip loop now checks bInterfaceNumber, stopping at interfaces that belong to other functions in composite devices - SET_INTERFACE handler now rejects alt > 1 (returns false/stall) - Named constants for GTB descriptor types and MIDI protocol values Descriptor macros (usbd.h): - TUD_MIDI2_DESC_ALT1_HEAD: iInterface set to 0 (consistent with Alt 0), wTotalLength now uses TUD_MIDI2_DESC_ALT1_CS_LEN to cover all Alt 1 class-specific descriptors - TUD_MIDI2_DESC_ALT1_EP: now accepts GTB ID list via variadic args, emitting complete CS endpoint descriptor Host example: - CMakeLists.txt restricted to rp2040 family (display.c requires Pico SDK headers) - display.c: null terminator after strncpy in log scroll Documentation: - class_drivers.rst updated to reflect SET_INTERFACE behavior and auto-select with fallback Addresses: Codex P1 (#1, #2, #3), Copilot (#4-#9)
2026-05-12feat: add MIDI 2.0 Host class driver (USB-MIDI 2.0)Saulo Veríssimo
Add native USB-MIDI 2.0 Host class driver to TinyUSB. Implements reactive architecture: enumerate, detect MIDI 2.0 capability, inform application via callbacks. Driver features: - Parse both Alt Setting 0 (MIDI 1.0) and Alt Setting 1 (UMP) - Detect bcdMSC version from descriptor - Auto-select highest protocol (Alt 1 preferred if available) - UMP read/write via endpoint streams - Proper Audio Control interface skip (loop-based, following midi_host.c pattern) - Endpoint open with tuh_edpt_open/tu_edpt_stream_open/clear - usbh_driver_set_config_complete for USBH state machine - Handle Audio Control itf_num in set_config gracefully - 5 weak callback stubs (descriptor, mount, unmount, rx, tx) Build system: - Register midih2_* in usbh.c driver table - Add midi2_host.h include to tusb.h - Add CFG_TUH_MIDI2_LOG_LEVEL to tusb_option.h All changes guarded by #if CFG_TUH_MIDI2 (default 0). Zero impact on existing drivers and examples. Tested: Waveshare RP2350-USB-A (Host) receiving UMP from Raspberry Pi Pico (Device) via PIO-USB, board-to-board
2026-05-12feat: add MIDI 2.0 Device class driver (USB-MIDI 2.0)Saulo Veríssimo
Add native USB-MIDI 2.0 Device class driver to TinyUSB. Implements the USB-MIDI 2.0 specification with both Alt Setting 0 (MIDI 1.0 fallback) and Alt Setting 1 (UMP native) descriptor support. Driver features: - UMP (Universal MIDI Packet) read/write with atomic message framing - Protocol negotiation: Endpoint Discovery, Config Request/Notify, Function Block Discovery (embedded in driver) - Group Terminal Block descriptor via GET_DESCRIPTOR - Alt Setting switch handler with endpoint re-arm - Static allocation, no dynamic memory, ISR-safe Build system: - Register midi2d_* in usbd.c driver table - Add TUD_MIDI2_DESCRIPTOR macros to usbd.h - Add config defaults (CFG_TUD_MIDI2_*) to tusb_option.h - Add midi2_ump_word_count() to midi.h (shared by Device and Host) - Add midi2_device.c/h to family.cmake and CMakeLists.txt - Add midi2_device.h include to tusb.h All changes guarded by #if CFG_TUD_MIDI2 (default 0). Zero impact on existing drivers and examples. Tested: Raspberry Pi Pico (RP2040), Linux ALSA, Windows MIDI Services
2026-05-11Merge remote-tracking branch 'tinyusb/master' into stm32c5HiFiPhile
2026-05-11Merge pull request #3632 from hathach/msc_osZixun LI
hcd/dwc2: fix txfifo full check
2026-05-10add stm32c5 supportHiFiPHile
Signed-off-by: HiFiPHile <[email protected]>
2026-05-10Merge pull request #3630 from nminaylov/ncm_packet_filterZixun LI
NCM: support for SetEthernetPacketFilter and SetNTBInputSize request
2026-05-09dwc2: guard EP0 status completion with armed ZLP stateAlex-Schaefer
Track when an EP0 OUT zero-length transfer is actually armed and require that state before synthesizing a status-stage completion ahead of a co-reported SETUP event. This preserves the validated status-before-SETUP ordering fix while avoiding stale zero-length state from producing spurious EP0 OUT completions.
2026-05-09dwc2: preserve EP0 status completion before SETUPAlex-Schaefer
On STM32 DWC2, SETUP phase done and EP0 OUT transfer complete can be reported together. Processing SETUP first can overwrite control state before the previous zero-length OUT status stage is acknowledged, which causes DFU DNLOAD/GETSTATUS traffic to lose the status ACK and stall. Queue the EP0 OUT zero-length transfer completion before queuing the SETUP event when the endpoint has no pending OUT data and total_len is zero. This keeps TinyUSB control-transfer ordering intact for the combined interrupt case.
2026-05-08nrf5x: request HFCLK in USB_EVT_READY to fix post-SoftDevice deadlockhathach
USB_EVT_DETECTED runs hfclk_enable() which, when SoftDevice is not yet enabled, starts HFXO via direct CLOCK register access. After sd_softdevice_enable() takes over CLOCK, HFXO is physically off again and SD's HFCLK reference count is 0. If USB_EVT_READY is fired post-SD (e.g. on nRF52 via Bluefruit's usb_softdevice_post_enable() when the pre-SD nrfx_power READY callback didn't get to run before nrfx_power was uninited), the wait loop 'while (!hfclk_running()) {}' calls sd_clock_hfclk_is_running() which returns false forever -> deadlock that blocks both USB enumeration and any further app code on the calling thread. Call hfclk_enable() right before the wait so HFCLK is requested in whichever context (SD or direct) is current. hfclk_enable() is idempotent. Reproduces reliably with bleuart on Feather nRF52840 Express flashed via JLink: chip wedges in sd_clock_hfclk_is_running SVC, no USB enumeration, no BLE advertising. With the fix, USB enumerates and BLE advertises as expected.
2026-05-08fixupHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-05-08Merge remote-tracking branch 'tinyusb/master' into ncm_packet_filterHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-05-07Merge remote-tracking branch 'tinyusb/master' into ↵Zixun LI
midi-host-rx-bufsize-default-and-docs
2026-05-07revert RX buffer size as it's not related to issueZixun LI
Even if CFG_TUH_MIDI_RX_BUFSIZE=100*TUH_EPSIZE_BULK_MAX, calling tuh_midi_stream_read without a loop can return only one 4-byte packet and preventing subsequent transfer. Signed-off-by: Zixun LI <[email protected]>
2026-05-05Merge pull request #3627 from hathach/merge-usbd-controlHa Thach
Refactor USB control transfer handling into `usbd.c`
2026-05-04hcd/dwc2: fix txfifo full checkHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-05-04add default implementation for tuh_hid_report_received_cb()hathach
2026-05-04fix usbd control to support wLength hackhathach
2026-05-04refactor: replace `tu_edpt_state_t` struct with `uint8_t` and update all ↵hathach
endpoint state handling methods and accesses
2026-05-04refactor `usbd.c`: extract `process_std_device_request` for clarityhathach
2026-05-04minor clean uphathach
2026-05-04refactor `usbd.c`: centralize control transfer state management into ↵hathach
`_usbd_dev` structure and remove `usbd_control_reset`
2026-05-03Merge branch 'master' into copilot/upgrade-net-lwip-webserver-descriptorsZixun LI
2026-05-01Merge remote-tracking branch 'origin/master' into ncm_packet_filterHiFiPHile
2026-05-01ncm: implement GetNtbInputSize requestZixun LI
Signed-off-by: HiFiPHile <[email protected]>
2026-04-30ncm: Implement SetNtbInputSize requestElwin Huang
According to NCM standard 7.2.7, the device should tell the host its maximum size of NTB. Implement SetNtbInputSize according to it. Without this commit, some OS may failed to enumerate the NCM device (e.g., IOS 26). Signed-off-by: Elwin Huang <[email protected]>
2026-04-30refactor capabilityZixun LI
Signed-off-by: Zixun LI <[email protected]>
2026-04-30add packet filter callbackZixun LI
Co-authored-by: Copilot <[email protected]> Signed-off-by: Zixun LI <[email protected]>
2026-04-29deprecated `usbd_control.c` and merge its functionality into `usbd.c`hathach
2026-04-29clean uphathach
2026-04-28Merge branch 'master' into fork/kira-live/masterhathach
# Conflicts: # src/device/usbd_control.c
2026-04-28fix(dcd_ch32_usbfs): fix dropped bulk OUT packets by properly re-arming ↵mickabrig7
EP_RX_CTRL state
2026-04-27Merge branch 'master' into ncm_packet_filternminaylov
2026-04-27NCM caps enumnminaylov
2026-04-26usbd_control: consolidate status stage ep selectionhathach
Extract the "which endpoint is the Status stage on" rule into a single TU_ATTR_ALWAYS_INLINE helper, and use it from both status_stage_xact() and the completion callback. Replaces the two-operand wLength/direction check with a direct endpoint-match comparison, matching the first operand's pattern. Per USB 2.0 §9.3.1, when wLength == 0 the bmRequestType Direction bit is ignored and the Status stage is always IN; otherwise the Status stage is opposite to the Data stage direction. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-04-25fix: add BE bitfield guards for audio and fix UAC2 example endian-safe field ↵copilot-swe-agent[bot]
extraction - Add TU_BITFIELD_ORDER guards for audio10_desc_as_iso_data_ep_t.bmAttributes in audio.h - Add TU_BITFIELD_ORDER guards for audio20_control_request_t.bmRequestType_bit in audio.h - Fix cdc_uac2/src/uac2_app.c: replace alias cast with TU_U16_LOW/HIGH field extraction - Fix uac2_headset/src/main.c: replace alias cast with TU_U16_LOW/HIGH field extraction - Fix uac2_speaker_fb/src/main.c: replace alias cast with TU_U16_LOW/HIGH field extraction Addresses review comment: https://github.com/hathach/tinyusb/pull/3597#issuecomment-4320042007 Agent-Logs-Url: https://github.com/hathach/tinyusb/sessions/8b695271-74b3-4a26-b3d8-c48ecdf2e481 Co-authored-by: HiFiPhile <[email protected]>
2026-04-25Merge branch 'master' into musb-followup-3594hathach
# Conflicts: # src/common/tusb_types.h # src/portable/mentor/musb/dcd_musb.c
2026-04-25separate pipe0 since it is 1 packet per transfer, merge PIPE0 STATUS PENDINGhathach
2026-04-25clean uphathach
2026-04-25musb more ep0 refactor. add back remaining_ctrl for correct ep0 state ↵hathach
transition. handle status out to make sure xfer_complete() not called before dcd_edpt_xfer()
2026-04-24NCM packet filter supportnminaylov
2026-04-24musb migrate to ep0_state, remove setup packet from dcd datahathach
2026-04-24refactor musb ep0 xferhathach
2026-04-24Merge pull request #3597 from canokeys/big-endian-for-setup-packetsZixun LI
fix #3596: big-endian host support for SETUP packet handling
2026-04-23typec/stm32: guard hard reset RX re-arm against uninitialized bufferMike Ajax
2026-04-23typec/stm32: updates based on Copilot reviewMike Ajax
2026-04-23typec/stm32: fix -Wcast-qual error, _rx_buf doesn't need constMike Ajax
2026-04-23typec/stm32: fix three UCPD sink bugs for strict PD 3.0 sourcesMike Ajax
2026-04-24fix zero wLength request in control requestakari