|
|
|
@ -22,7 +22,6 @@
@@ -22,7 +22,6 @@
|
|
|
|
|
#include "StorageManager.h" |
|
|
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h> |
|
|
|
|
#include <AP_Progmem/AP_Progmem.h> |
|
|
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal; |
|
|
|
|
|
|
|
|
@ -94,8 +93,8 @@ void StorageManager::erase(void)
@@ -94,8 +93,8 @@ void StorageManager::erase(void)
|
|
|
|
|
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 = pgm_read_word(&area.length); |
|
|
|
|
uint16_t offset = pgm_read_word(&area.offset); |
|
|
|
|
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) { |
|
|
|
@ -117,8 +116,8 @@ StorageAccess::StorageAccess(StorageManager::StorageType _type) :
@@ -117,8 +116,8 @@ StorageAccess::StorageAccess(StorageManager::StorageType _type) :
|
|
|
|
|
total_size = 0; |
|
|
|
|
for (uint8_t i=0; i<STORAGE_NUM_AREAS; i++) { |
|
|
|
|
const StorageManager::StorageArea &area = StorageManager::layout[i]; |
|
|
|
|
if (pgm_read_byte(&area.type) == type) { |
|
|
|
|
total_size += pgm_read_word(&area.length); |
|
|
|
|
if (area.type == type) { |
|
|
|
|
total_size += area.length; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -132,9 +131,9 @@ bool StorageAccess::read_block(void *data, uint16_t addr, size_t n) const
@@ -132,9 +131,9 @@ bool StorageAccess::read_block(void *data, uint16_t addr, size_t n) const
|
|
|
|
|
uint8_t *b = (uint8_t *)data; |
|
|
|
|
for (uint8_t i=0; i<STORAGE_NUM_AREAS; i++) { |
|
|
|
|
const StorageManager::StorageArea &area = StorageManager::layout[i]; |
|
|
|
|
uint16_t length = pgm_read_word(&area.length); |
|
|
|
|
uint16_t offset = pgm_read_word(&area.offset); |
|
|
|
|
if (pgm_read_byte(&area.type) != type) { |
|
|
|
|
uint16_t length = area.length; |
|
|
|
|
uint16_t offset = area.offset; |
|
|
|
|
if (area.type != type) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (addr >= length) { |
|
|
|
@ -172,9 +171,9 @@ bool StorageAccess::write_block(uint16_t addr, const void *data, size_t n) const
@@ -172,9 +171,9 @@ bool StorageAccess::write_block(uint16_t addr, const void *data, size_t n) const
|
|
|
|
|
const uint8_t *b = (const uint8_t *)data; |
|
|
|
|
for (uint8_t i=0; i<STORAGE_NUM_AREAS; i++) { |
|
|
|
|
const StorageManager::StorageArea &area = StorageManager::layout[i]; |
|
|
|
|
uint16_t length = pgm_read_word(&area.length); |
|
|
|
|
uint16_t offset = pgm_read_word(&area.offset); |
|
|
|
|
if (pgm_read_byte(&area.type) != type) { |
|
|
|
|
uint16_t length = area.length; |
|
|
|
|
uint16_t offset = area.offset; |
|
|
|
|
if (area.type != type) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (addr >= length) { |
|
|
|
|