cancel
Showing results for 
Search instead for 
Did you mean: 

usb host MSC send&receiveData

Khoa Tran
Associate II
Posted on June 01, 2015 at 11:27

I made a project with stm32cude mx for stm32f401 discovery,

discovery board is usb msc host, send a command to devide (usb msc device) then receive data form device my project connected and saw all infomation of device, but a don't know how to send command (2 byte) to device. what 's library can do it. i try USBH_BulkSendData (USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length, uint8_t pipe_num, uint8_t do_ping ) and USBH_BulkReceiveData(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length, uint8_t pipe_num) .... but it not send/recive data please help me!!!!

HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
USBH_Start(&hUSB_Host);
while (1)
{
/* USB Host Background task */
USBH_Process(&hUSB_Host);
HAL_Delay(1);
/* Mass Storage Application State Machine */
switch(Appli_state)
{
case APPLICATION_START:
while(USBH_BulkSendData(&hUSB_Host,(uint8_t*)tx,2,1,1)!=USBH_OK);
while(USBH_BulkReceiveData(&hUSB_Host, (uint8_t *)rx, 64,1)!=USBH_OK);
Appli_state = APPLICATION_IDLE;
break;
case APPLICATION_IDLE:
default:
break;
}
}

1 REPLY 1
chrif
Associate II
Posted on June 15, 2015 at 12:30

Hi,

You can refer to the application in

STM32Cube_FW_F4_V1.6.0\Projects\STM324xG_EVAL\Applications\USB_Device\MSC_Standalone, also have a look at the user manual UM1720, specially the section 4.2

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