mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 09:28:31 -04:00
AP_HAL: added erase() method to Storage class
This commit is contained in:
parent
2b717a19ab
commit
3ace15b04e
17
libraries/AP_HAL/Storage.cpp
Normal file
17
libraries/AP_HAL/Storage.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "AP_HAL.h"
|
||||||
|
#include "Storage.h"
|
||||||
|
#include <AP_Math/AP_Math.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
default erase method
|
||||||
|
*/
|
||||||
|
bool AP_HAL::Storage::erase(void)
|
||||||
|
{
|
||||||
|
uint8_t blk[16] {};
|
||||||
|
uint32_t ofs;
|
||||||
|
for (ofs=0; ofs<HAL_STORAGE_SIZE; ofs += sizeof(blk)) {
|
||||||
|
uint32_t n = MIN(sizeof(blk), HAL_STORAGE_SIZE - ofs);
|
||||||
|
write_block(ofs, blk, n);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
class AP_HAL::Storage {
|
class AP_HAL::Storage {
|
||||||
public:
|
public:
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
virtual bool erase();
|
||||||
virtual void read_block(void *dst, uint16_t src, size_t n) = 0;
|
virtual void read_block(void *dst, uint16_t src, size_t n) = 0;
|
||||||
virtual void write_block(uint16_t dst, const void* src, size_t n) = 0;
|
virtual void write_block(uint16_t dst, const void* src, size_t n) = 0;
|
||||||
virtual void _timer_tick(void) {};
|
virtual void _timer_tick(void) {};
|
||||||
|
Loading…
Reference in New Issue
Block a user