summaryrefslogtreecommitdiff
path: root/tools/metrics.py
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2024-05-24 15:57:01 +1000
committerDamien George <damien@micropython.org>2024-06-03 16:00:52 +1000
commita84c7a0ed931667cda44a8e27888f066e085d5eb (patch)
treecf36cb12f5118e926154b7872b2dd17c7c6d9350 /tools/metrics.py
parent93394da69c46324b53465abaee05919d543a754a (diff)
rp2/modmachine: Selectively leave the USB clocks enabled in lightsleep.
Without this change going to lightsleep stops the USB peripheral clock, and can lead to either the device going into a weird state or the host deciding to issue a bus reset. This change only keeps the USB peripheral clocks enabled if the USB device is currently active and a host has configured the device. This means the USB device continues to respond to host transfers and (presumably) will even complete pending endpoint transfers. All other requests are NAKed while still asleep, but the interaction with the host seems to resume correctly on wake Otherwise, if USB is not active or configured by a host, USB clocks are disabled, the same as before. With the change, one can issue a `machine.lightsleep(...)` with USB CDC connected and the USB CDC remains connected during the sleep and resumes when the lightsleep finishes. Tested on a RPi Pico, the power consumption is: - During normal idle at the REPL, about 15.3mA. - During lightsleep, prior to this change, about 1.35mA. - During lightsleep, with this change and USB CDC connected, about 3.7mA. If power consumption should be as low as possible when USB is connected, one can use `machine.USBDevice` to disable the USB before entering lightsleep. As discussed at https://github.com/orgs/micropython/discussions/14401 This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'tools/metrics.py')
0 files changed, 0 insertions, 0 deletions