Skip to content

Commit b369396

Browse files
committed
tinyusb: Allow configuration of power setting
In some cases the power value in the device descriptor needs to be set to a lower value, commonly 20 mA, to not get rejected by iOS devices. The classic USB stack reads USB_CONFIG_POWER, this adds the same logic to tinyusb.
1 parent 54be8f0 commit b369396

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#define USB_PRODUCT "Unknown"
3535
#endif
3636

37+
#ifndef USB_CONFIG_POWER
38+
#define USB_CONFIG_POWER 100
39+
#endif
40+
3741
extern uint8_t load_serial_number(uint16_t* serial_str);
3842

3943
Adafruit_USBD_Device USBDevice;
@@ -76,7 +80,7 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
7680
.bConfigurationValue = 1,
7781
.iConfiguration = 0x00,
7882
.bmAttributes = TU_BIT(7) | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP,
79-
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
83+
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(USB_CONFIG_POWER)
8084
};
8185

8286
memcpy(_desc_cfg, &dev_cfg, sizeof(tusb_desc_configuration_t));

0 commit comments

Comments
 (0)