From 6f3a342f6105813a6205875339cae9f374298704 Mon Sep 17 00:00:00 2001 From: David Saada Date: Wed, 4 Jul 2018 16:37:18 +0300 Subject: [PATCH] Implement the get_erase_size API (based on address) --- DataFlashBlockDevice.cpp | 7 +++++++ DataFlashBlockDevice.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/DataFlashBlockDevice.cpp b/DataFlashBlockDevice.cpp index e367b2d398..0d2309661a 100644 --- a/DataFlashBlockDevice.cpp +++ b/DataFlashBlockDevice.cpp @@ -446,6 +446,13 @@ bd_size_t DataFlashBlockDevice::get_erase_size() const return _block_size; } +bd_size_t DataFlashBlockDevice::get_erase_size(bd_addr_t addr) const +{ + DEBUG_PRINTF("erase size: %" PRIX16 "\r\n", _block_size); + + return _block_size; +} + bd_size_t DataFlashBlockDevice::size() const { DEBUG_PRINTF("device size: %" PRIX32 "\r\n", _device_size); diff --git a/DataFlashBlockDevice.h b/DataFlashBlockDevice.h index 31ced0c4d1..e73b40222f 100644 --- a/DataFlashBlockDevice.h +++ b/DataFlashBlockDevice.h @@ -139,6 +139,14 @@ public: */ virtual bd_size_t get_erase_size() const; + /** Get the size of an erasable block given address + * + * @param addr Address within the erasable block + * @return Size of an erasable block in bytes + * @note Must be a multiple of the program size + */ + virtual bd_size_t get_erase_size(bd_addr_t addr) const; + /** Get the total size of the underlying device * * @return Size of the underlying device in bytes