driver::storage: Fix isSliceUninitialized() for AVREEPROM

`kaleidoscope::driver::storage::AVREEPROM` wasn't implementing its own
`isSliceUninitialized()` method, and relied on the Base class to do so. However,
since we're not using `virtual` methods, the base class was using
`Base::read()` (which always returns 0) rather than `AVREEPROM::read()`, so
`isSliceUninitialized()` always returned false.

To fix this, we implement the function in `AVREEPROM`, and let the default
implementation in Base always return false.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/1196/head
Gergely Nagy 2 years ago
parent cb9ad9f753
commit 657d33450c
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -56,6 +56,14 @@ class AVREEPROM : public kaleidoscope::driver::storage::Base<_StorageProps> {
void update(int idx, uint8_t val) {
EEPROM.update(idx, val);
}
bool isSliceUninitialized(uint16_t offset, uint16_t size) {
for (uint16_t o = offset; o < offset + size; o++) {
if (this->read(o) != _StorageProps::uninitialized_byte)
return false;
}
return true;
}
};
} // namespace storage

@ -50,12 +50,8 @@ class Base {
void update(int idx, uint8_t val) {}
bool isSliceUninitialized(uint16_t offset, uint16_t size) {
for (uint16_t o = offset; o < offset + size; o++) {
if (read(o) != _StorageProps::uninitialized_byte)
return false;
}
return true;
}
const uint16_t length() {
return _StorageProps::length;

Loading…
Cancel
Save