• Yes, it'd be a really good idea to get it in - this totally slipped off my radar.

    @Dennis, what do you think?

    IMO it'd be nice if read and write worked a bit like the AT24/AT25/DS2xxx modules though:

    flash.read(address,bytes)
    flash.write(address,data)
    

    Then at least users could choose different modules while using the same code - although obviously the eraseChip/erasePage stuff still needs to be exposed.

    I'd like to expose Espruino's internal flash memory somehow too, and it'd be nice to use the same API for that. As it's got variable size pages, I wonder whether something like this might work:

    flash.getPage(address) -> { start:address, end:address, size:int }
    flash.erasePage(address);
    

    In your case I guess:

    // assuming you can only erase blocks of 16 pages at once?
    
    Flash.prototype.getPage = function(address) {
      var pageSize = 256*16;
      return { start: address & ~(pageSize-1), size: pageSize }
    }
    
    Flash.prototype.erase16Pages = function(address) {
      var pageNumber = address >> 12; // 256*16
      // ...
    }
    

    That way it's relatively easy for code to see which page it needs to erase, and the same API should be transferrable to other flash memory.

About

Avatar for Gordon @Gordon started