From f834bd607962b892f62d268c2d8fef4d46a11130 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 23 May 2022 18:00:25 +0200 Subject: [PATCH] k::d::storage::GD32Flash: Implement isSliceUninitialized() The `::isSliceUninitialized()` method is required by the Base flash driver class, but `GD32Flash` did not implement it. While the Base class does so, `GD32Flash` is subclassing `EEPROMClass`, rather than `storage::Base`, for historical and technical reasons. As such, we need to implement this method ourselves. We could probably use multiple inheritance, but I feel that would be more trouble than its worth. Signed-off-by: Gergely Nagy --- src/kaleidoscope/driver/storage/GD32Flash.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/kaleidoscope/driver/storage/GD32Flash.h b/src/kaleidoscope/driver/storage/GD32Flash.h index e06e0b7e..21614905 100644 --- a/src/kaleidoscope/driver/storage/GD32Flash.h +++ b/src/kaleidoscope/driver/storage/GD32Flash.h @@ -38,6 +38,14 @@ class GD32Flash : public EEPROMClass<_StorageProps::length> { void setup() { EEPROMClass<_StorageProps::length>::begin(); } + + 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