diff --git a/src/knx/memory.cpp b/src/knx/memory.cpp index 5d33148..c7bdd00 100644 --- a/src/knx/memory.cpp +++ b/src/knx/memory.cpp @@ -127,7 +127,7 @@ void Memory::readMemory() void Memory::writeMemory() { // first get the necessary size of the writeBuffer - size_t writeBufferSize = _metadataSize; + uint16_t writeBufferSize = _metadataSize; for (int i = 0; i < _saveCount; i++) writeBufferSize = MAX(writeBufferSize, _saveRestores[i]->saveSize()); diff --git a/src/knx/platform.cpp b/src/knx/platform.cpp index a66a341..3c2a74e 100644 --- a/src/knx/platform.cpp +++ b/src/knx/platform.cpp @@ -181,8 +181,8 @@ uint32_t Platform::writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buf uint32_t start = _bufferedEraseblockNumber * (flashEraseBlockSize() * flashPageSize()); uint32_t end = start + (flashEraseBlockSize() * flashPageSize()); - ptrdiff_t offset = relativeAddress - start; - ptrdiff_t length = end - relativeAddress; + uint32_t offset = relativeAddress - start; + uint32_t length = end - relativeAddress; if(length > size) length = size; memcpy(_eraseblockBuffer + offset, buffer, length); @@ -227,7 +227,7 @@ void Platform::writeBufferedEraseBlock() if(_bufferedEraseblockNumber > -1 && _bufferedEraseblockDirty) { flashErase(_bufferedEraseblockNumber); - for(int i = 0; i < flashEraseBlockSize(); i++) + for(uint32_t i = 0; i < flashEraseBlockSize(); i++) { int32_t pageNumber = _bufferedEraseblockNumber * flashEraseBlockSize() + i; uint8_t *data = _eraseblockBuffer + flashPageSize() * i; @@ -238,7 +238,7 @@ void Platform::writeBufferedEraseBlock() } -void Platform::bufferEraseBlock(uint32_t eraseBlockNumber) +void Platform::bufferEraseBlock(int32_t eraseBlockNumber) { if(_bufferedEraseblockNumber == eraseBlockNumber) return; diff --git a/src/knx/platform.h b/src/knx/platform.h index 2aaf758..21a2867 100644 --- a/src/knx/platform.h +++ b/src/knx/platform.h @@ -104,7 +104,7 @@ class Platform // writes _eraseblockBuffer to flash virtual void writeBufferedEraseBlock(); // copies a EraseBlock into the _eraseblockBuffer - void bufferEraseBlock(uint32_t eraseBlockNumber); + void bufferEraseBlock(int32_t eraseBlockNumber); // in theory we would have to use this buffer for memory reads too, // but because ets always restarts the device after programming it diff --git a/src/knx/table_object.cpp b/src/knx/table_object.cpp index 1f670a9..90e6624 100644 --- a/src/knx/table_object.cpp +++ b/src/knx/table_object.cpp @@ -110,7 +110,7 @@ bool TableObject::allocTable(uint32_t size, bool doFill, uint8_t fillByte) if (doFill) { uint32_t addr = _memory.toRelative(_data); - for(int i = 0; i< size;i++) + for(uint32_t i = 0; i < size;i++) _memory.writeMemory(addr+i, 1, &fillByte); } diff --git a/src/rp2040_arduino_platform.cpp b/src/rp2040_arduino_platform.cpp index 7392223..0374e85 100644 --- a/src/rp2040_arduino_platform.cpp +++ b/src/rp2040_arduino_platform.cpp @@ -35,6 +35,7 @@ A RAM-buffered Flash can be use by defining USE_RP2040_LARGE_EEPROM_EMULATION #define FLASHPTR ((uint8_t*)XIP_BASE + KNX_FLASH_OFFSET) +#ifndef USE_RP2040_EEPROM_EMULATION #if KNX_FLASH_SIZE%4096 #error "KNX_FLASH_SIZE must be multiple of 4096" #endif @@ -42,6 +43,7 @@ A RAM-buffered Flash can be use by defining USE_RP2040_LARGE_EEPROM_EMULATION #if KNX_FLASH_OFFSET%4096 #error "KNX_FLASH_OFFSET must be multiple of 4096" #endif +#endif #ifndef KNX_SERIAL #define KNX_SERIAL Serial1 diff --git a/src/rp2040_arduino_platform.h b/src/rp2040_arduino_platform.h index 8a9e7f3..77a8736 100644 --- a/src/rp2040_arduino_platform.h +++ b/src/rp2040_arduino_platform.h @@ -4,10 +4,12 @@ #ifdef ARDUINO_ARCH_RP2040 +#ifndef USE_RP2040_EEPROM_EMULATION #ifndef KNX_FLASH_OFFSET #define KNX_FLASH_OFFSET 0x180000 // 1.5MiB #pragma warning "KNX_FLASH_OFFSET not defined, using 0x180000" #endif +#endif #ifdef USE_RP2040_LARGE_EEPROM_EMULATION #define USE_RP2040_EEPROM_EMULATION