Skip to content

USBHID.cpp uses non safe xSemaphoreGive in ISR #11407

Closed
@ChrGri

Description

@ChrGri

Board

ESP32 S3

Device Description

ESP32 S3 dev kit

Hardware Configuration

None

Version

latest stable Release (if not listed below)

IDE Name

Arduino

Operating System

Win 11

Flash frequency

a lot

PSRAM enabled

yes

Upload speed

a lot too

Description

The USBHID.cpp code implements an tud_hid_report_complete_cb from which a non safe xSemaphoreGive is beeing called, see.

Since tud_hid_report_complete_cb is an ISR, its advisable to use xSemaphoreGiveFromISR instead, e.g.

void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, tud_hid_report_complete_cb_len_t len) {
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    if (tinyusb_hid_device_input_sem) {
        xSemaphoreGiveFromISR(tinyusb_hid_device_input_sem, &xHigherPriorityTaskWoken);
        if (xHigherPriorityTaskWoken) {
            portYIELD_FROM_ISR();
        }
    }
}

BR
Chris

Sketch

See above

Debug Message

Sometimes I receive TUSB:error messages. Now trying to find possible reasons. This might be one.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions