Skip to content
Snippets Groups Projects
Commit 4caf5b23 authored by Damien George's avatar Damien George
Browse files

stm32/usbdev: Add USB config option for max power drawn by the board.

The new compile-time option is MICROPY_HW_USB_MAX_POWER_MA.  Set this in
the board configuration file to the maximum current in mA that the board
will draw over USB.  The default is 500mA.
parent 7d8db42d
Branches
No related tags found
No related merge requests found
...@@ -103,6 +103,13 @@ ...@@ -103,6 +103,13 @@
#define CONFIG_DESC_ATTRIBUTES (0x80) // bus powered #define CONFIG_DESC_ATTRIBUTES (0x80) // bus powered
#endif #endif
// Value used in the configuration descriptor for the bMaxPower entry
#if defined(MICROPY_HW_USB_MAX_POWER_MA)
#define CONFIG_DESC_MAXPOWER (MICROPY_HW_USB_MAX_POWER_MA / 2) // in units of 2mA
#else
#define CONFIG_DESC_MAXPOWER (0xfa) // 500mA in units of 2mA
#endif
#if USBD_SUPPORT_HS_MODE #if USBD_SUPPORT_HS_MODE
// USB Standard Device Descriptor // USB Standard Device Descriptor
__ALIGN_BEGIN static uint8_t USBD_CDC_MSC_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = { __ALIGN_BEGIN static uint8_t USBD_CDC_MSC_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = {
...@@ -131,7 +138,7 @@ static const uint8_t msc_template_config_desc[MSC_TEMPLATE_CONFIG_DESC_SIZE] = { ...@@ -131,7 +138,7 @@ static const uint8_t msc_template_config_desc[MSC_TEMPLATE_CONFIG_DESC_SIZE] = {
0x01, // bConfigurationValue: Configuration value 0x01, // bConfigurationValue: Configuration value
0x00, // iConfiguration: Index of string descriptor describing the configuration 0x00, // iConfiguration: Index of string descriptor describing the configuration
CONFIG_DESC_ATTRIBUTES, // bmAttributes CONFIG_DESC_ATTRIBUTES, // bmAttributes
0xfa, // bMaxPower: in units of 2mA CONFIG_DESC_MAXPOWER, // bMaxPower
//========================================================================== //==========================================================================
// MSC only has 1 interface so doesn't need an IAD // MSC only has 1 interface so doesn't need an IAD
...@@ -179,7 +186,7 @@ static const uint8_t cdc_msc_template_config_desc[CDC_MSC_TEMPLATE_CONFIG_DESC_S ...@@ -179,7 +186,7 @@ static const uint8_t cdc_msc_template_config_desc[CDC_MSC_TEMPLATE_CONFIG_DESC_S
0x01, // bConfigurationValue: Configuration value 0x01, // bConfigurationValue: Configuration value
0x00, // iConfiguration: Index of string descriptor describing the configuration 0x00, // iConfiguration: Index of string descriptor describing the configuration
CONFIG_DESC_ATTRIBUTES, // bmAttributes CONFIG_DESC_ATTRIBUTES, // bmAttributes
0xfa, // bMaxPower: in units of 2mA CONFIG_DESC_MAXPOWER, // bMaxPower
//========================================================================== //==========================================================================
// MSC only has 1 interface so doesn't need an IAD // MSC only has 1 interface so doesn't need an IAD
...@@ -316,7 +323,7 @@ static const uint8_t cdc_hid_template_config_desc[CDC_HID_TEMPLATE_CONFIG_DESC_S ...@@ -316,7 +323,7 @@ static const uint8_t cdc_hid_template_config_desc[CDC_HID_TEMPLATE_CONFIG_DESC_S
0x01, // bConfigurationValue: Configuration value 0x01, // bConfigurationValue: Configuration value
0x00, // iConfiguration: Index of string descriptor describing the configuration 0x00, // iConfiguration: Index of string descriptor describing the configuration
CONFIG_DESC_ATTRIBUTES, // bmAttributes CONFIG_DESC_ATTRIBUTES, // bmAttributes
0xfa, // bMaxPower: in units of 2mA CONFIG_DESC_MAXPOWER, // bMaxPower
//========================================================================== //==========================================================================
// HID only has 1 interface so doesn't need an IAD // HID only has 1 interface so doesn't need an IAD
...@@ -463,7 +470,7 @@ static const uint8_t cdc_template_config_desc[CDC_TEMPLATE_CONFIG_DESC_SIZE] = { ...@@ -463,7 +470,7 @@ static const uint8_t cdc_template_config_desc[CDC_TEMPLATE_CONFIG_DESC_SIZE] = {
0x01, // bConfigurationValue: Configuration value 0x01, // bConfigurationValue: Configuration value
0x00, // iConfiguration: Index of string descriptor describing the configuration 0x00, // iConfiguration: Index of string descriptor describing the configuration
CONFIG_DESC_ATTRIBUTES, // bmAttributes CONFIG_DESC_ATTRIBUTES, // bmAttributes
0xfa, // bMaxPower: in units of 2mA CONFIG_DESC_MAXPOWER, // bMaxPower
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Interface Descriptor // Interface Descriptor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment