FileSystem

class

Mono specific version of mbed’s SDFileSystem class.

Access the filesystem on an SD Card using standard C lib functions:

  • fopen
  • fread
  • fwrite
  • fclose

You should include stdio.h and use I/O functions as in normal C on a OS.

Reset and wake

You should atke care not to write to the SD card immediately after a reset or wake up.SD cards might need to time from power-on to they react on SD initialization sequence. Therefore you should at least wait some milliseconds to allow the SD to be powered, before you start to write data.

Example

You should this class as a member of your global AppController class, such that it is first initialized when your AppController is contructed.

Add as a variable on AppController:

class AppController : public mono::IApplication
{
 public:
   mono::io::FileSystem fs;
}

Then call the designated initializor oin your AppController‘s constructor:

AppController::AppController() :
  fs("sd")
{
   // ...
}

Now the SD card is mounted at: /sd

This class adds support for sleep mode to mbed FS functionality.

Public Functions

FileSystem::FileSystem()

Construct an invalid file system driver

FileSystem::FileSystem(const char *mountPoint)

Initialize the File system for a attached SD Card.

virtual void FileSystem::onSystemEnterSleep()

Called right before the MCU goes into sleep mode.

You can override this method to get sleep notifications. Before the CPU stop executing intructions and goes into low power sleep mode, this method gets called.

Use this method to prepare your data or MCU components for sleep. Help preserve battery by power down any peripheral, that is not needed during sleep.

This method can be called many times during your apps life cycle. (That is between resets.) After each sleep period, when the MCU wakes the onSystemWakeFromSleep is guaranteed to be called.

virtual void FileSystem::onSystemWakeFromSleep()

Override to get notified when system wakes from sleep.

You can override this method to get wake-up notifications. When the CPU starts executing intructions and the power system has powered up all peripherals - this method gets called.

Use this method to setup your app to resume after sleep mode.

This method can be called many times during your apps life cycle. (That is between resets.)