Hi Christo
How to stop the SD card ?
Once the SD card has been detected and mounted it can be used. If the SD card is then removed from the system this is not noticed (unless a card detect switch is present and used) until some action is performed that needs to read the card (sometimes even performing a DIR will not notice that the card has been removed because the root directory is still in cache).
But I think that you would like a method of not necessarily removing the card but disabling it so that the uFileSystem is used by FTP (for example).
FTP bases its file system use on the flag UTDIR_VALID which is set when the FTP connection is established by calling utOpenDirectory(FTP_ROOT, ptr_utDirectory);. Since this will always be sucessful if the SD card is still present I think that it would be simplest to control FTP directly to either try to use the FTP card or not rather than controlling whether the card is detected or not. Fpr example a global variable that indicates which modules can use the card and which should not.
That means that if you want to switch FTP from SD card based to uFileSystem based with an active SD card it woudl be necessary to be able to control that variable.
Generally it may be useful to add an unmount command which can be used to disable the SD card entirely, including powering it down if it has its own power supply. Later a mount could be commanded that will then try to mount the card or regularly poll it in case it is not inserted at the time but may be inserted later.
As summary I could imaging three commands to the utFAT module:
- one to disable or enable access from certain system modules (eg. FTP, HTTP and maybe some optional flags for the application parts too)
- one to unmount a card
- one to remount the card (although restarting the mass storage task may be adequate)
Regards
Mark