Skip to content

Commit 3842980

Browse files
committed
dcd: add tud_configure()
Signed-off-by: HiFiPhile <[email protected]>
1 parent c785469 commit 3842980

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/device/dcd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ bool dcd_dcache_clean_invalidate(const void* addr, uint32_t data_size);
107107
// Controller API
108108
//--------------------------------------------------------------------+
109109

110+
// optional dcd configuration, called by tud_configure()
111+
bool dcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
112+
110113
// Initialize controller to device mode
111114
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
112115

src/device/usbd.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t
424424
return false;
425425
}
426426

427+
TU_ATTR_WEAK bool dcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
428+
(void) rhport; (void) cfg_id; (void) cfg_param;
429+
return false;
430+
}
431+
427432
//--------------------------------------------------------------------+
428433
// Debug
429434
//--------------------------------------------------------------------+
@@ -493,13 +498,14 @@ void tud_sof_cb_enable(bool en) {
493498
usbd_sof_enable(_usbd_rhport, SOF_CONSUMER_USER, en);
494499
}
495500

496-
//--------------------------------------------------------------------+
497-
// USBD Task
498-
//--------------------------------------------------------------------+
499501
bool tud_inited(void) {
500502
return _usbd_rhport != RHPORT_INVALID;
501503
}
502504

505+
bool tud_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
506+
return dcd_configure(rhport, cfg_id, cfg_param);
507+
}
508+
503509
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
504510
if (tud_inited()) {
505511
return true; // skip if already initialized
@@ -623,6 +629,9 @@ bool tud_task_event_ready(void) {
623629
return !osal_queue_empty(_usbd_q);
624630
}
625631

632+
//--------------------------------------------------------------------+
633+
// USBD Task
634+
//--------------------------------------------------------------------+
626635
/* USB Device Driver task
627636
* This top level thread manages all device controller event and delegates events to class-specific drivers.
628637
* This should be called periodically within the mainloop or rtos thread.

src/device/usbd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ extern "C" {
3737
// Application API
3838
//--------------------------------------------------------------------+
3939

40+
// Configure device stack behavior with dynamic or port-specific parameters.
41+
// Should be called before tud_init()
42+
// - cfg_id : configure ID (TBD)
43+
// - cfg_param: configure data, structure depends on the ID
44+
bool tud_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
45+
4046
// New API to replace tud_init() to init device stack on specific roothub port
4147
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
4248

0 commit comments

Comments
 (0)