diff options
| author | Ha Thach <[email protected]> | 2025-12-13 18:48:07 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-13 18:48:07 +0700 |
| commit | 54857210e6541b1e41970ab70f19d3cdf434011c (patch) | |
| tree | ab4a1222fc804fa8b13ac836cc592c66af66ef73 /src/device | |
| parent | 20b03bbc081353295f7a491038bd3efbc9c3a75a (diff) | |
| parent | 85354377fd855480f4be99fb67e5805fe88d059d (diff) | |
Merge pull request #3358 from hathach/dwc2_cfg
Add dcd_configure for dwc2 FIFO config
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/dcd.h | 3 | ||||
| -rw-r--r-- | src/device/usbd.c | 15 | ||||
| -rw-r--r-- | src/device/usbd.h | 20 |
3 files changed, 35 insertions, 3 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h index 8a074ab47..850c37bc2 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -107,6 +107,9 @@ bool dcd_dcache_clean_invalidate(const void* addr, uint32_t data_size); // Controller API //--------------------------------------------------------------------+ +// optional dcd configuration, called by tud_configure() +bool dcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param); + // Initialize controller to device mode bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init); diff --git a/src/device/usbd.c b/src/device/usbd.c index 6c2ff2f62..e337a5000 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -425,6 +425,11 @@ TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t return false; } +TU_ATTR_WEAK bool dcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) { + (void) rhport; (void) cfg_id; (void) cfg_param; + return false; +} + //--------------------------------------------------------------------+ // Debug //--------------------------------------------------------------------+ @@ -494,13 +499,14 @@ void tud_sof_cb_enable(bool en) { usbd_sof_enable(_usbd_rhport, SOF_CONSUMER_USER, en); } -//--------------------------------------------------------------------+ -// USBD Task -//--------------------------------------------------------------------+ bool tud_inited(void) { return _usbd_rhport != RHPORT_INVALID; } +bool tud_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) { + return dcd_configure(rhport, cfg_id, cfg_param); +} + bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { if (tud_inited()) { return true; // skip if already initialized @@ -624,6 +630,9 @@ bool tud_task_event_ready(void) { return !osal_queue_empty(_usbd_q); } +//--------------------------------------------------------------------+ +// USBD Task +//--------------------------------------------------------------------+ /* USB Device Driver task * This top level thread manages all device controller event and delegates events to class-specific drivers. * This should be called periodically within the mainloop or rtos thread. diff --git a/src/device/usbd.h b/src/device/usbd.h index c446638c3..efde9377f 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -33,10 +33,30 @@ extern "C" { #endif +// ConfigID for tud_configure() +enum { + TUD_CFGID_INVALID = 0, + TUD_CFGID_DWC2 = 100, +}; + +typedef struct { + uint16_t bm_double_buffered; // bitmap of IN endpoints to be double buffered, only effective for bulk endpoints +} tud_configure_dwc2_t; + +typedef union { + tud_configure_dwc2_t dwc2; +} tud_configure_param_t; + //--------------------------------------------------------------------+ // Application API //--------------------------------------------------------------------+ +// Configure device stack behavior with dynamic or port-specific parameters. +// Should be called before initialization of the device stack +// - cfg_id : configure ID from TUD_CFGID_* enum values +// - cfg_param: configure data, structure depends on the ID +bool tud_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param); + // New API to replace tud_init() to init device stack on specific roothub port bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init); |
