diff --git a/stm32/usb/usbd_cdc_if.c b/stm32/usb/usbd_cdc_if.c index 2b390f4..35fd4d5 100755 --- a/stm32/usb/usbd_cdc_if.c +++ b/stm32/usb/usbd_cdc_if.c @@ -24,6 +24,7 @@ /* USER CODE BEGIN INCLUDE */ uint8_t* CDC_RX_BUFFER = NULL ; +uint16_t CDC_RX_LEN = 0; /* USER CODE END INCLUDE */ /* Private typedef -----------------------------------------------------------*/ @@ -264,8 +265,9 @@ 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); + CDC_RX_BUFFER = Buf; + CDC_RX_LEN = *Len; return (USBD_OK); /* USER CODE END 6 */ } diff --git a/stm32/usb/usbd_cdc_if.h b/stm32/usb/usbd_cdc_if.h index c55c34b..87da7a5 100755 --- a/stm32/usb/usbd_cdc_if.h +++ b/stm32/usb/usbd_cdc_if.h @@ -91,6 +91,16 @@ extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; /* USER CODE BEGIN EXPORTED_VARIABLES */ +extern USBD_HandleTypeDef hUsbDeviceFS; +extern uint8_t* CDC_RX_BUFFER; +extern uint16_t CDC_RX_LEN; +/* + * when CDC_RX_LEN != 0, CDC_RX_LEN bytes are available in CDC_RX_BUFFER. + * Once all bytes have been consumed from the buffer, set CDC_RX_LEN to + * zero and call: + * USBD_CDC_ReceivePacket(&hUsbDeviceFS); + * to receive more data. + */ /* USER CODE END EXPORTED_VARIABLES */