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

Remove unnecessary xSemaphoreTake() of USBHID semaphore #7205

Merged
merged 1 commit into from
Sep 17, 2022
Merged
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
7 changes: 6 additions & 1 deletion libraries/USB/src/USBHID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,16 @@ bool USBHID::SendReport(uint8_t id, const void* data, size_t len, uint32_t timeo
if(!res){
log_e("not ready");
} else {
// The semaphore may be given if the last SendReport() timed out waiting for the report to
// be sent. Or, tud_hid_report_complete_cb() may be called an extra time, causing the
// semaphore to be given. In these cases, take the semaphore to clear its state so that
// we can wait for it to be given after calling tud_hid_n_report().
xSemaphoreTake(tinyusb_hid_device_input_sem, 0);

res = tud_hid_n_report(0, id, data, len);
if(!res){
log_e("report %u failed", id);
} else {
xSemaphoreTake(tinyusb_hid_device_input_sem, 0);
if(xSemaphoreTake(tinyusb_hid_device_input_sem, timeout_ms / portTICK_PERIOD_MS) != pdTRUE){
log_e("report %u wait failed", id);
res = false;
Expand Down