Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tuh_enumeration_cb to intercept enumeration xfers #2938

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions src/host/usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ TU_ATTR_WEAK void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_is
(void) in_isr;
}

TU_ATTR_WEAK bool tuh_enumeration_cb(tuh_xfer_t* xfer) {
(void) xfer;
return false;
}

TU_ATTR_WEAK bool hcd_dcache_clean(const void* addr, uint32_t data_size) {
(void) addr; (void) data_size;
return false;
Expand Down Expand Up @@ -1331,6 +1336,11 @@ static void enum_full_complete(void);

// process device enumeration
static void process_enumeration(tuh_xfer_t* xfer) {
// Call callback and skip if returns true
if (tuh_enumeration_cb(xfer)) {
return;
}

// Retry a few times with transfers in enumeration since device can be unstable when starting up
enum {
ATTEMPT_COUNT_MAX = 3,
Expand Down
3 changes: 3 additions & 0 deletions src/host/usbh.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr);
// Invoked when there is a new usb event, which need to be processed by tuh_task()/tuh_task_ext()
void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr);

// Invoked when an usb enumeration transfer is completed
bool tuh_enumeration_cb(tuh_xfer_t* xfer);

//--------------------------------------------------------------------+
// APPLICATION API
//--------------------------------------------------------------------+
Expand Down
Loading