1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 14:03:55 +01:00

usb: Add configuration options for USB peripheral serial

This adds compile-time options to configure the serial of an USB
peripheral. The serial be autogenerated with a configured number of
bytes. It is also possible to configure a fixed serial string for a
device and disable the autogeneration of the serial.
This commit is contained in:
Koen Zandberg 2020-12-16 17:22:30 +01:00
parent 4661948bd1
commit 185bf28c21
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
2 changed files with 52 additions and 0 deletions

View File

@ -96,6 +96,32 @@ extern "C" {
#define CONFIG_USB_CONFIGURATION_STR "USB config"
#endif
/**
* @brief USB peripheral serial string
*
* Compile-time value to override the serial string with. An LUID-based hex
* string is generated when this value is not used.
*
* This string does not have to be a number, but it must be unique between
* devices with identical VID:PID combination.
*/
#ifdef DOXYGEN
#define CONFIG_USB_SERIAL_STR "RIOT-12345"
#endif
/**
* @brief USB peripheral serial string length
*
* Maximum value is 63. Sensible values are between 8 to 32 depending on the
* number of expected devices.
*
* The length here is in bytes. The generated hex string is twice as many chars
* in length due to conversion from bytes to hex chars.
*/
#if !defined(CONFIG_USB_SERIAL_STR) && !defined(CONFIG_USB_SERIAL_BYTE_LENGTH)
#define CONFIG_USB_SERIAL_BYTE_LENGTH 8
#endif
/**
* @brief USB peripheral device version
*

View File

@ -81,6 +81,32 @@ config USB_DEFAULT_LANGID
help
The default value is EN-US (0x0409).
config USB_CUSTOM_SERIAL_STR
bool "Configure a custom USB serial string"
config USB_SERIAL_STR
string "Serial string"
depends on USB_CUSTOM_SERIAL_STR
help
USB peripheral serial string
Compile-time value to override the serial string with. An LUID-based hex
string is generated when this value is not used.
This string does not have to be a number, but it must be unique between
devices with identical VID:PID combination.
config USB_SERIAL_BYTE_LENGTH
int "USB peripheral serial string length"
depends on !USB_CUSTOM_SERIAL_STR
range 0 63
default 8
help
The length here is in bytes. The generated hex string is twice as many chars
in length due to conversion from bytes to hex chars.
comment "WARNING: The serial string is empty!"
depends on USB_SERIAL_STR = "" && USB_CUSTOM_SERIAL_STR
rsource "usbus/Kconfig"
endif # KCONFIG_USB