f
Fork of SDFileSystem by
Revision 3:44b82d302743, committed 2014-03-26
- Comitter:
- jmar7
- Date:
- Wed Mar 26 18:18:45 2014 +0000
- Parent:
- 2:c8f66dc765d4
- Commit message:
- v1
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 |
diff -r c8f66dc765d4 -r 44b82d302743 SDFileSystem.cpp --- a/SDFileSystem.cpp Thu Nov 29 10:56:21 2012 +0000 +++ b/SDFileSystem.cpp Wed Mar 26 18:18:45 2014 +0000 @@ -119,8 +119,8 @@ #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; } @@ -240,6 +240,17 @@ int SDFileSystem::disk_sync() { return 0; } uint64_t SDFileSystem::disk_sectors() { return _sectors; } +bool SDFileSystem::sd_inserted() { + DigitalIn SDcard_detect(p9); + SDcard_detect.mode(PullUp); + wait(0.1); + if(SDcard_detect==1) { + return true; + } + else { + return false; + } +} // PRIVATE FUNCTIONS int SDFileSystem::_cmd(int cmd, int arg) {
diff -r c8f66dc765d4 -r 44b82d302743 SDFileSystem.h --- a/SDFileSystem.h Thu Nov 29 10:56:21 2012 +0000 +++ b/SDFileSystem.h Wed Mar 26 18:18:45 2014 +0000 @@ -51,14 +51,15 @@ * @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(); - + bool sd_inserted(); + protected: int _cmd(int cmd, int arg); @@ -76,6 +77,7 @@ SPI _spi; DigitalOut _cs; + DigitalIn _cd; int cdv; };