AnsweredAssumed Answered

CDC_Transmit_FS is not happening from inside the CDC_Receive_FS function

Question asked by P D on Nov 3, 2017
Latest reply on Nov 3, 2017 by Ant M

Hi there,

 

I am trying to Transmit data over USB CDC after receiving a command, So I need call cdc transmit function inside cdc rx function in which I am comparing the received data. 

But i am able to use only 1 cdc_tx function. when I am calling more than 1 tx function it is not functioning..

 

Following are the cdc tx and rx functions that I am using:-

 

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(USB_CONNECTED)
{
while(hcdc->TxState != 0);
}
/*if (hcdc->TxState != 0){
return USBD_BUSY;
}*/
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);

/* USER CODE END 7 */
return result;
}

 

 

 

static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
//printf("\n\r%d\n\r",*Buf);
if(Buf[0]=='i')
{
CDC_Transmit_FS((uint8_t *)"\n\r Hello\n\r",strlen((const char *)"\n\r Hello\n\r"));

CDC_Transmit_FS((uint8_t *)"\n\r Hello\n\r",strlen((const char *)"\n\r Hello\n\r"));


}

 

 

 

USBD_CDC_ReceivePacket(&hUsbDeviceFS);
return (USBD_OK);
/* USER CODE END 6 */
}

 

 

I am using STM32F2 nucleo board

CubeMX v 4.22.0

Outcomes