mirror of https://github.com/ARMmbed/mbed-os.git
parent
456ac214a7
commit
0dde4f5597
|
@ -323,14 +323,14 @@ int USBHostMSD::disk_initialize() {
|
|||
return readCapacity();
|
||||
}
|
||||
|
||||
int USBHostMSD::disk_write(const uint8_t* buffer, uint32_t block_number, uint32_t count) {
|
||||
int USBHostMSD::disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count) {
|
||||
USB_DBG("FILESYSTEM: write block: %lld, count: %d", block_number, count);
|
||||
if (!disk_init) {
|
||||
disk_initialize();
|
||||
}
|
||||
if (!disk_init)
|
||||
return -1;
|
||||
for (uint32_t b = block_number; b < block_number + count; b++) {
|
||||
for (uint64_t b = block_number; b < block_number + count; b++) {
|
||||
if (dataTransfer((uint8_t*)buffer, b, 1, HOST_TO_DEVICE))
|
||||
return -1;
|
||||
buffer += 512;
|
||||
|
@ -338,14 +338,14 @@ int USBHostMSD::disk_write(const uint8_t* buffer, uint32_t block_number, uint32_
|
|||
return 0;
|
||||
}
|
||||
|
||||
int USBHostMSD::disk_read(uint8_t* buffer, uint32_t block_number, uint32_t count) {
|
||||
int USBHostMSD::disk_read(uint8_t* buffer, uint64_t block_number, uint8_t count) {
|
||||
USB_DBG("FILESYSTEM: read block: %lld, count: %d", block_number, count);
|
||||
if (!disk_init) {
|
||||
disk_initialize();
|
||||
}
|
||||
if (!disk_init)
|
||||
return -1;
|
||||
for (uint32_t b = block_number; b < block_number + count; b++) {
|
||||
for (uint64_t b = block_number; b < block_number + count; b++) {
|
||||
if (dataTransfer((uint8_t*)buffer, b, 1, DEVICE_TO_HOST))
|
||||
return -1;
|
||||
buffer += 512;
|
||||
|
@ -353,7 +353,7 @@ int USBHostMSD::disk_read(uint8_t* buffer, uint32_t block_number, uint32_t count
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t USBHostMSD::disk_sectors() {
|
||||
uint64_t USBHostMSD::disk_sectors() {
|
||||
USB_DBG("FILESYSTEM: sectors");
|
||||
if (!disk_init) {
|
||||
disk_initialize();
|
||||
|
|
|
@ -59,10 +59,10 @@ protected:
|
|||
// From FATFileSystem
|
||||
virtual int disk_initialize();
|
||||
virtual int disk_status() {return 0;};
|
||||
virtual int disk_read(uint8_t* buffer, uint32_t sector, uint32_t count);
|
||||
virtual int disk_write(const uint8_t* buffer, uint32_t sector, uint32_t count);
|
||||
virtual int disk_read(uint8_t* buffer, uint64_t sector, uint8_t count);
|
||||
virtual int disk_write(const uint8_t* buffer, uint64_t sector, uint8_t count);
|
||||
virtual int disk_sync() {return 0;};
|
||||
virtual uint32_t disk_sectors();
|
||||
virtual uint64_t disk_sectors();
|
||||
|
||||
private:
|
||||
USBHost * host;
|
||||
|
@ -104,7 +104,7 @@ private:
|
|||
int getMaxLun();
|
||||
|
||||
int blockSize;
|
||||
uint32_t blockCount;
|
||||
uint64_t blockCount;
|
||||
|
||||
int msd_intf;
|
||||
bool msd_device_found;
|
||||
|
|
|
@ -36,7 +36,7 @@ DRESULT disk_read (
|
|||
)
|
||||
{
|
||||
debug_if(FFS_DBG, "disk_read(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv);
|
||||
if (FATFileSystem::_ffs[pdrv]->disk_read(buff, sector, count))
|
||||
if (FATFileSystem::_ffs[pdrv]->disk_read((uint8_t*)buff, sector, count))
|
||||
return RES_PARERR;
|
||||
else
|
||||
return RES_OK;
|
||||
|
@ -51,7 +51,7 @@ DRESULT disk_write (
|
|||
)
|
||||
{
|
||||
debug_if(FFS_DBG, "disk_write(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv);
|
||||
if (FATFileSystem::_ffs[pdrv]->disk_write(buff, sector, count))
|
||||
if (FATFileSystem::_ffs[pdrv]->disk_write((uint8_t*)buff, sector, count))
|
||||
return RES_PARERR;
|
||||
else
|
||||
return RES_OK;
|
||||
|
|
|
@ -84,10 +84,10 @@ public:
|
|||
|
||||
virtual int disk_initialize() { return 0; }
|
||||
virtual int disk_status() { return 0; }
|
||||
virtual int disk_read(uint8_t * buffer, uint32_t sector, uint32_t count) = 0;
|
||||
virtual int disk_write(const uint8_t * buffer, uint32_t sector, uint32_t count) = 0;
|
||||
virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count) = 0;
|
||||
virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count) = 0;
|
||||
virtual int disk_sync() { return 0; }
|
||||
virtual uint32_t disk_sectors() = 0;
|
||||
virtual uint64_t disk_sectors() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -223,12 +223,12 @@ int SDFileSystem::disk_initialize() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDFileSystem::disk_write(const uint8_t* buffer, uint32_t block_number, uint32_t count) {
|
||||
int SDFileSystem::disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count) {
|
||||
if (!_is_initialized) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (uint32_t b = block_number; b < block_number + count; b++) {
|
||||
for (uint64_t b = block_number; b < block_number + count; b++) {
|
||||
// set write address for single block (CMD24)
|
||||
if (_cmd(24, b * cdv) != 0) {
|
||||
return 1;
|
||||
|
@ -242,12 +242,12 @@ int SDFileSystem::disk_write(const uint8_t* buffer, uint32_t block_number, uint3
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SDFileSystem::disk_read(uint8_t* buffer, uint32_t block_number, uint32_t count) {
|
||||
int SDFileSystem::disk_read(uint8_t* buffer, uint64_t block_number, uint8_t count) {
|
||||
if (!_is_initialized) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (uint32_t b = block_number; b < block_number + count; b++) {
|
||||
for (uint64_t b = block_number; b < block_number + count; b++) {
|
||||
// set read address for single block (CMD17)
|
||||
if (_cmd(17, b * cdv) != 0) {
|
||||
return 1;
|
||||
|
@ -271,7 +271,7 @@ int SDFileSystem::disk_status() {
|
|||
}
|
||||
|
||||
int SDFileSystem::disk_sync() { return 0; }
|
||||
uint32_t SDFileSystem::disk_sectors() { return _sectors; }
|
||||
uint64_t SDFileSystem::disk_sectors() { return _sectors; }
|
||||
|
||||
|
||||
// PRIVATE FUNCTIONS
|
||||
|
@ -443,11 +443,11 @@ static uint32_t ext_bits(unsigned char *data, int msb, int lsb) {
|
|||
return bits;
|
||||
}
|
||||
|
||||
uint32_t SDFileSystem::_sd_sectors() {
|
||||
uint64_t SDFileSystem::_sd_sectors() {
|
||||
uint32_t c_size, c_size_mult, read_bl_len;
|
||||
uint32_t block_len, mult, blocknr, capacity;
|
||||
uint32_t hc_c_size;
|
||||
uint32_t blocks;
|
||||
uint64_t blocks;
|
||||
|
||||
// CMD9, Response R2 (R1 byte + 16-byte block read)
|
||||
if (_cmdx(9, 0) != 0) {
|
||||
|
|
|
@ -54,10 +54,10 @@ public:
|
|||
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, 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_read(uint8_t* buffer, uint64_t block_number, uint8_t count);
|
||||
virtual int disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count);
|
||||
virtual int disk_sync();
|
||||
virtual uint32_t disk_sectors();
|
||||
virtual uint64_t disk_sectors();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -71,8 +71,8 @@ protected:
|
|||
|
||||
int _read(uint8_t * buffer, uint32_t length);
|
||||
int _write(const uint8_t *buffer, uint32_t length);
|
||||
uint32_t _sd_sectors();
|
||||
uint32_t _sectors;
|
||||
uint64_t _sd_sectors();
|
||||
uint64_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
|
||||
|
|
Loading…
Reference in New Issue