2018-07-03 04:11 AM
I have used CubeMX to generate the USB CDC driver. I connect my board to a PC and the device manager recognize it as: 'STMicroelectronics Virtual COM Port (COM1)', And then the device is connected.
- STM32Cube V1.0 Version 4.23.0
- STM32_USB_Device_Library from STM32Cube V1.0
- VCP_V1.4_Setup.exe (ST's host side USB CDC driver for Windows 10)
- STM32F103VCxxDiscovery (STM32F103VCT6)
I am doing query and response commands in USB communcation polling with 200 milliseconds.and also having GSM(SIM800L) and Ehternet communication presence on that board.Now the Problem is USB communcation which are disconnected in very rare case.While I debugging with disconnection of USB it go for busy state so let me give a solution for communication disconnect on USB
(usbd_cdc_if.c)
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
{
uint8_t result = USBD_OK;
/* USER CODE BEGIN 7 */
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
/**************************************************************************/
if (hcdc->TxState != 0){
return USBD_BUSY;
} //--->(always return BUSY when communication disconnected)
/************************************************************************/
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
/* USER CODE END 7 */
return result;
}
I have never worked with USB drivers before and do not know where to start to be able to solve this problem.
#stm-mcu