STM32F103 的例子用的是static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) 回调函数, 不是 CDC_Itf_Receive
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
//USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
HAL_UART_Transmit_DMA(&huart2, Buf, *Len);
//HAL_UART_Transmit_IT(&huart1, Buf , 1);
return (USBD_OK);
/* USER CODE END 6 */
} |