I found this nice project which is perfect for me and work well with an SD card: FTPino - A FTP Client and Server for the Particle
But now I need something to do the same thing with the eeprom.
So I can use the flashee-eeprom library, support my chip IS25LQ080 which is compatible with W25Q80BV and I found a small adafruit library for it (but the code is very simple).
So my question now is how do I integrate a new library for my external eeprom in the flashee library.
I’m not good with c++ and all the classes.
I think the way to go would be to do the same thing as the SparkExternalFlashDevice but right now I dont know how to make this work…
I know this is not a big deal but I dont know how to do that… Here is my code and the error I get is:
undefined reference to `Flashee::Adafruit_TinyFlash::Adafruit_TinyFlash(unsigned char)’
#ifndef HAS_SERIAL_FLASH
#define HAS_SERIAL_FLASH
#define sFLASH_PAGESIZE (256)
#define sFLASH_PAGECOUNT (4096)
#endif
#elif defined(HAS_SERIAL_FLASH)
#endif
#include "Adafruit_TinyFlash.h"
#ifdef HAS_SERIAL_FLASH
class SparkExternalFlashDevice : public FlashDevice {
Adafruit_TinyFlash flash;
public:
SparkExternalFlashDevice()
{
uint8_t manID, devID;
flash.begin(&manID, &devID);
}
/**
* @return The size of each page in this flash device.
*/
virtual page_size_t pageSize() const {
return sFLASH_PAGESIZE;
}
/**
* @return The number of pages in this flash device.
*/
virtual page_count_t pageCount() const {
return sFLASH_PAGECOUNT;
}
virtual bool erasePage(flash_addr_t address) {
bool success = false;
if (address < pageAddress(pageCount()) && (address % pageSize()) == 0) {
//sFLASH_EraseSector(address);
success = flash.eraseSector(address);
//success = true;
}
return success;
}
/**
* Writes directly to the flash. Depending upon the state of the flash, the
* write may provide the data required or it may not.
* @param data
* @param address
* @param length
* @return
*/
virtual bool writePage(const void* data, flash_addr_t address, page_size_t length) {
// TODO: SPI interface shouldn't need mutable data buffer to write?
//sFLASH_WriteBuffer(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(data)), address, length);
while (length > 0)
{
flash.writePage(address, const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(data)));
address += sFLASH_PAGESIZE;
length -= sFLASH_PAGESIZE;
}
return true;
}
virtual bool readPage(void* data, flash_addr_t address, page_size_t length) const {
//sFLASH_ReadBuffer((uint8_t*)data, address, length);
//flash.readblock((uint8_t*)data, address, length);
page_size_t i;
uint8_t* _data = (uint8_t*)data;
flash.beginRead(address);
for(i = 0; i < length; i++)
{
_data[i] = flash.readNextByte();
}
flash.endRead();
return true;
}
/**
* Writes data to the flash memory, performing an erase beforehand if necessary
* to ensure the data is written correctly.
* @param data
* @param address
* @param length
* @return
*/
virtual bool writeErasePage(const void* data, flash_addr_t address, page_size_t length) {
return false;
}
/**
* Internally re-reorganizes the page's storage by passing the page contents via
* a buffer through a handler function and then writing the buffer back to
* memory.
*
* @param address
* @param handler
* @param data
* @param buf
* @param bufSize
* @return
*/
virtual bool copyPage(flash_addr_t address, TransferHandler handler, void* data, uint8_t* buf, page_size_t bufSize) {
return false;
}
};
#endif // HAS_SERIAL_FLASH
#endif // SPARK