Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SDFileSystem by
Revision 3:b8c141fd8e0e, committed 2014-12-02
- Comitter:
- jhawkins38
- Date:
- Tue Dec 02 15:19:26 2014 +0000
- Parent:
- 2:c8f66dc765d4
- Commit message:
- for alarm
Changed in this revision
| SDFileSystem.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SDFileSystem.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SDFileSystem.cpp Thu Nov 29 10:56:21 2012 +0000
+++ b/SDFileSystem.cpp Tue Dec 02 15:19:26 2014 +0000
@@ -119,9 +119,10 @@
#define SD_DBG 0
-SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) :
- FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs) {
+SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName cd, const char* name) :
+ FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs), _cd(cd) {
_cs = 1;
+ _cd.mode(PullUp);
}
#define R1_IDLE_STATE (1 << 0)
@@ -463,3 +464,15 @@
};
return blocks;
}
+//creates SD card detect using cd
+bool SDFileSystem:: SD_inserted(){
+
+if ( _cd==1){
+ wait(0.1);
+ disk_initialize();
+return true;
+}
+else{
+return false;
+}
+}
\ No newline at end of file
--- a/SDFileSystem.h Thu Nov 29 10:56:21 2012 +0000
+++ b/SDFileSystem.h Tue Dec 02 15:19:26 2014 +0000
@@ -51,13 +51,14 @@
* @param cs DigitalOut pin used as SD Card chip select
* @param name The name used to access the virtual filesystem
*/
- SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
+ SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName cd, const char* name);
virtual int disk_initialize();
virtual int disk_status();
virtual int disk_read(uint8_t * buffer, uint64_t block_number);
virtual int disk_write(const uint8_t * buffer, uint64_t block_number);
virtual int disk_sync();
virtual uint64_t disk_sectors();
+ virtual bool SD_inserted();
protected:
@@ -77,6 +78,7 @@
SPI _spi;
DigitalOut _cs;
int cdv;
+ DigitalIn _cd;
};
#endif
