AnsweredAssumed Answered

nedd for Delay between CDC_Transmit_FS calling

Question asked by elgarbe on Sep 4, 2015
Latest reply on Apr 7, 2016 by Chinzei.Tsuneo
I have this code:

    while (1)
    {
        if(fUSB_rcv)
        {
            CDC_Transmit_FS((uint8_t *)"Mensaje Recibido\n\r", 18);
            HAL_Delay(10);
            if (msg[0]=='L' && msg[1]=='E' && msg[2]=='O' && msg[3]=='1')
            {
                CDC_Transmit_FS((uint8_t *)"Mensaje Correcto\n\r", 18);
            }
            else
            {
                CDC_Transmit_FS((uint8_t *)"Mensaje Incorrecto\n\r", 20);
            }
            fUSB_rcv=0;
        }
 
    }
 
 
static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
    /* USER CODE BEGIN 6 */
    char i = 0;
    fUSB_rcv=1;
    for (i = 0; i < *Len; i++)
        msg[i] = *(Buf + i);
     
    USBD_CDC_ReceivePacket(&hUsbDeviceFS);
    return (USBD_OK);
    /* USER CODE END 6 */
}

I would like to remove HAL_Delay before
 CDC_Transmit_FS((uint8_t *)"Mensaje Recibido\n\r", 18);
If I remove that delay, the second msg (Message Correct or Incorrect) is not received on PC side.
Is there a macro or a function to check before the second CDC_Transmit_FS calling?

regards

Outcomes