From ae08cb7946610699238315e78bb739380001ec23 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sun, 7 Jul 2019 12:15:14 +0200 Subject: [PATCH] common: Make USB_VcomInit() take VID/PID and pass them on. --- src/common/usb_serial.rs | 4 ++-- src/common/virtual_com.c | 6 +++++- src/common/virtual_com.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/usb_serial.rs b/src/common/usb_serial.rs index 6f28e52..6a7cd17 100644 --- a/src/common/usb_serial.rs +++ b/src/common/usb_serial.rs @@ -25,11 +25,11 @@ use nvic; use clock; extern { - fn USB_VcomInit(); + fn USB_VcomInit(vid: u16, pid: u16); } pub unsafe fn init(vid: u16, pid: u16) { - USB_VcomInit(); + USB_VcomInit(vid, pid); } #[no_mangle] diff --git a/src/common/virtual_com.c b/src/common/virtual_com.c index 804c91a..3707678 100644 --- a/src/common/virtual_com.c +++ b/src/common/virtual_com.c @@ -624,7 +624,8 @@ flush_tx_buffer (void *user_data, void *vbuf, size_t bufsiz, size_t count) } /* See virtual_com.h for documentation of this function. */ -usb_device_handle USB_VcomInit(void) +usb_device_handle +USB_VcomInit (uint16_t vid, uint16_t pid) { usb_device_handle deviceHandle = NULL; @@ -638,6 +639,9 @@ usb_device_handle USB_VcomInit(void) s_cdcVcom.attach = 0; s_cdcVcom.deviceHandle = NULL; + USB_DeviceSetVendorId(vid); + USB_DeviceSetProductId(pid); + if (kStatus_USB_Success != USB_DeviceInit(CONTROLLER_ID, USB_DeviceCallback, &s_cdcVcom.deviceHandle)) { deviceHandle = NULL; diff --git a/src/common/virtual_com.h b/src/common/virtual_com.h index 895b4c3..c8e5f02 100644 --- a/src/common/virtual_com.h +++ b/src/common/virtual_com.h @@ -125,7 +125,7 @@ typedef struct _usb_cdc_acm_info * * @return pointer to USB device handle. */ -usb_device_handle USB_VcomInit(void); +usb_device_handle USB_VcomInit (uint16_t vid, uint16_t pid); /*! * @brief Application initialization function. -- 2.30.2