Encapsulate DFU Image buffering and writing into spi flash in DfuImage.

Add some const in SPI driver.
This commit is contained in:
JF
2020-06-01 18:32:46 +02:00
parent f6aa41c214
commit de822cc3a2
9 changed files with 137 additions and 99 deletions

View File

@@ -96,12 +96,12 @@ bool SpiNorFlash::EraseFailed() {
return (ReadSecurityRegister() & 0x40u) == 0x40u;
}
void SpiNorFlash::Write(uint32_t address, uint8_t *buffer, size_t size) {
void SpiNorFlash::Write(uint32_t address, const uint8_t *buffer, size_t size) {
static constexpr uint8_t cmdSize = 4;
size_t len = size;
uint32_t addr = address;
uint8_t* b = buffer;
const uint8_t* b = buffer;
while(len > 0) {
uint32_t pageLimit = (addr & ~(pageSize - 1u)) + pageSize;
uint32_t toWrite = pageLimit - addr > len ? len : pageLimit - addr;