Fix writeBytes length

Credit to wilsynet
This commit is contained in:
Felix Rusu 2014-06-30 11:25:09 -04:00
parent 0370bec69d
commit 7c4424e08e
2 changed files with 4 additions and 4 deletions

View File

@ -176,12 +176,12 @@ void SPIFlash::writeByte(long addr, uint8_t byt) {
/// WARNING: if you write beyond a page boundary (or more than 256bytes), /// WARNING: if you write beyond a page boundary (or more than 256bytes),
/// the bytes will wrap around and start overwriting at the beginning of that same page /// the bytes will wrap around and start overwriting at the beginning of that same page
/// see datasheet for more details /// see datasheet for more details
void SPIFlash::writeBytes(long addr, const void* buf, uint8_t len) { void SPIFlash::writeBytes(long addr, const void* buf, uint16_t len) {
command(SPIFLASH_BYTEPAGEPROGRAM, true); // Byte/Page Program command(SPIFLASH_BYTEPAGEPROGRAM, true); // Byte/Page Program
SPI.transfer(addr >> 16); SPI.transfer(addr >> 16);
SPI.transfer(addr >> 8); SPI.transfer(addr >> 8);
SPI.transfer(addr); SPI.transfer(addr);
for (uint8_t i = 0; i < len; i++) for (uint16_t i = 0; i < len; i++)
SPI.transfer(((byte*) buf)[i]); SPI.transfer(((byte*) buf)[i]);
unselect(); unselect();
} }

View File

@ -77,7 +77,7 @@ public:
byte readByte(long addr); byte readByte(long addr);
void readBytes(long addr, void* buf, word len); void readBytes(long addr, void* buf, word len);
void writeByte(long addr, byte byt); void writeByte(long addr, byte byt);
void writeBytes(long addr, const void* buf, byte len); void writeBytes(long addr, const void* buf, uint16_t len);
boolean busy(); boolean busy();
void chipErase(); void chipErase();
void blockErase4K(long address); void blockErase4K(long address);