Hello Hui,
In Host stack, it is quite different, you need to initialize a transfer request and then set a callback that you can use to signal an event when transaction (either recepcion or transmission) has completed. For more information, you can read the MQX_USB_Host_User_Guide, section 4.2.4.6 Sending/Receiving Data to/from Device.
Also, you can see host's examples and could notice (for example, en hid example) how this TR is used:
/******************************************************************
Initiate a transfer request on the interrupt pipe
******************************************************************/
usb_hostdev_tr_init(&tr, usb_host_hid_recv_callback, NULL);
tr.G.RX_BUFFER = buffer;
tr.G.RX_LENGTH = pipe->MAX_PACKET_SIZE;
status = _usb_host_recv_data(host_handle, pipe, &tr);
This TR is a structure that describes a transfer in its entirety, then you can request/transmit data using this TR and after this transaction is completed, callback function is called. In this callback you can use an event to inform about success/failure for transmission/reception:
void usb_host_hid_recv_callback
(
/* [IN] pointer to pipe */
_usb_pipe_handle pipe_handle,
/* [IN] user-defined parameter */
void *user_parm,
/* [IN] buffer address */
unsigned char *buffer,
/* [IN] length of data transferred */
uint32_t buflen,
/* [IN] status, hopefully USB_OK or USB_DONE */
USB_STATUS status
)
{ /* Body */
if (status == USB_OK) {
/* notify application that data are available */
_lwevent_set(&USB_Event, USB_EVENT_DATA);
}
else {
/* notify application that data are available */
_lwevent_set(&USB_Event, USB_EVENT_DATA_CORRUPTED);
}
}
I hope this can help you!
Best Regards,
Isaac Avila
----------------------------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------------------------