diff --git a/micropython/usb/usb-device/usb/device/impl.py b/micropython/usb/usb-device/usb/device/impl.py index 90606082..b8b1786d 100644 --- a/micropython/usb/usb-device/usb/device/impl.py +++ b/micropython/usb/usb-device/usb/device/impl.py @@ -99,7 +99,7 @@ class _Device: device_subclass=None, device_protocol=None, config_str=None, - max_power_ma=50, + max_power_ma=None, ): # Configure the USB device with a set of interfaces, and optionally reconfiguring the # device and configuration descriptor fields @@ -198,6 +198,13 @@ class _Device: iConfiguration = len(strs) strs.append(configuration_str) + if max_power_ma is None: + # Default to whatever value the builtin driver reports + max_power_ma = builtin.desc_cfg[8] + else: + # Otherwise, convert from mA to the units used in the descriptor + max_power_ma //= 2 + desc.pack_into( "