AnsweredAssumed Answered

when I am sending data using USB, when the callback in my firmware gives me USB BUSY?  i am using STM32F303VC discovery board ......USB code generated using STMCUBEMX

Question asked by shankargowda m on May 21, 2018

when I am sending data using USB, when the callback in my firmware gives me USB BUSY?  i am using STM32F303VC discovery board ......USB code generated using STM32CubeMX.

 

Once, I received USB Busy state, dynamically sends correct data sometimes and sometimes i am losing data which i am sending...

here he is the code snippet.

i feel some issue with state change....

 

i am calling CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) API fro two different places alternatively....

 

when i call from one place it is working fine....

issue arising when calling from 2 places akternatively

 

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;
  }
  USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
  result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
  /* USER CODE END 7 */
  return result;

 

}

Outcomes