Omit serial number if not defined (#11104)
This commit is contained in:
parent
e3888281f4
commit
15faffacf4
2 changed files with 16 additions and 8 deletions
|
@ -374,7 +374,11 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
|
||||||
.ReleaseNumber = DEVICE_VER,
|
.ReleaseNumber = DEVICE_VER,
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
|
#if defined(SERIAL_NUMBER)
|
||||||
.SerialNumStrIndex = 0x03,
|
.SerialNumStrIndex = 0x03,
|
||||||
|
#else
|
||||||
|
.SerialNumStrIndex = 0x00,
|
||||||
|
#endif
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -950,10 +954,7 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
|
||||||
.UnicodeString = LSTR(PRODUCT)
|
.UnicodeString = LSTR(PRODUCT)
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef SERIAL_NUMBER
|
#if defined(SERIAL_NUMBER)
|
||||||
# define SERIAL_NUMBER 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const USB_Descriptor_String_t PROGMEM SerialNumberString = {
|
const USB_Descriptor_String_t PROGMEM SerialNumberString = {
|
||||||
.Header = {
|
.Header = {
|
||||||
.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator
|
.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator
|
||||||
|
@ -961,6 +962,7 @@ const USB_Descriptor_String_t PROGMEM SerialNumberString = {
|
||||||
},
|
},
|
||||||
.UnicodeString = LSTR(SERIAL_NUMBER)
|
.UnicodeString = LSTR(SERIAL_NUMBER)
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -1005,11 +1007,13 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
#if defined(SERIAL_NUMBER)
|
||||||
case 0x03:
|
case 0x03:
|
||||||
Address = &SerialNumberString;
|
Address = &SerialNumberString;
|
||||||
Size = pgm_read_byte(&SerialNumberString.Header.Size);
|
Size = pgm_read_byte(&SerialNumberString.Header.Size);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -531,10 +531,6 @@ const PROGMEM uchar console_hid_report[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SERIAL_NUMBER
|
|
||||||
# define SERIAL_NUMBER 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef USB_MAX_POWER_CONSUMPTION
|
#ifndef USB_MAX_POWER_CONSUMPTION
|
||||||
# define USB_MAX_POWER_CONSUMPTION 500
|
# define USB_MAX_POWER_CONSUMPTION 500
|
||||||
#endif
|
#endif
|
||||||
|
@ -569,6 +565,7 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = {
|
||||||
.bString = LSTR(PRODUCT)
|
.bString = LSTR(PRODUCT)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(SERIAL_NUMBER)
|
||||||
const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
|
const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
|
||||||
.header = {
|
.header = {
|
||||||
.bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1),
|
.bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1),
|
||||||
|
@ -576,6 +573,7 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
|
||||||
},
|
},
|
||||||
.bString = LSTR(SERIAL_NUMBER)
|
.bString = LSTR(SERIAL_NUMBER)
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Device descriptor
|
* Device descriptor
|
||||||
|
@ -595,7 +593,11 @@ const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = {
|
||||||
.bcdDevice = DEVICE_VER,
|
.bcdDevice = DEVICE_VER,
|
||||||
.iManufacturer = 0x01,
|
.iManufacturer = 0x01,
|
||||||
.iProduct = 0x02,
|
.iProduct = 0x02,
|
||||||
|
#if defined(SERIAL_NUMBER)
|
||||||
.iSerialNumber = 0x03,
|
.iSerialNumber = 0x03,
|
||||||
|
#else
|
||||||
|
.iSerialNumber = 0x00,
|
||||||
|
#endif
|
||||||
.bNumConfigurations = 1
|
.bNumConfigurations = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -821,10 +823,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
|
||||||
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct;
|
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct;
|
||||||
len = usbStringDescriptorProduct.header.bLength;
|
len = usbStringDescriptorProduct.header.bLength;
|
||||||
break;
|
break;
|
||||||
|
#if defined(SERIAL_NUMBER)
|
||||||
case 3: // iSerialNumber
|
case 3: // iSerialNumber
|
||||||
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial;
|
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial;
|
||||||
len = usbStringDescriptorSerial.header.bLength;
|
len = usbStringDescriptorSerial.header.bLength;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case USBDESCR_HID:
|
case USBDESCR_HID:
|
||||||
|
|
Loading…
Reference in a new issue