File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
micropython/usb/usb-device/usb/device Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -198,12 +198,16 @@ def maybe_set(value, idx):
198198 iConfiguration = len (strs )
199199 strs .append (configuration_str )
200200
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
201+ if max_power_ma is not None :
202+ # Convert from mA to the units used in the descriptor
206203 max_power_ma //= 2
204+ else :
205+ try :
206+ # 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
207211
208212 desc .pack_into (
209213 "<BBHBBBBB" ,
You can’t perform that action at this time.
0 commit comments