libhal / SJSU-Dev2

Firmware platform written by San Jose State University for building application for embedded systems
Apache License 2.0
42 stars 63 forks source link

Storage: Consider removing IsMediaPresent() #1428

Open kammce opened 3 years ago

kammce commented 3 years ago

Feature Request

Remove IsMediaPresent() from the sjsu::Storage interface and have an exception be thrown if the media is not present when Initialize() is called.

Detailed Description

When should IsMediaPresent() be called? Normally it should be called after Initialize(), but without some sort of Enable() or Mount() methods, shouldn't Initialize() handle the duty of setting up peripherals AND mounting the media? At that point, if the media is mounted then checking an additional method is pointless. Initialize could omit the mounting step, then add a Mount() API to storage which would allow a point in time when IsMediaPresent() can be called. But this requires an additional entry on the storage interface's vtable and make the call structure more complicated. Simply making Initialize the only method needed to get storage working and having it throw an exception if it fails seems like the right approach.

The only concern is FAT FS and how there will need to be some work around for checking if media is present.