Does anyone ported successfully Elm Chan’s FATFS to FreeRTOS ?
The author suggested using mutexes for using fatfs from more than 1 thread, but where do I really have to use them?
a) just to protect the hardware dependent calls ?
b) to protect every call to the fatfs api ?
I searched this forum and found some messages from a person that apparently used mutexes in a higher level (just freeing the resource when the file was closed).
I wraped all fatfs api calls (f_open, f_read…) with a mutex ,
I wraped all access to SPI port (that I plan to use for another device) in the hardware dependant calls (disk_initialize,disk_read, etc) with another mutex.
To mimic the timer interrupt routines (disk_timerproc), I created a task to fire at 10ms intervals:
I made a test, 2 task writing to different files , 1000 lines of text, one writing 1 line each 100ms and the other at 200ms, both tasks started at the same time, but obviously file1 took half long to complete.
Both files writen successfully, no aparent problem.
Just a Note:
If you have planed to use SPI for other device and not using FATFS in multiple tasks simaltanously, then its sufficient to lock/unlock just SPI calls.
Aceesing the FATFS calls for writing to a SDcard from multiple tasks with mutex, decreses the card read/write speed in realtime.
Example:Writing a PCM Audio data @44.1Khz is not possible in realtime with SPI interface.