Fork of SDFileSystem by
Diff: SDFileSystem.h
- Revision:
- 4:3f40cbfe801c
- Parent:
- 3:7b35d1709458
diff -r 7b35d1709458 -r 3f40cbfe801c SDFileSystem.h --- a/SDFileSystem.h Mon Mar 17 14:34:01 2014 +0000 +++ b/SDFileSystem.h Wed Aug 24 02:51:06 2016 +0000 @@ -32,14 +32,13 @@ * #include "mbed.h" * #include "SDFileSystem.h" * - * SDFileSystem sd(p5, p6, p7, p12, "sd"); // MOSI, MISO, SCLK, SSEL - * + * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs + * * int main() { - * FILE *fp = fopen("/sd/mbed.txt", "w"); + * FILE *fp = fopen("/sd/myfile.txt", "w"); * fprintf(fp, "Hello World!\n"); * fclose(fp); * } - * @endcode */ class SDFileSystem : public FATFileSystem { public: @@ -53,13 +52,12 @@ * @param name The name used to access the virtual filesystem */ SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, 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_read(uint8_t* buffer, uint32_t block_number, uint32_t count); + virtual int disk_write(const uint8_t* buffer, uint32_t block_number, uint32_t count); virtual int disk_sync(); - virtual uint64_t disk_sectors(); + virtual uint32_t disk_sectors(); protected: @@ -70,15 +68,22 @@ int initialise_card(); int initialise_card_v1(); int initialise_card_v2(); - + int _read(uint8_t * buffer, uint32_t length); int _write(const uint8_t *buffer, uint32_t length); - uint64_t _sd_sectors(); - uint64_t _sectors; - + uint32_t _sd_sectors(); + uint32_t _sectors; + + void set_init_sck(uint32_t sck) { _init_sck = sck; } + // Note: The highest SPI clock rate is 20 MHz for MMC and 25 MHz for SD + void set_transfer_sck(uint32_t sck) { _transfer_sck = sck; } + uint32_t _init_sck; + uint32_t _transfer_sck; + SPI _spi; DigitalOut _cs; int cdv; + int _is_initialized; }; -#endif +#endif \ No newline at end of file