squeeze the usb identification code
This commit is contained in:
parent
c567b43441
commit
daf415d9c7
@ -122,7 +122,9 @@ void usb_set_defaults(void) {
|
||||
#endif
|
||||
};
|
||||
|
||||
#if CIRCUITPY_USB_IDENTIFICATION
|
||||
supervisor_allocation *usb_identification_allocation;
|
||||
#endif
|
||||
|
||||
// Some dynamic USB data must be saved after boot.py. How much is needed?
|
||||
size_t usb_boot_py_data_size(void) {
|
||||
@ -137,16 +139,21 @@ size_t usb_boot_py_data_size(void) {
|
||||
|
||||
// Fill in the data to save.
|
||||
void usb_get_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size) {
|
||||
#if CIRCUITPY_USB_IDENTIFICATION
|
||||
if (usb_identification_allocation) {
|
||||
memcpy(temp_storage, usb_identification_allocation->ptr, sizeof(usb_identification_t));
|
||||
free_memory(usb_identification_allocation);
|
||||
#else
|
||||
if (false) {
|
||||
// Nothing
|
||||
#endif
|
||||
} else {
|
||||
usb_identification_t defaults = {
|
||||
.vid = USB_VID,
|
||||
.pid = USB_PID,
|
||||
.manufacturer_name = USB_MANUFACTURER,
|
||||
.product_name = USB_PRODUCT,
|
||||
};
|
||||
usb_identification_t defaults;
|
||||
// This compiles to less code than using a struct initializer.
|
||||
defaults.vid = USB_VID;
|
||||
defaults.pid = USB_PID;
|
||||
strcpy(defaults.manufacturer_name, USB_MANUFACTURER);
|
||||
strcpy(defaults.product_name, USB_PRODUCT);
|
||||
memcpy(temp_storage, &defaults, sizeof(defaults));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user