StorageManager: use hal.storage->erase()

This commit is contained in:
Andrew Tridgell 2019-12-27 11:44:30 +11:00 committed by Randy Mackay
parent 3ace15b04e
commit 4eb5e5e8d4

View File

@ -21,6 +21,7 @@
#include <AP_HAL/AP_HAL.h>
#include "StorageManager.h"
#include <stdio.h>
extern const AP_HAL::HAL& hal;
@ -110,21 +111,9 @@ const StorageManager::StorageArea *StorageManager::layout = layout_default;
*/
void StorageManager::erase(void)
{
uint8_t blk[16];
memset(blk, 0, sizeof(blk));
for (uint8_t i=0; i<STORAGE_NUM_AREAS; i++) {
const StorageManager::StorageArea &area = StorageManager::layout[i];
uint16_t length = area.length;
uint16_t offset = area.offset;
for (uint16_t ofs=0; ofs<length; ofs += sizeof(blk)) {
uint8_t n = 16;
if (ofs + n > length) {
n = length - ofs;
if (!hal.storage->erase()) {
::printf("StorageManager: erase failed\n");
}
hal.storage->write_block(offset + ofs, blk, n);
}
}
}
/*