X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fcommon%2Fvirtual_com.c;h=cc388c704778aa037805d3fb01ffd56428a7f6e9;hb=4e82712727981c944f56d4ada62dc54ad8542d94;hp=804c91a95de332de0963865746ef18f236d79f19;hpb=e0f8b131e63b9449a95da4e821812f0db992a3fc;p=gps-watch.git diff --git a/src/common/virtual_com.c b/src/common/virtual_com.c index 804c91a..cc388c7 100644 --- a/src/common/virtual_com.c +++ b/src/common/virtual_com.c @@ -59,6 +59,7 @@ /* Provided by users. */ extern void USB_DeviceClockInit(void); extern void USB_DeviceIsrEnable(void); +extern void USB_DeviceIsrDisable(void); /******************************************************************************* * Definitions ******************************************************************************/ @@ -102,9 +103,8 @@ static usb_cdc_acm_info_t s_usbCdcAcmInfo = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, /* Data buffer for receiving and sending*/ static uint8_t s_currRecvBuf[DATA_BUFF_SIZE]; -volatile static uint32_t s_recvSize = 0; -volatile static uint32_t s_sendSize = 0; -volatile static uint8_t s_sendComplete = 0; +static volatile uint32_t s_recvSize = 0; +static volatile uint8_t s_sendComplete = 0; static uint32_t s_usbBulkMaxPacketSize = FS_CDC_VCOM_BULK_OUT_PACKET_SIZE; /******************************************************************************* * Prototypes @@ -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; @@ -656,25 +660,19 @@ usb_device_handle USB_VcomInit(void) } /* See virtual_com.h for documentation of this function. */ -void USB_VcomDeinit(usb_device_handle deviceHandle) +void +USB_VcomDeinit (void) { - USB_DeviceStop(deviceHandle); - USB_DeviceDeinit(deviceHandle); + if (s_cdcVcom.deviceHandle == NULL) + return; + + USB_DeviceStop (s_cdcVcom.deviceHandle); + USB_DeviceDeinit (s_cdcVcom.deviceHandle); s_cdcVcom.deviceHandle = NULL; -#if defined(USB_DEVICE_CONFIG_EHCI) && (USB_DEVICE_CONFIG_EHCI > 0) - USB_EhciPhyDeinit(CONTROLLER_ID); -#endif -#if defined(USB_DEVICE_CONFIG_KHCI) && (USB_DEVICE_CONFIG_KHCI > 0) - CLOCK_DisableUsbfs0Clock(); -#endif -#if defined(USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U) - /* enable USB IP clock, user code. */ - CLOCK_DisableClock(kCLOCK_Usbd0); -#endif /* USB_DEVICE_CONFIG_LPCIP3511FS */ - -#if defined(USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U) -/* enable USB IP clock,user code. */ -#endif /* USB_DEVICE_CONFIG_LPCIP3511HS */ + + USB_DeviceIsrDisable(); + + /* XXX: We are not stopping the USBOTG clock yet. */ } void