2015-09-02 11:23 AM
Hi, I create a new project using cubemx 4.10 with hal 1.8 for USB device. I'm looking for receive function and i found CDC_Receive_FS, but there is almost no code in ther:
/**
* @brief CDC_Receive_FS
* Data received over USB OUT endpoint are sent over CDC interface
* through this function.
*
* @note
* This function will block any OUT packet reception on USB endpoint
* untill exiting this function. If you exit this function before transfer
* is complete on CDC interface (ie. using DMA controller) it will result
* in receiving more data while previous ones are still not sent.
*
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
return (USBD_OK);
/* USER CODE END 6 */
}
when the host send a byte an IRQ is generated and end on this function, right? On Buf I have byte receive and on Len the lenght of it. What is the link between that lenght and the define:
/* Define size for the receive and transmit buffer over CDC */
/* It's up to user to redefine and/or remove those define */
#define APP_RX_DATA_SIZE 4
#define APP_TX_DATA_SIZE 4
as soon as the host send a byte the
CDC_Receive_FS
will run? or it has to be
APP_RX_DATA_SIZE
bytes before
CDC_Receive_FS
will call?
thank!
2015-09-08 09:29 AM
Hi elgarbe,
1- usbd_cdc_if.c is a driver for user application, so you can add your own code in CDC_Receive_FS function. 2- APP_RX_DATA_SIZE is the total size of circular temporary buffer fo IN data, APP_TX_DATA_SIZE is the total size of circular temporary buffer OUT data transfer. These two parameters corresponds respectively to the size of user buffers UserRxBuffer, UserTxBuffer. No relation between run of CDC_Receive_FS and them. 3-For more details, refer to this -Shahrzad-2015-09-15 05:24 AM
Thank you shahrzad, I understand now.