From: Tilman Sauerbeck Date: Sun, 7 Jul 2019 10:08:35 +0000 (+0200) Subject: common: Add USB_DeviceSetVendorId() and USB_DeviceSetProductId(). X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=d6527916c38428842248f558fa6716d8d6ba4871;p=gps-watch.git common: Add USB_DeviceSetVendorId() and USB_DeviceSetProductId(). These configure the VID/PID pair to use. --- diff --git a/src/common/usb_device_descriptor.c b/src/common/usb_device_descriptor.c index 8271e58..ac95a13 100644 --- a/src/common/usb_device_descriptor.c +++ b/src/common/usb_device_descriptor.c @@ -62,9 +62,9 @@ uint8_t g_UsbDeviceDescriptor[USB_DESCRIPTOR_LENGTH_DEVICE] = { /* Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid) */ USB_CONTROL_MAX_PACKET_SIZE, /* Vendor ID (assigned by the USB-IF) */ - 0xC9U, 0x1FU, + 0x00, 0x00, /* Product ID (assigned by the manufacturer) */ - 0x94, 0x00, + 0x00, 0x00, /* Device release number in binary-coded decimal */ USB_SHORT_GET_LOW(USB_DEVICE_DEMO_BCD_VERSION), USB_SHORT_GET_HIGH(USB_DEVICE_DEMO_BCD_VERSION), /* Index of string descriptor describing manufacturer */ @@ -480,3 +480,17 @@ usb_status_t USB_DeviceSetSpeed(usb_device_handle handle, uint8_t speed) } return kStatus_USB_Success; } + +void +USB_DeviceSetVendorId (uint16_t vid) +{ + g_UsbDeviceDescriptor[8] = (vid >> 0) & 0xff; + g_UsbDeviceDescriptor[9] = (vid >> 8) & 0xff; +} + +void +USB_DeviceSetProductId (uint16_t pid) +{ + g_UsbDeviceDescriptor[10] = (pid >> 0) & 0xff; + g_UsbDeviceDescriptor[11] = (pid >> 8) & 0xff; +} diff --git a/src/common/usb_device_descriptor.h b/src/common/usb_device_descriptor.h index 5b8c808..5bfbef8 100644 --- a/src/common/usb_device_descriptor.h +++ b/src/common/usb_device_descriptor.h @@ -200,4 +200,7 @@ extern usb_status_t USB_DeviceCallback(usb_device_handle handle, uint32_t event, */ extern usb_status_t USB_DeviceSetSpeed(usb_device_handle handle, uint8_t speed); +void USB_DeviceSetVendorId (uint16_t vid); +void USB_DeviceSetProductId (uint16_t vid); + #endif /* _USB_DEVICE_DESCRIPTOR_H_ */