diff --git a/features/filesystem/sd/SDBlockDevice.cpp b/features/filesystem/sd/SDBlockDevice.cpp index ee3f14006f..915fa6a4a4 100644 --- a/features/filesystem/sd/SDBlockDevice.cpp +++ b/features/filesystem/sd/SDBlockDevice.cpp @@ -405,29 +405,6 @@ int SDBlockDevice::_cmd(int cmd, int arg) { return -1; // timeout } -int SDBlockDevice::_cmdx(int cmd, int arg) { - _select(); - - // send a command - _spi.write(0x40 | cmd); - _spi.write(arg >> 24); - _spi.write(arg >> 16); - _spi.write(arg >> 8); - _spi.write(arg >> 0); - _spi.write(0x95); - - // wait for the response (response[7] == 0) - for (int i = 0; i < SD_COMMAND_TIMEOUT; i++) { - int response = _spi.write(0xFF); - if (!(response & 0x80)) { - _deselect(); - return response; - } - } - _deselect(); - return -1; // timeout -} - int SDBlockDevice::_cmd58() { int arg = 0; _select(); @@ -582,7 +559,7 @@ uint32_t SDBlockDevice::_sd_sectors() { uint32_t blocks; // CMD9, Response R2 (R1 byte + 16-byte block read) - if (_cmdx(9, 0) != 0) { + if (_cmd(9, 0) != 0) { debug_if(_dbg, "Didn't get a response from the disk\n"); return 0; } diff --git a/features/filesystem/sd/SDBlockDevice.h b/features/filesystem/sd/SDBlockDevice.h index cabce605a8..cdf3ca9f95 100644 --- a/features/filesystem/sd/SDBlockDevice.h +++ b/features/filesystem/sd/SDBlockDevice.h @@ -129,7 +129,6 @@ public: private: int _cmd(int cmd, int arg); - int _cmdx(int cmd, int arg); int _cmd8(); int _cmd58(); @@ -154,13 +153,14 @@ private: uint32_t _sd_sectors(); uint32_t _sectors; - DigitalOut _cs; uint32_t _init_sck; uint32_t _transfer_sck; SPI _spi; void _spi_init(); void _select(); void _deselect(); + + DigitalOut _cs; mutable Mutex _lock; unsigned _block_size;