<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPCXpresso IDE中的主题 Combining EFSL and USB Mass Storage Access</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581521#M24982</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by scs on Tue Sep 27 09:30:01 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;We are fairly new to the LPCXpresso 1769 and need to access files on a SD flash card and also to allow USB access to those files from a PC. I'd bet many others have similar needs.&amp;nbsp; The RDB1768cmsis2.zip sample projects RDB1768cmsis2_efsl_lib, RDB1768cmsis2_efsl_demo, RDB1768cmsis2_usbstack, and RDB1768cmsis2_usb_msc do both, but need combining. Plus we wished that those and other samples explained how to wire the required hardware, an SD card and USB connector in this case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I created EfsUsb.c which combines EFSL links and USB MSC in a single source file, linking to the RDB1768cmsis2_efsl_lib and RDB1768cmsis2_usbstack library projects, and combining all of the necessary RDB1768cmsis2_usb_msc sources in that single file. It uses the EFSL low level block read and write functions instead of blockdev_sd.c and lpc2000_spi.c.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EfsUsb.c also includes detailed comments at the top explaining how to wire your SD card and USB connection, and also where to change the USB product ID's and such. I'm not the one who actually did that wiring here (I mostly just type for a living), but tried to make the wiring information very clear and hopefully error free.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EfsUsb.c also has information and a simple API for coordinating local EFSL file access with USB connections, since having both occur at the same time can easily scramble your SD data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The attached EfsUsb.zip is a sample project with EfsUsb.c, EfsUsb.h and a main.c that demonstrates writing and reading an SD file and then waits forever for USB connections. There is a ReadMe.txt and similar information in the main.c comments, in addition to the documentation in EfsUsb.c.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To install on the Code Red IDE, unzip into a new folder outside your workspace and use "Import project(s)" and Browse to that "Project directory (unpacked)". This may result in two Debug build choices and you can just choose the first. I'm unsure whether unziping directly into your workspace would also work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code is free to use as you like, but check the copyright information in the EfsUsb.c header comments. If anyone from Code Red is reading this, it would be great if you guys could include this in a future release, possibly in the RDB1768cmsis2.zip sample projects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(The attached EfsUsb.zip was updated 9 Jan 2012 to call efs_init via a new SDsetup(1) mode, used to clear the state after EFS file access. This seems to be required for successful USB access after you have written a file via EFS in many cases. My own code now routinely calls SDsetup(1) after closing a file, but before using SDlock(NOT_USING) to release the EFS lock on the SD. SDsetup(0) is now called with a 0 argument for initialization.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve Simonoff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SporTraq&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:00:58 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:00:58Z</dc:date>
    <item>
      <title>Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581521#M24982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by scs on Tue Sep 27 09:30:01 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;We are fairly new to the LPCXpresso 1769 and need to access files on a SD flash card and also to allow USB access to those files from a PC. I'd bet many others have similar needs.&amp;nbsp; The RDB1768cmsis2.zip sample projects RDB1768cmsis2_efsl_lib, RDB1768cmsis2_efsl_demo, RDB1768cmsis2_usbstack, and RDB1768cmsis2_usb_msc do both, but need combining. Plus we wished that those and other samples explained how to wire the required hardware, an SD card and USB connector in this case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I created EfsUsb.c which combines EFSL links and USB MSC in a single source file, linking to the RDB1768cmsis2_efsl_lib and RDB1768cmsis2_usbstack library projects, and combining all of the necessary RDB1768cmsis2_usb_msc sources in that single file. It uses the EFSL low level block read and write functions instead of blockdev_sd.c and lpc2000_spi.c.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EfsUsb.c also includes detailed comments at the top explaining how to wire your SD card and USB connection, and also where to change the USB product ID's and such. I'm not the one who actually did that wiring here (I mostly just type for a living), but tried to make the wiring information very clear and hopefully error free.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EfsUsb.c also has information and a simple API for coordinating local EFSL file access with USB connections, since having both occur at the same time can easily scramble your SD data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The attached EfsUsb.zip is a sample project with EfsUsb.c, EfsUsb.h and a main.c that demonstrates writing and reading an SD file and then waits forever for USB connections. There is a ReadMe.txt and similar information in the main.c comments, in addition to the documentation in EfsUsb.c.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To install on the Code Red IDE, unzip into a new folder outside your workspace and use "Import project(s)" and Browse to that "Project directory (unpacked)". This may result in two Debug build choices and you can just choose the first. I'm unsure whether unziping directly into your workspace would also work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code is free to use as you like, but check the copyright information in the EfsUsb.c header comments. If anyone from Code Red is reading this, it would be great if you guys could include this in a future release, possibly in the RDB1768cmsis2.zip sample projects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(The attached EfsUsb.zip was updated 9 Jan 2012 to call efs_init via a new SDsetup(1) mode, used to clear the state after EFS file access. This seems to be required for successful USB access after you have written a file via EFS in many cases. My own code now routinely calls SDsetup(1) after closing a file, but before using SDlock(NOT_USING) to release the EFS lock on the SD. SDsetup(0) is now called with a 0 argument for initialization.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve Simonoff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SporTraq&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:00:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581521#M24982</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581522#M24983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by OXO on Wed Sep 28 00:41:04 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That's a good donation to the community. Too late for me though.. last month I did the same thing with fatfs and usbmsd.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:00:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581522#M24983</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581523#M24984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Wed Sep 28 07:04:27 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for posting your project. Nice to see the examples being extended like this :)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One minor point, your project also needs the CMSIS library project in order to build, in addition to the USB and EFSL library projects that you mention&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:00:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581523#M24984</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581524#M24985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by james on Mon Jan 02 21:02:02 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: OXO&lt;/STRONG&gt;&lt;BR /&gt;That's a good donation to the community. Too late for me though.. last month I did the same thing with fatfs and usbmsd.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thats cool, not sure if you could share with us a part of that?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:01:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581524#M24985</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581525#M24986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by OXO on Tue Jan 03 01:21:35 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Well it's a bit more cool than I said. it doesn't use an SD card, the files are in Atmel Dataflash with (unfortunately for sharing) copyrighted wear levelling.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:01:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581525#M24986</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581526#M24987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by scs on Mon Jan 09 19:43:47 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I just updated my original EfsUsb.zip download below. After creating and writing a file via EFS, USB access from a PC seems to often fail unless efs_init is called again, which appears to clear the state seen by USB. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A modified version of the SDsetup function now takes an argument, which is 0 initially, but which can be 1 to call efs_init again without re-initializing the USB. I now routinely call SDsetup(1) after closing a file but before releasing the SD for USB access via&amp;nbsp; SDlock(NOT_USING).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:01:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581526#M24987</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581527#M24988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by monnoliv on Tue Jan 17 06:39:50 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your contribution of great value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you a few lines of code (for main or a task) that shows the way to use it. I've installed your code right on my FreeRTOS project, it compiles fine (I add efsl_SetTime on my time.c).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My interest is that the PC leaves a file onto the SDCard and then my code read the file. I understood the SDlock(arg) function but what about the USBpoll(0)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Must the PC eject the media in order for my tasks to access it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Olivier&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:01:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581527#M24988</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581528#M24989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by scs on Tue Jan 17 16:15:05 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The main.c does have a simple example, but maybe not quite what you were looking for. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm no expert, but this is my understanding.&amp;nbsp; Passing data from the PC to your app is not as easy as you might imagine.&amp;nbsp; That's because of the way USB mass storage works and not just this implementation. The device just reads and writes 512 byte blocks for the PC without really knowing which directory entries and/or files are being used. The PC does not ask "please create file X", just "please write block N", which might or might not be part of file X.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Fortunately, your software can know when the PC is done, so it can grab the SDlock and check for new data.&amp;nbsp; The processor knows when the USB disconnects, but this may not be quite the same as when you "eject" the device from the PC.&amp;nbsp; At least on Windows, it usually seems to take physically disconnecting the cable, and the "Eject" command apparently just flushes changes to the device but does not electrically break the connection. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you unplug the USB cable, (LPC_GPIO1-&amp;gt;FIOPIN &amp;amp; (1 &amp;lt;&amp;lt; 18)) goes false (at least on an LPC1768), which is detected by USBpoll.&amp;nbsp; USBpoll then returns 0.&amp;nbsp; Your code can wait for USBpoll to return with a value other than 1 (USB_USING) and then call SDlock(EFS_USING) to grab the SD card for EFS access. It can then check for anything new from the PC, such as in an agreed-upon file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to positively know the USB was connected before checking, you could use USBpoll(1) so it would return USB_CONNECTED for a while before returning 0.&amp;nbsp; Or you could modify the internals of USBpoll to set a "SD potentially changed" flag.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:01:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581528#M24989</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Combining EFSL and USB Mass Storage Access</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581529#M24990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by monnoliv on Wed Jan 18 07:22:38 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok, thanks for your explanation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Since I need some more interaction with the PC, I think that it's better for me to do a HID device and use the Fatfs library. I've already done the HID (really nice, no driver whatever the OS) and FatFs separately in FreeRTOS, works fine, it remains to write a file transfer function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Olivier&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:01:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Combining-EFSL-and-USB-Mass-Storage-Access/m-p/581529#M24990</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:01:10Z</dc:date>
    </item>
  </channel>
</rss>

