diff options
author | Damien George <damien@micropython.org> | 2023-04-04 11:57:25 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-04-04 11:57:25 +1000 |
commit | 783ddfc264c8c36253a4279ef501f02f8cac1200 (patch) | |
tree | 9e482f440ff6aa12883f7cca6e559fffe48ec4f1 /shared/tinyusb | |
parent | 0a3600a9ade773e54cbd70e93a671ec089c3b0fe (diff) |
shared/tinyusb: Allow max USB descriptor string to be configured.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'shared/tinyusb')
-rw-r--r-- | shared/tinyusb/mp_usbd.h | 2 | ||||
-rw-r--r-- | shared/tinyusb/mp_usbd_descriptor.c | 6 | ||||
-rw-r--r-- | shared/tinyusb/tusb_config.h | 7 |
3 files changed, 8 insertions, 7 deletions
diff --git a/shared/tinyusb/mp_usbd.h b/shared/tinyusb/mp_usbd.h index a118bc34d..3a93b929c 100644 --- a/shared/tinyusb/mp_usbd.h +++ b/shared/tinyusb/mp_usbd.h @@ -33,7 +33,7 @@ void mp_usbd_task(void); // Function to be implemented in port code. -// Can write a string up to USBD_DESC_STR_MAX characters long, plus terminating byte. +// Can write a string up to MICROPY_HW_USB_DESC_STR_MAX characters long, plus terminating byte. extern void mp_usbd_port_get_serial_number(char *buf); #endif // MICROPY_INCLUDED_SHARED_TINYUSB_USBD_H diff --git a/shared/tinyusb/mp_usbd_descriptor.c b/shared/tinyusb/mp_usbd_descriptor.c index c6d205c92..8fab599b6 100644 --- a/shared/tinyusb/mp_usbd_descriptor.c +++ b/shared/tinyusb/mp_usbd_descriptor.c @@ -67,8 +67,8 @@ const uint8_t mp_usbd_desc_cfg_static[USBD_STATIC_DESC_LEN] = { }; const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) { - char serial_buf[USBD_DESC_STR_MAX + 1]; // Includes terminating NUL byte - static uint16_t desc_wstr[USBD_DESC_STR_MAX + 1]; // Includes prefix uint16_t + char serial_buf[MICROPY_HW_USB_DESC_STR_MAX + 1]; // Includes terminating NUL byte + static uint16_t desc_wstr[MICROPY_HW_USB_DESC_STR_MAX + 1]; // Includes prefix uint16_t const char *desc_str; uint16_t desc_len; @@ -109,7 +109,7 @@ const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) { // Convert from narrow string to wide string desc_len = 2; - for (int i = 0; i < USBD_DESC_STR_MAX && desc_str[i] != 0; i++) { + for (int i = 0; i < MICROPY_HW_USB_DESC_STR_MAX && desc_str[i] != 0; i++) { desc_wstr[1 + i] = desc_str[i]; desc_len += 2; } diff --git a/shared/tinyusb/tusb_config.h b/shared/tinyusb/tusb_config.h index 23dbd14a5..a6410a1c9 100644 --- a/shared/tinyusb/tusb_config.h +++ b/shared/tinyusb/tusb_config.h @@ -27,8 +27,7 @@ #ifndef MICROPY_INCLUDED_SHARED_TINYUSB_TUSB_CONFIG_H #define MICROPY_INCLUDED_SHARED_TINYUSB_TUSB_CONFIG_H -#include <py/mpconfig.h> -#include "mpconfigport.h" +#include "py/mpconfig.h" #if MICROPY_HW_ENABLE_USBDEV @@ -90,7 +89,9 @@ #define USBD_MAX_POWER_MA (250) -#define USBD_DESC_STR_MAX (20) +#ifndef MICROPY_HW_USB_DESC_STR_MAX +#define MICROPY_HW_USB_DESC_STR_MAX (20) +#endif #if CFG_TUD_CDC #define USBD_ITF_CDC (0) // needs 2 interfaces |