From: Tilman Sauerbeck Date: Sun, 7 Jul 2019 10:15:14 +0000 (+0200) Subject: common: Make USB_VcomInit() take VID/PID and pass them on. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=ae08cb7946610699238315e78bb739380001ec23;p=gps-watch.git common: Make USB_VcomInit() take VID/PID and pass them on. --- 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.