How to Data Read or Write in USB(Full Speed/High Speed)

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

How to Data Read or Write in USB(Full Speed/High Speed)

344 Views
aajithkumarr
Contributor I

Hi NXP Team

I am beginner to the NXP controllers,I am currently working on a board OM13098LPCxpresso54628.I am trying create a new txt file write some data on to it in microUSB port J2/J3.I am using the example project provided in the SDK example(host_msd_fatfs_bm).USB Device was connected to the micro AB port to USB(J3) was detected. But i was structed in where to open the file and write the file.

In main function 

USB_HostTaskFn(g_HostHandle);
USB_HostMsdTask(&g_MsdFatfsInstance);

function was called but i dont know how to write data onto the file.Is there any function i need to call.

Please provide me the example project which can open the file and write the data onto it or provide how to i start working. what are the procedure i need to follow.

 

 

Kindly help me.

 

Best regards,

A. Ajith Kumar 

0 Kudos
1 Reply

322 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @aajithkumarr,

The SDK example(host_msd_fatfs_bm) that you are using is the recommended one to start to open, create, write and read files.

Follow the next steps to find the relevant functions to open and write a file to the USB in the example:

  • Ctrl + click on USB_HostMsdTask(&g_MsdFatfsInstance);

RaulRomero_0-1685386167958.png

[app.c file in host_msd_fatfs_bm SDK example]

  • Then in the function search for USB_HostMsdFatfsTest(msdFatfsInstance); and ctrl + click on it.

RaulRomero_1-1685386168226.png

[host_msd_fatfs.c file in host_msd_fatfs_bm SDK example]

Now you are in the function that performs all the testing/actions this example mentions in the readme.pdf file.

  • Nonetheless, the file opening and writing is almost at the end of the function. You may want to search for the following line that starts the open/create a file test: usb_echo("file operation:\r\n");

RaulRomero_2-1685386168228.png

[host_msd_fatfs.c file in host_msd_fatfs_bm SDK example]

In here you will find the f_open function that is used for open/creating a non-existing file, while f_write is used for writing onto the file.

We recommend you work with the example, and to debug it to see how it works.

Caution: The SDK example erases all the content of the connected USB stick (performs a format).

Best regards, Raul.

0 Kudos