Skip to content

Commit 9aa73fd

Browse files
committed
shared-module/usb_hid: allow HID to wake sleeping host computer
1 parent a28f853 commit 9aa73fd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

shared-module/usb_hid/Device.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,16 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *
229229
RUN_BACKGROUND_TASKS;
230230
}
231231

232-
if (!tud_hid_ready()) {
233-
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("USB busy"));
234-
}
232+
if (!tud_suspended()) {
233+
if (!tud_hid_ready()) {
234+
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("USB busy"));
235+
}
235236

236-
if (!tud_hid_report(report_id, report, len)) {
237-
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("USB error"));
237+
if (!tud_hid_report(report_id, report, len)) {
238+
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("USB error"));
239+
}
240+
} else {
241+
tud_remote_wakeup();
238242
}
239243
}
240244

supervisor/shared/usb/usb_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static const uint8_t configuration_descriptor_template[] = {
105105
#define CONFIG_NUM_INTERFACES_INDEX (4)
106106
0x01, // 5 bConfigurationValue
107107
0x00, // 6 iConfiguration (String Index)
108-
0x80, // 7 bmAttributes
108+
0x80 | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, // 7 bmAttributes
109109
0x32, // 8 bMaxPower 100mA
110110
};
111111

0 commit comments

Comments
 (0)