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.
Dependencies: BaseDAP SWD USBDAP USBLocalFileSystem mbed DA14580 SWSPI W25X40BV
mystorage.cpp
00001 #include "mbed.h" 00002 #include "mystorage.h" 00003 #include "W25X40BV.h" 00004 00005 // MyStorage(PinName mosi, PinName miso, PinName sclk, PinName cs); 00006 MyStorage::MyStorage(PinName mosi, PinName miso, PinName sclk, PinName cs) : 00007 _flash(mosi, miso, sclk, cs) { 00008 } 00009 00010 // virtual int storage_read(uint8_t* data, uint32_t block); 00011 int MyStorage::storage_read(uint8_t *buffer, uint32_t block_number) { 00012 report_read_count++; 00013 00014 // receive the data 00015 // _read(buffer, 512); 00016 // _flash.readStream(uint32_t addr, uint8_t* buf, uint32_t count); 00017 _flash.readStream(256 * ((block_number) * 2), buffer, 512); 00018 return 0; 00019 } 00020 00021 // virtual int storage_write(const uint8_t* data, uint32_t block); 00022 int MyStorage::storage_write(const uint8_t *buffer, uint32_t block_number) { 00023 report_write_count++; 00024 00025 // send the data block 00026 // _write(buffer, 512); 00027 // writeStream(uint32_t addr, uint8_t* buf, uint32_t count); 00028 // void pageErase(uint8_t page); 00029 // _flash.pageErase((block_number) * 2); 00030 // _flash.pageErase((block_number) * 2 + 1); 00031 _flash.writeStream(512 * (block_number), (uint8_t*)buffer, 256); 00032 _flash.writeStream(512 * (block_number) + 256, (uint8_t*)(buffer + 256), 256); 00033 return 0; 00034 } 00035 00036 // virtual uint32_t storage_sectors(); 00037 uint32_t MyStorage::storage_sectors() { 00038 report_sectors_count++; 00039 return (256); //256*512 00040 } 00041 00042 // virtual uint32_t storage_size(); 00043 uint32_t MyStorage::storage_size() 00044 { 00045 report_size_count++; 00046 return (256*512); //256*512 00047 }
Generated on Mon Jul 25 2022 10:58:37 by
1.7.2