Skip to main content
JLee.64
Associate
January 7, 2022
Question

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

  • January 7, 2022
  • 2 replies
  • 990 views

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

This topic has been closed for replies.

2 replies

Uwe Bonnes
Chief
January 7, 2022

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

JLee.64
JLee.64Author
Associate
January 7, 2022

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