We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d90e654 commit 163f8eaCopy full SHA for 163f8ea
1 file changed
micropython/usb/usb-device/usb/device/impl.py
@@ -198,12 +198,16 @@ def maybe_set(value, idx):
198
iConfiguration = len(strs)
199
strs.append(configuration_str)
200
201
- if max_power_ma is None:
202
- # Default to whatever value the builtin driver reports
203
- max_power_ma = builtin.desc_cfg[8]
204
- else:
205
- # Otherwise, convert from mA to the units used in the descriptor
+ if max_power_ma is not None:
+ # Convert from mA to the units used in the descriptor
206
max_power_ma //= 2
+ else:
+ try:
+ # Default to whatever value the builtin driver reports
207
+ max_power_ma = _usbd.BUILTIN_DEFAULT.desc_cfg[8]
208
+ except IndexError:
209
+ # If no built-in driver, default to 250mA
210
+ max_power_ma = 125
211
212
desc.pack_into(
213
"<BBHBBBBB",
0 commit comments