cancel
Showing results for 
Search instead for 
Did you mean: 

How to receive data from host under the STM32 Mass Storage FS?

JLee.64
Associate II

Hi all,

I am newbie in this field.

Using the STM32CubeMX V6.3 to create a virtual memory stick and working well under win7/10.

Using the sample code I can easily to send data to host as following

function sendDataToHost(...)

{

 USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;

  hmsc->bot_data[0] = 0x01;

  hmsc->bot_data[1] = 0x02;

  hmsc->bot_data[2] = 0x03;

  hmsc->bot_data[3] = 0x03;

  hmsc->bot_data_length = 4U;

  return 0;

}

And I want to receive data from host, what should i do?

My test code cause the timeout error and it seems like host don't know the data is received complete.

PS. Host Will send 8 bytes to device

function(...)

{

USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *) pdev->pClassData;

USBD_LL_PrepareReceive(pdev, MSC_EPOUT_ADDR, hmsc->bot_data, 8);

}

can anyone give me some idea?

Thanks

2 REPLIES 2
Uwe Bonnes
Principal III

There are a lot of MSC examples out there. Look at the code that receives data from the host. Perhaps LL has also an example

Thanks for your opinion! I will check the sample of USBD_LL_PrepareReceive().