diff --git a/libraries/AP_HAL/AP_HAL.h b/libraries/AP_HAL/AP_HAL.h index e0d83acd12..4c22f4fbdd 100644 --- a/libraries/AP_HAL/AP_HAL.h +++ b/libraries/AP_HAL/AP_HAL.h @@ -18,6 +18,7 @@ #include "Semaphores.h" #include "Util.h" #include "OpticalFlow.h" +#include "Flash.h" #if HAL_WITH_UAVCAN #include "CAN.h" diff --git a/libraries/AP_HAL/AP_HAL_Namespace.h b/libraries/AP_HAL/AP_HAL_Namespace.h index 158e20c8da..b58a4258b3 100644 --- a/libraries/AP_HAL/AP_HAL_Namespace.h +++ b/libraries/AP_HAL/AP_HAL_Namespace.h @@ -33,6 +33,7 @@ namespace AP_HAL { class CAN; class Util; + class Flash; /* Utility Classes */ class Print; diff --git a/libraries/AP_HAL/Flash.h b/libraries/AP_HAL/Flash.h new file mode 100644 index 0000000000..7402afba76 --- /dev/null +++ b/libraries/AP_HAL/Flash.h @@ -0,0 +1,18 @@ +/* + interface to flash read/write + */ +#pragma once + +#include +#include "AP_HAL_Namespace.h" + +class AP_HAL::Flash { +public: + virtual uint32_t getpageaddr(uint32_t page) = 0; + virtual uint32_t getpagesize(uint32_t page) = 0; + virtual uint32_t getnumpages(void) = 0; + virtual bool erasepage(uint32_t page) = 0; + virtual bool write(uint32_t addr, const void *buf, uint32_t count) = 0; + virtual void keep_unlocked(bool set) = 0; + virtual bool ispageerased(uint32_t page) = 0; +}; diff --git a/libraries/AP_HAL/HAL.h b/libraries/AP_HAL/HAL.h index 1aaa233d79..5ed1274de6 100644 --- a/libraries/AP_HAL/HAL.h +++ b/libraries/AP_HAL/HAL.h @@ -43,6 +43,7 @@ public: AP_HAL::Scheduler* _scheduler, AP_HAL::Util* _util, AP_HAL::OpticalFlow *_opticalflow, + AP_HAL::Flash *_flash, #if HAL_WITH_UAVCAN AP_HAL::CANManager* _can_mgr[MAX_NUMBER_OF_CAN_DRIVERS]) #else @@ -66,7 +67,8 @@ public: rcout(_rcout), scheduler(_scheduler), util(_util), - opticalflow(_opticalflow) + opticalflow(_opticalflow), + flash(_flash) { #if HAL_WITH_UAVCAN if (_can_mgr == nullptr) { @@ -117,6 +119,7 @@ public: AP_HAL::Scheduler* scheduler; AP_HAL::Util *util; AP_HAL::OpticalFlow *opticalflow; + AP_HAL::Flash *flash; #if HAL_WITH_UAVCAN AP_HAL::CANManager* can_mgr[MAX_NUMBER_OF_CAN_DRIVERS]; #else