Skip to content

Commit d0d47dc

Browse files
authored
Merge pull request #2 from ARMmbed/david_get_erase_size_overload
Implement the get_erase_size API (based on address)
2 parents 179e915 + 5418b0b commit d0d47dc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

FlashIAPBlockDevice.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ bd_size_t FlashIAPBlockDevice::get_erase_size() const
151151
return erase_size;
152152
}
153153

154+
bd_size_t FlashIAPBlockDevice::get_erase_size(bd_addr_t addr) const
155+
{
156+
uint32_t erase_size = _flash.get_sector_size(_base + addr);
157+
158+
DEBUG_PRINTF("get_erase_size: %" PRIX32 "\r\n", erase_size);
159+
160+
return erase_size;
161+
}
162+
154163
bd_size_t FlashIAPBlockDevice::size() const
155164
{
156165
DEBUG_PRINTF("size: %" PRIX64 "\r\n", _size);

FlashIAPBlockDevice.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ class FlashIAPBlockDevice : public BlockDevice {
110110
*/
111111
virtual bd_size_t get_erase_size() const;
112112

113+
/** Get the size of an erasable block given address
114+
*
115+
* @param addr Address within the erasable block
116+
* @return Size of an erasable block in bytes
117+
* @note Must be a multiple of the program size
118+
*/
119+
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
120+
113121
/** Get the total size of the underlying device
114122
*
115123
* @return Size of the underlying device in bytes

0 commit comments

Comments
 (0)