Skip to content

Commit 57008a1

Browse files
felixdoerredpgeorge
authored andcommitted
extmod/machine_usb_device: Add USBDevice.remote_wakeup method.
This simply exposes the TinyUSB function. Signed-off-by: Felix Dörre <[email protected]>
1 parent bb6a466 commit 57008a1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/library/machine.USBDevice.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ Methods
215215
drivers. Placing a different string at any of these indexes overrides that
216216
string in the built-in driver.
217217

218+
.. method:: USBDevice.remote_wakeup(self)
219+
220+
Wake up host if we are in suspend mode and the REMOTE_WAKEUP feature
221+
is enabled by the host. This has to be enabled in the USB attributes,
222+
and on the host. Returns ``True`` if remote wakeup was enabled and
223+
active and the host was woken up.
224+
218225
.. method:: USBDevice.submit_xfer(self, ep, buffer /)
219226

220227
Submit a USB transfer on endpoint number ``ep``. ``buffer`` must be

extmod/machine_usb_device.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ static mp_obj_t usb_device_active(size_t n_args, const mp_obj_t *args) {
157157
}
158158
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(usb_device_active_obj, 1, 2, usb_device_active);
159159

160+
static mp_obj_t usb_remote_wakeup(mp_obj_t self) {
161+
return mp_obj_new_bool(tud_remote_wakeup());
162+
}
163+
static MP_DEFINE_CONST_FUN_OBJ_1(usb_remote_wakeup_obj, usb_remote_wakeup);
164+
160165
static mp_obj_t usb_device_stall(size_t n_args, const mp_obj_t *args) {
161166
mp_obj_usb_device_t *self = (mp_obj_usb_device_t *)MP_OBJ_TO_PTR(args[0]);
162167
int epnum = mp_obj_get_int(args[1]);
@@ -272,6 +277,7 @@ static const mp_rom_map_elem_t usb_device_locals_dict_table[] = {
272277
{ MP_ROM_QSTR(MP_QSTR_submit_xfer), MP_ROM_PTR(&usb_device_submit_xfer_obj) },
273278
{ MP_ROM_QSTR(MP_QSTR_active), MP_ROM_PTR(&usb_device_active_obj) },
274279
{ MP_ROM_QSTR(MP_QSTR_stall), MP_ROM_PTR(&usb_device_stall_obj) },
280+
{ MP_ROM_QSTR(MP_QSTR_remote_wakeup), MP_ROM_PTR(&usb_remote_wakeup_obj) },
275281

276282
// Built-in driver constants
277283
{ MP_ROM_QSTR(MP_QSTR_BUILTIN_NONE), MP_ROM_PTR(&mp_type_usb_device_builtin_none) },

0 commit comments

Comments
 (0)