summaryrefslogtreecommitdiff
path: root/src/portable/nxp/lpc17_40
AgeCommit message (Collapse)Author
2026-07-18dcd_lpc17_40: address review findings in the iso pathshathach
From a second max-effort review of the branch: - Drop the dead TUSB_XFER_ISOCHRONOUS case in dcd_edpt_open: iso endpoints are armed via dcd_edpt_iso_alloc/activate (TUP_DCD_EDPT_ISO_ALLOC is defined for this IP), never through dcd_edpt_open, so the case and its dd->isochronous assignment were unreachable and asserted a false invariant. Only bulk/interrupt reach the switch now. - Extend the iso compile gate to the classes that actually arm an iso endpoint: DCD_ISO_ENABLED now includes CFG_TUD_BTH (bth_device.c opens an iso voice endpoint). Without it a BTH build would compile the iso machinery out and fail SET_INTERFACE at runtime. - Un-skip LPC175X_6X in the usbtest example: it shares dcd_lpc17_40.c with LPC40XX verbatim, so the "DCD has no isochronous support" skip reason no longer holds. Build-verified for lpcxpresso1769 (previously blocked by the skip). - TU_ATTR_UNUSED on the ep_id_is_iso helper: every caller is under #if DCD_ISO_ENABLED, so non-iso builds don't reference it and clang's -Wunused-function (fatal in CI) rejected the build — gcc stays quiet. Verified with the full lpc17 and lpc40 example sets under arm-clang. A fifth finding — bounding control_ep_read's PACKET_READY spin with a timeout — was implemented and REVERTED: a naive 100k-iteration bound fires on legitimately-slow control reads and intermittently drops the device (hardware-proven by interleaved A/B testing against the pre-fix binary). The infinite wait is retained; the read is only reached once out_received/ out_queued signal data is present, so the theoretical IRQ-off hang is not reachable in practice. Re-verified on ea4088_quickstart: usbtest 30/30 (repeated) + HIL 14/14.
2026-07-17dcd_lpc17_40: mask USB IRQ around non-reentrant SIE and realization sequenceshathach
The SIE command protocol (CmdCode + CCEMPTY/CDFULL handshake), the slave-mode Ctrl/RxData/TxData window, the EpIntEn read-modify-writes, and set_ep_size's ReEp/EP_RLZED handshake are all shared between thread-mode API calls and dcd_int_handler, and none are reentrant: an ISR preempting a thread-mode sequence consumes its handshake flags or, in set_ep_size's case, a bus reset's DevIntClr = 0xFFFFFFFF eats the EP_RLZED flag the spin waits on, hanging it forever. Guard them by masking only the USB IRQ (nestable, ISR-safe; CMSIS NVIC_DisableIRQ already ends with DSB+ISB). control_xact keeps the mask across its in_isr=true event push, since osal_none skips queue locking for in_isr. Hardening, not a fix for an observed failure: the ea4088 usbtest 30/30 + HIL 14/14 results were reproduced with and without it. The windows are a few instructions wide and most exposed on RTOS builds where class drivers queue transfers from tasks concurrent with the USB IRQ.
2026-07-17dcd_lpc17_40: fix stale EP0 out_received, add isochronous supporthathach
EP0 control-OUT fix (usbtest 14/21, errno 110/-74): usbd queues the status-stage OUT ZLP of every control read with buffer=NULL, so the ISR's `if (out_buffer)` check missed it and marked the arriving ZLP as out_received instead. The stale flag poisoned the next control-OUT with data: its first chunk "completed" instantly from an empty EP0 buffer and the host's real DATA NAKed forever. Track queued transfers with an explicit out_queued flag and void half-finished control state on a new SETUP. Isochronous support (UM10562 12.15.6): 5-word DMA descriptors with per-packet size memory, buflen/present_count in packets, one packet per FRAME (no DMARSet/EpIntEn involvement), completion at EOT for both directions. Details that matter: - the iso machinery (5th DD word + packet-size memory) is compiled only when an iso-capable class is enabled (CFG_TUD_AUDIO/VIDEO/VENDOR), so non-iso builds pay nothing: _dcd stays 648 B vs 1032 B with iso - ISR dispatch keys on the hardware's fixed ep-number/type map (ep_id_is_iso), never on dd fields that thread mode rebuilds - iso OUT honors Packet_valid (bit 16) and prefills the hardware writeback slots with 0, so a missed frame counts as 0 bytes instead of reading back stale buffer contents as data - packet count is validated (tu_div_ceil <= ISO_MAX_PACKETS) before the DD is touched, so an oversized transfer is refused without leaving a serviceable half-built descriptor armed for the frame engine - dcd_edpt_iso_alloc and iso_activate both enforce the fixed iso endpoint numbers (3/6/9/12); classes ignore alloc's return value, so activate must not trust it Un-skip LPC40XX in the usbtest example; tier 4 now enumerates and passes iso cases 15/16/22/23. cdc_msc_throughput and printer_to_cdc had bulk on iso-only EP3 (SET_CONFIGURATION failed with -32); add the LPC17/40 EPNUM block (bulk on EP2/EP5) like other fixed-EP examples. Verified on ea4088_quickstart: usbtest tier-4 battery 30/30 repeatedly and the full device HIL suite 14/14 (incl. audio_test iso).
2026-07-02license: use SPDX identifiers for src/ headers (#3749)Ha Thach
* license: use SPDX identifiers for src/ headers Replace the full ~20-line MIT license boilerplate on every src/ file with a two-line SPDX tag (SPDX-FileCopyrightText + SPDX-License-Identifier), following the REUSE convention used by CircuitPython and the Linux kernel. Removes ~3500 lines of duplicated boilerplate.
2026-04-17fix some Wconversion warningshathach
2025-11-19Merge remote-tracking branch 'tinyusb/master' into ↵HiFiPhile
copilot/fix-dcd-edpt-xfer-issue Signed-off-by: HiFiPhile <[email protected]>
2025-11-17make TUP_DCD_EDPT_ISO_ALLOC i.e dcd_edpt_iso_alloc()/dcd_edpt_iso_activate() ↵hathach
as default driver implementation. dcd_edpt_close() is deprecated and will be removed from all driver in the future.
2025-10-31Merge branch 'copilot/fix-dcd-edpt-xfer-issue' of ↵HiFiPhile
https://github.com/hathach/tinyusb into copilot/fix-dcd-edpt-xfer-issue
2025-10-31Merge remote-tracking branch 'tinyusb/master' into ↵HiFiPhile
copilot/fix-dcd-edpt-xfer-issue Signed-off-by: HiFiPhile <[email protected]>
2025-10-30Merge branch 'master' into add-ohci-lpc55hathach
# Conflicts: - hw/bsp/lpc17/family.cmake - hw/bsp/lpc40/family.cmake - hw/bsp/lpc55/family.cmake
2025-10-28fix Identifiers that start with '__' or '_[A-Z]' are reserved.hathach
fix compiling with nuc family
2025-10-22Apply suggestions from code reviewZixun LI
Co-authored-by: Copilot <[email protected]>
2025-10-22Add is_isr parameter to dcd_edpt_xfer and dcd_edpt_xfer_fifocopilot-swe-agent[bot]
Co-authored-by: HiFiPhile <[email protected]>
2025-10-10try to enable ohci for lpc55 but not working, probably clock issuehathach
2025-04-23rename and expose tuh_bus_info_get() to applicationhathach
2024-11-27Fix missing protoype warning, change TUD_EPBUF_TYPE_DEF order (#2889)Ha Thach
* change TUD_EPBUF_TYPE_DEF order * add and fix -Wmissing-prototypes warnings for cmake (skip make)
2024-10-14change dcd_init() return from void to boolhathach
2024-10-14change the tusb_rhport_init_t struct, exclude the rhport to make API more ↵hathach
consistent
2024-10-11change dcd_init() to take rhport structhathach
2024-08-19remove weak from dcd_edpt_close() for port without TUP_DCD_EDPT_ISO_ALLOChathach
2023-07-24rename CFG_TUSB_MEM_SECTION to CFG_TUD_MEM_SECTION in device stackhathach
CFG_TUD_MEM_SECTION is default to CFG_TUSB_MEM_SECTION
2023-03-17fix trailing space and new linehathach
temporarily disable codespell
2022-03-07added dcd_sof_enable() stubs for all other portshathach
2022-02-25rename TUSB_OPT_HOST_ENABLED to CFG_TUH_ENABLEDhathach
2022-02-25rename TUSB_OPT_DEVICE_ENABLED to CFG_TUD_ENABLEDhathach
TUSB_OPT_DEVICE_ENABLED still usable for backward compatible
2021-10-24remove ep descriptor wMaxPacketSize bitfield due to endian issuehathach
2021-08-26add dcd_edpt_close_all() for clear existing configured statehathach
correctly responded to TD 9.13 Set Configuration Test
2021-03-16fix build with OPT_MCU_LPC177X_8Xhathach
2021-01-08use dcd_event_bus_reset() with speed to replace bus_signalhathach
2020-08-01enable pull-up in dcd_init() instead of usbdhathach
2020-04-17complete remove dcd_set_config(), fix unit testhathach
2020-04-17Merge branch 'master' into remove-dcd-set-confighathach
2020-04-17mass rename tud/dcd_irq_handler to tud/dcd_init_handlerhathach
2020-04-16implement dcd disconnect/connect for lpc ip3511hathach
2020-04-16added dcd disconnect/connect to lpc17/40hathach
2020-04-13lpc17xx move set configdevice into set addresshathach
for removing dcd_set_config()
2020-04-06mass rename dcd_isr() to dcd_irq_handler()hathach
2019-11-21moving irq to bsp for lpc17/40hathach
2019-11-21rename lpc 17/18 irq to dcd_isr/hcd_isrhathach
2019-09-27Fix typo of CFG_TUD_ENDOINT0_SIZE.Nathan Conrad
2019-09-16fix #143hathach
2019-06-10remove dcd_edpt_busy()hathach
2019-06-06add TU_ prefix to compiler ATTR to prevent name conflict with applicationhathach
2019-05-14more clean up use inline bit funciton instead of macroshathach
2019-05-14update license year to 2019hathach
2019-03-30added dcd_remote_wakeup() stub for all portshathach
2019-03-29working on suspend and resumehathach
change dcd_init signature
2019-03-29added Suspend and Resume event for nrf5x porthathach
also rename DCD_EVENT_SUSPENDED to DCD_EVENT_SUSPEND
2019-03-27replace dcd_edpt_(clear)stall by usbd_edpt_(clear)stallhathach
- remove dcd_edpt_stalled() from dcd porting
2019-03-27remove dcd_get_frame_number()hathach