USB MSC writing complete event

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB MSC writing complete event

1,270 Views
mircopizzichini
Contributor III

Hi

Using USB MSC driver, is there a way to know when writing to a file is complete?

In usb_msc.c, function USB_Service_Bulk_Out(), there'a control on remaining transfer size

event_type = (uint_8)(msc_obj_ptr->transfer_remaining?

                USB_MSC_DEVICE_WRITE_REQUEST : USB_APP_DATA_RECEIVED);

But in my callback, usb_bulk_transaction_callback(), I receive multiple USB_MSC_DEVICE_WRITE_REQUEST, as expected, but never a USB_APP_DATA_RECEIVED, which I assume is set to indicate the end of writing. Maybe I didn't understand correctly this driver.

Can you help me?

Labels (1)
Tags (2)
0 Kudos
Reply
2 Replies

1,033 Views
soledad
NXP Employee
NXP Employee

Hi,

You need to implement something like the disk example that you can find at the path C:\Freescale\Freescale_MQX_4_1\usb\device\examples\msd

Please check the Bulk_Transaction_Callback function in disk.c

      case USB_APP_DATA_RECEIVED :
            /* Add User defined code -- if required*/


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,033 Views
mircopizzichini
Contributor III

Hi Sol, thank you for your response

I've already tried as you suggest, adding (for example) a LED blinking in the USB_APP_DATA_RECEIVED case in my Bulk_Transaction_Callback function, but I think this event is never sent because LED does not blink.

So I've also put a breakpoint in the usb_msc.c function (USB_Service_Bulk_Out) sending this event, but it's never asserted.

I think the problem is in file usb_msc.c: remaining transfer size is decremented (line 446) after the event transmission (line 422), so USB_APP_DATA_RECEIVED can never be asserted.

I moved 

msc_obj_ptr->param_callback.callback(USB_APP_DATA_RECEIVED, (void*)&bulk_out_recv, msc_obj_ptr->param_callback.arg);

on line 474, when transfer is complete and the end of data phase is completed, and now it works. Could it be rigth?

Now transfer is correctly done and reported by the previous event, but with a "sd dir" I cannot see the new file in the memory. Is there a way to refresh (maybe) filesystem to see the new file?

Thank you

Mirco

0 Kudos
Reply