Skip to content

Commit 59d4393

Browse files
authored
Merge pull request #529 from adafruit/add-set-maxpower
add setConfigurationMaxPower() and setConfigurationAttribute
2 parents cdc07c1 + 60fb663 commit 59d4393

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ body:
4646
- type: input
4747
attributes:
4848
label: TinyUSB Library version
49-
placeholder: "Release version or github latest"
49+
placeholder: "Release version or commit SHA"
5050
validations:
5151
required: true
5252

src/arduino/Adafruit_USBD_Device.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ class Adafruit_USBD_Device {
8080
// Clear/Reset configuration descriptor
8181
void clearConfiguration(void);
8282

83+
// Set configuration attribute
84+
void setConfigurationAttribute(uint8_t attribute) {
85+
_desc_cfg[offsetof(tusb_desc_configuration_t, bmAttributes)] = attribute;
86+
}
87+
88+
// Set max power consumption in mA (absolute max is 510ma)
89+
bool setConfigurationMaxPower(uint16_t power_ma) {
90+
if (power_ma > 255 * 2u) {
91+
return false;
92+
}
93+
_desc_cfg[offsetof(tusb_desc_configuration_t, bMaxPower)] =
94+
(uint8_t)(power_ma / 2);
95+
return true;
96+
}
97+
8398
// Provide user buffer for configuration descriptor, if total length > 256
8499
void setConfigurationBuffer(uint8_t *buf, uint32_t buflen);
85100

0 commit comments

Comments
 (0)