Skip to content

Commit e25e1a2

Browse files
committed
Add information on power saving options for USB components
1 parent d888a45 commit e25e1a2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/api/usb/usb_component.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,9 @@ int main(void)
8787
The `connect()` and `disconnect()` functions control the state of the physical USB line to the host. When a device is connected, it is visible to the host PC to which it is attached. Once connected, the host PC must finish setup.
8888

8989
USB components provide at least one service. When a service is available for use, it is `ready`. For example, the USBSerial component enters the `ready` state after a serial port has been opened on the host PC. To determine whether a USB component's service is ready, you can use the `ready()` function. It returns `true` if the USB component is ready for use and `false` otherwise. Some components provide multiple services, such as USBAudio, which can send or receive data and has two separate ready functions - `read_ready()` and `write_ready()`. Furthermore, for each `ready()` function, there is also a corresponding `wait_ready()` function, which you can use to block until the USB component's service is available.
90+
91+
## USB component and power saving
92+
93+
Instantiated USB components prevent devices from going to deep sleep due to USBPhy holding a deep sleep lock. It is possible to temporarily disable USB using `USBDevice::deinit()` to permit deep sleep. However, it is up to the user to make sure all the data transfers have concluded (for example when USB power is lost) to avoid any data corruption. The USB host controls the enumeration process so it chooses when and how the device will be restored. Even if the device state is returned to what it was before the disconnect, the host PC software may not be where it left off - for example a serial port may need to be re-opended by the user.
94+
95+
`USBDevice::connect()` can be used to resume USB components operation when USB power is detected after it was previously suspended via `USBDevice::deinit()`.

0 commit comments

Comments
 (0)