AP_HAL_AVR: Dataflash instances stubbed out based on /libraries/DataFlash

This commit is contained in:
Pat Hickey 2012-08-31 13:12:39 -07:00 committed by Andrew Tridgell
parent 34ec5081e2
commit 9beba972c8
5 changed files with 208 additions and 9 deletions

View File

@ -10,6 +10,7 @@ namespace AP_HAL_AVR {
class ArduinoSPIDriver;
class ArduinoAnalogIn;
class AVREEPROMStorage;
class CommonDataflash;
class APM1Dataflash;
class APM2Dataflash;
class ArduinoGPIO;

View File

@ -5,20 +5,88 @@
#include <AP_HAL.h>
#include "AP_HAL_AVR_Namespace.h"
class AP_HAL_AVR::APM1Dataflash : public AP_HAL::Dataflash {
/* CommonDataflash: A partial concrete class providing the common
* implementations for most of the AP_HAL::Dataflash methods. */
class AP_HAL_AVR::CommonDataflash : public AP_HAL::Dataflash {
public:
APM1Dataflash() : _init(0) {}
void init(int machtnicht) { _init = 1; }
private:
int _init;
/* Implementation-specific public methods (re-exported from AP_Dataflash) */
virtual void init(void *implspecific) = 0;
virtual void read_mfg_id() = 0;
virtual bool media_present() = 0;
virtual uint16_t num_pages() = 0;
/* Concrete public methods: */
uint16_t get_page() { return _read_page_addr - 1; }
uint16_t get_write_page() { return _page_addr; }
void erase_all();
bool need_erase();
void start_write(int16_t page);
void finish_write();
void write_byte(uint8_t data);
void write_word(uint16_t data);
void write_dword(uint32_t data);
void start_read(int16_t page);
uint8_t read_byte();
uint16_t read_word();
uint32_t read_dword();
void set_file(uint16_t filenum);
uint16_t get_file() { return _file_num; }
uint16_t get_file_page() { return _file_page; }
int16_t find_last_log();
void get_log_boundaries(uint8_t log,
int16_t &startpage, int16_t &endpage);
uint8_t get_num_logs();
void start_new_log();
protected:
/* Implementation-specific private methods: */
virtual void _wait_ready() = 0;
virtual void _page_to_buffer(uint8_t buffer_num, uint16_t page_addr) = 0;
uint8_t _buffer_num;
uint8_t _read_buffer_num;
uint16_t _buffer_idx;
uint16_t _read_buffer_idx;
uint16_t _page_addr;
uint16_t _read_page_addr;
uint8_t _stop_write;
uint16_t _file_num;
uint16_t _file_page;
uint8_t _mfg;
uint16_t _device;
uint16_t _page_size;
};
class AP_HAL_AVR::APM2Dataflash : public AP_HAL::Dataflash {
/* APM1Dataflash and APM2Dataflash: fully concrete classes implementing
* the remaining methods left virtual by CommonDataflash.
*/
class AP_HAL_AVR::APM1Dataflash : public AP_HAL_AVR::CommonDataflash {
public:
APM2Dataflash() : _init(0) {}
void init(int machtnicht) { _init = 2; }
void init(void* machtnichts);
void read_mfg_id();
bool media_present();
uint16_t num_pages();
private:
int _init;
void _wait_ready();
void _page_to_buffer(uint8_t buffer_num, uint16_t page_addr);
};
class AP_HAL_AVR::APM2Dataflash : public AP_HAL_AVR::CommonDataflash {
public:
void init(void* machtnichts);
void read_mfg_id();
bool media_present();
uint16_t num_pages();
private:
void _wait_ready();
void _page_to_buffer(uint8_t buffer_num, uint16_t page_addr);
};
#endif // __AP_HAL_AVR_DATAFLASH_H__

View File

@ -0,0 +1,30 @@
#include "Dataflash.h"
using namespace AP_HAL_AVR;
void APM1Dataflash::init(void* machtnichts) {
}
void APM1Dataflash::read_mfg_id() {
}
bool APM1Dataflash::media_present() {
}
uint16_t APM1Dataflash::num_pages() {
}
void APM1Dataflash::_wait_ready() {
}
void APM1Dataflash::_page_to_buffer(uint8_t buffer_num, uint16_t page_addr) {
}

View File

@ -0,0 +1,30 @@
#include "Dataflash.h"
using namespace AP_HAL_AVR;
void APM2Dataflash::init(void* machtnichts) {
}
void APM2Dataflash::read_mfg_id() {
}
bool APM2Dataflash::media_present() {
}
uint16_t APM2Dataflash::num_pages() {
}
void APM2Dataflash::_wait_ready() {
}
void APM2Dataflash::_page_to_buffer(uint8_t buffer_num, uint16_t page_addr) {
}

View File

@ -0,0 +1,70 @@
#include "Dataflash.h"
using namespace AP_HAL_AVR;
void CommonDataflash::erase_all() {
}
bool CommonDataflash::need_erase() {
}
void CommonDataflash::start_write(int16_t page) {
}
void CommonDataflash::finish_write() {
}
void CommonDataflash::write_byte(uint8_t data) {
}
void CommonDataflash::write_word(uint16_t data) {
}
void CommonDataflash::write_dword(uint32_t data) {
}
void CommonDataflash::start_read(int16_t page) {
}
uint8_t CommonDataflash::read_byte() {
}
uint16_t CommonDataflash::read_word() {
}
uint32_t CommonDataflash::read_dword() {
}
void CommonDataflash::set_file(uint16_t filenum) {
}
int16_t CommonDataflash::find_last_log() {
}
void CommonDataflash::get_log_boundaries(uint8_t log,
int16_t &startpage, int16_t &endpage) {
}
uint8_t CommonDataflash::get_num_logs() {
}
void CommonDataflash::start_new_log() {
}