usb接收

This commit is contained in:
许晟昊 2025-03-12 00:58:36 +08:00
parent 056b3e1d3e
commit c6ec9d0b06
3 changed files with 4328 additions and 4323 deletions

File diff suppressed because it is too large Load Diff

View File

@ -260,6 +260,7 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t *pbuf, uint16_t length)
static int8_t CDC_Receive_FS(uint8_t *Buf, uint32_t *Len) static int8_t CDC_Receive_FS(uint8_t *Buf, uint32_t *Len)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */
usb_receive(Buf, *Len);
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceFS); USBD_CDC_ReceivePacket(&hUsbDeviceFS);
return (USBD_OK); return (USBD_OK);
@ -349,6 +350,11 @@ void usb_printf(const char *format, ...)
CDC_Transmit_FS(UserTxBufferFS, length); // 调用 USB CDC函数发送数据 CDC_Transmit_FS(UserTxBufferFS, length); // 调用 USB CDC函数发送数据
} }
void usb_receive(uint8_t *pbuf, uint32_t len)
{
usb_printf("len = %d\r\n", len);
}
/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
/** /**

View File

@ -1,7 +1,7 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : usbd_cdc_if.h * @file usbd_cdc_if.h
* @version : v1.0_Cube * @version : v1.0_Cube
* @brief : Header for usbd_cdc_if.c file. * @brief : Header for usbd_cdc_if.c file.
****************************************************************************** ******************************************************************************
@ -109,6 +109,7 @@ uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
/* USER CODE BEGIN EXPORTED_FUNCTIONS */ /* USER CODE BEGIN EXPORTED_FUNCTIONS */
void usb_printf(const char *format, ...); void usb_printf(const char *format, ...);
void usb_receive(uint8_t *pbuf, uint32_t len);
/* USER CODE END EXPORTED_FUNCTIONS */ /* USER CODE END EXPORTED_FUNCTIONS */
/** /**