2014-11-02 11:07 PM
I need to sent a message to my main task, that tells it USB is connected. (so I can display a message on screen, and display file names etc.)
What events are generated? any documentation or sample code on this?It does not seems right to poll the FatFS with f_mount()..Thanks2014-11-03 12:34 AM
Hi Johanan,
I don't really have enough insight into what specifically you are doing, and how. Can you tell us what STM32 are you using, and with any FW package ?Regards,Heisenberg.2014-11-03 02:09 AM
2014-11-03 02:38 AM
Hi
''Now I need to use the FatFS in a separate thread, but could not find any documentation on this.'' Having the disk in a separate thread May or May NOT be a good idea ! Usually, 'disk' is treated like any sharable resource and should be guarded (Mutex or semaphore) against multiple access. It is possible to have it guarded by using it in a thread (in fact the system I am working on treats shared resources like this. However, it has caused many more problems than it has solved. Not my idea and I did advise against it!) What you must do now is treat all access to disk as a inter-task message. Your design now becomes a tasking/event driven system. This is a system design decision. ''To start , I need to have the FS thread to wait for an event, which will dispaly a short message like '' USB detected'' or similar, then I can start the FS with f_mount etc.'' I think is is becoming apparent that there is not a clear understanding between the USB and FatFS.'' Firstly, it sounds like you are dealing with a USB host MSC implementation. This will generate a number of IRQs. These should be handled by the code generated by STM32Cube. FatFS sits on top of the USB host MSC implementation. It should be tied in to some of the USB IRQs eg device connect should be linked to FatFS mount device. A successful (or un-successful) mount can then send an inter-task message to what ever task deals with displaying the message. ''I think is is becoming apparent that there is not a clear understanding between the USB and FatFS.'' It is apparent that there is a lack of understanding of 'Tasking' in a mult-tasking operating system. It is apparent that there is a lack of understanding of separation of driver layer (USB) and services (disk format provided by FatFS) and tasking.2014-11-03 03:08 AM
2014-11-03 03:17 AM
2014-11-03 03:39 AM
Hi
''You are correct that I don't fully understand the FatFS <-> MSC relationships. That is why I am looking for some proper documentation or help.'' This is a steep learning curve! So the ST Cube (as far as I understand) took the original code from the USB OTG library and put it into a Java program that would generate the same code but with some name changes. Have a look at he document UM1021 which is an overview of the USB UTG library.http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF257882
You are only interrested in the USB Host part and in particular the 'Host' 'Mass Storage Class' implementation in the library. Now, the ST examples have already integrated FatFS with the USB MSC (after all who want to work with the raw sectors in a USB stick or memory card). If you look at the code in the library and the documentation, it should tell you which functions need to be integrated for 'disk access' and this should already be integrated with FatFS in the example. When you have got your head around this, this is only has the STM32 can access USB memory stick. Next, you will have to get your head around Multi-tasking and inter-task messages.2014-11-03 03:51 AM
2014-11-03 06:07 AM
''would you be so kind and send me your email to:''
No thank you.2014-11-03 08:15 AM
BTW have you read this
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00105259.pdf
? It looks like it comes at it from the other side - FatFS ie. what functions FatFS needs integrating with