stm32f4: usb midi: use unique serial numbers
The unique serial number from the device unique signature block was never used in any examples. Add it to the these two usb midi examples, to have a user for this api available for reference.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <libopencm3/usb/audio.h>
|
||||
#include <libopencm3/usb/midi.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
#include <libopencm3/stm32/desig.h>
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/stm32/gpio.h>
|
||||
|
||||
@@ -47,7 +48,7 @@ static const struct usb_device_descriptor dev = {
|
||||
.bcdDevice = 0x0100,
|
||||
.iManufacturer = 1, /* index to string desc */
|
||||
.iProduct = 2, /* index to string desc */
|
||||
.iSerialNumber = 0,
|
||||
.iSerialNumber = 3, /* index to string desc */
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
@@ -268,9 +269,12 @@ static const struct usb_config_descriptor config = {
|
||||
.interface = ifaces,
|
||||
};
|
||||
|
||||
static char usb_serial_number[25]; /* 12 bytes of desig and a \0 */
|
||||
|
||||
static const char *usb_strings[] = {
|
||||
"libopencm3.org",
|
||||
"MIDI demo",
|
||||
usb_serial_number
|
||||
};
|
||||
|
||||
/* Buffer to be used for control requests. */
|
||||
@@ -373,11 +377,13 @@ int main(void)
|
||||
GPIO13 | GPIO14 | GPIO15);
|
||||
gpio_set_af(GPIOB, GPIO_AF12, GPIO13 | GPIO14 | GPIO15);
|
||||
|
||||
desig_get_unique_id_as_string(usb_serial_number, sizeof(usb_serial_number));
|
||||
|
||||
/* Button pin */
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO0);
|
||||
|
||||
usbd_dev = usbd_init(&otghs_usb_driver, &dev, &config,
|
||||
usb_strings, 2,
|
||||
usb_strings, 3,
|
||||
usbd_control_buffer, sizeof(usbd_control_buffer));
|
||||
|
||||
usbd_register_set_config_callback(usbd_dev, usbmidi_set_config);
|
||||
|
||||
Reference in New Issue
Block a user