AnsweredAssumed Answered

CDC stm32f4 full duplex sample ( STM32CubeMX )

Question asked by Reddy.Harinadha on Jul 15, 2014
I'm using the STM32CubeMX 4.3.0 version. I created a project for CDC Virtual COM port for STM32F405RG micro. I need full duplex communication. Please find the attached CubeMX project .ioc file.
Following is the USB schematic of the board.
USB_STM32F405.png
Generated code for IAR EWARM. The generated code has the following functions to receive & transmit data.

static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
  /* USER CODE BEGIN 7 */
  
  return (USBD_OK);
  /* USER CODE END 7 */
}
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
{
  uint8_t result = USBD_OK;
  /* USER CODE BEGIN 8 */
  //USBD_CDC_SetTxBuffer(hUsbDevice_0, UserTxBufferFS, Len);   // generated code
  USBD_CDC_SetTxBuffer(hUsbDevice_0, Buf, Len);      // modified code
  result = USBD_CDC_TransmitPacket(hUsbDevice_0);
  /* USER CODE END 8 */
  return result;
}

I have changed a line in CDC_Transmit_FS function to use it from main.c file to write data to USB.
How can I get data out of UserRxBufferFS buffer as there is no code inside CDC_Receive_FS function ?
In my application, I need full duplex USB communication. Please through some code samples for this project.
I have seen CDC_Standalone example in STM32Cube_FW_F4_V1.3.0\Projects\STM324x9I_EVAL\Applications\USB_Device\CDC_Standalone

But this is quite different from what I want to achieve ( this is USB to RS232 bridge sample)

Attachments

Outcomes