AP_HAL: added hal.flash driver

needed for semaphore
This commit is contained in:
Andrew Tridgell 2019-03-26 11:13:39 +11:00 committed by Randy Mackay
parent 2fbe6edf47
commit 608fd54f62
4 changed files with 24 additions and 1 deletions

View File

@ -18,6 +18,7 @@
#include "Semaphores.h"
#include "Util.h"
#include "OpticalFlow.h"
#include "Flash.h"
#if HAL_WITH_UAVCAN
#include "CAN.h"

View File

@ -33,6 +33,7 @@ namespace AP_HAL {
class CAN;
class Util;
class Flash;
/* Utility Classes */
class Print;

18
libraries/AP_HAL/Flash.h Normal file
View File

@ -0,0 +1,18 @@
/*
interface to flash read/write
*/
#pragma once
#include <stdint.h>
#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;
};

View File

@ -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