cancel
Showing results for 
Search instead for 
Did you mean: 

Why CDC_Receive_FS is empty on usbd_cdc_if.c?

leogarberoglio
Associate III
Posted on September 02, 2015 at 20:23

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!
2 REPLIES 2
Posted on September 08, 2015 at 18:29

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

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00108129.pdf?s_searchtype=keyword

-Shahrzad-
leogarberoglio
Associate III
Posted on September 15, 2015 at 14:24

Thank you shahrzad, I understand now.