Skip to content

Commit 8d29adf

Browse files
committed
USBDevice: add documentation on USB suspend/resume to enter deep sleep
It is possible to temporarily suspend USB and safely preserve its configuration. This is needed to allow a device to enter deep sleep as a USBDevice instance prevents deep sleep. USB operation can be suspended with `deinit` and restored with `connect`.
1 parent eeb033f commit 8d29adf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/internal/USBDevice.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ class USBDevice: public USBPhyEvents {
9797
* Power down this instance
9898
*
9999
* Disable interrupts and stop sending events.
100+
* This method can be used for temporary power-saving; This call can allow
101+
* USB to be temporarily disabled to permit power saving.
102+
* However, it is up to the user to make sure all the
103+
* transfers have concluded (for example when USB power is lost).
100104
*/
101105
void deinit();
102106

@@ -109,6 +113,8 @@ class USBDevice: public USBPhyEvents {
109113

110114
/**
111115
* Connect a device
116+
* This method can also be used to resume USB operation when USB power is
117+
* detected after it was suspended via USBDevice::deinit.
112118
*/
113119
void connect();
114120

@@ -256,6 +262,23 @@ class USBDevice: public USBPhyEvents {
256262
*/
257263
uint32_t write_finish(usb_ep_t endpoint);
258264

265+
/** Suspend USB operation
266+
*
267+
* Control the USB state. This is primarily intended
268+
* for temporary power-saving; This call can
269+
* allow pwm to be temporarily disabled to permit power saving without
270+
* losing device state.
271+
*/
272+
void suspend();
273+
274+
/** Resume USB operation
275+
*
276+
* Control the USB state. This is primarily intended
277+
* to resume USB operations after a previous USBDevice::suspend call;
278+
* This call restores the device state prior to suspension.
279+
*/
280+
void resume();
281+
259282
/*
260283
* Get device descriptor.
261284
*

0 commit comments

Comments
 (0)