common: Add USB_DeviceSetVendorId() and USB_DeviceSetProductId().
authorTilman Sauerbeck <tilman@code-monkey.de>
Sun, 7 Jul 2019 10:08:35 +0000 (12:08 +0200)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sun, 5 Jan 2020 19:38:11 +0000 (20:38 +0100)
These configure the VID/PID pair to use.

src/common/usb_device_descriptor.c
src/common/usb_device_descriptor.h

index 8271e58a8ba781cb22fa7bfa9abe4170c4fe5181..ac95a13c68ade3f19d1d73c3a9827614211d8dd6 100644 (file)
@@ -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;
+}
index 5b8c8084a261de1b6f66ac75f659d9be7b46fafe..5bfbef80e2376ad2b369d29f45bca85322e45c7a 100644 (file)
@@ -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_ */