2013-01-12 02:21:04 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2011-11-12 23:29:07 -04:00
|
|
|
/* ************************************************************ */
|
2012-11-10 02:02:16 -04:00
|
|
|
/* DataFlash_APM1 Log library */
|
2011-11-12 23:29:07 -04:00
|
|
|
/* ************************************************************ */
|
|
|
|
#ifndef __DATAFLASH_APM1_H__
|
|
|
|
#define __DATAFLASH_APM1_H__
|
|
|
|
|
2012-12-07 23:23:09 -04:00
|
|
|
#include <AP_HAL.h>
|
2011-11-12 23:29:07 -04:00
|
|
|
#include "DataFlash.h"
|
|
|
|
|
2013-02-23 03:52:30 -04:00
|
|
|
class DataFlash_APM1 : public DataFlash_Block
|
2011-11-12 23:29:07 -04:00
|
|
|
{
|
2012-08-17 03:21:26 -03:00
|
|
|
private:
|
|
|
|
//Methods
|
2013-01-12 02:21:04 -04:00
|
|
|
void BufferToPage (uint8_t BufferNum, uint16_t PageAdr, uint8_t wait);
|
|
|
|
void PageToBuffer(uint8_t BufferNum, uint16_t PageAdr);
|
|
|
|
void WaitReady();
|
2012-12-07 23:20:17 -04:00
|
|
|
uint8_t ReadStatusReg();
|
|
|
|
uint8_t ReadStatus();
|
2013-01-12 02:21:04 -04:00
|
|
|
uint16_t PageSize();
|
|
|
|
void PageErase (uint16_t PageAdr);
|
|
|
|
void BlockErase (uint16_t BlockAdr);
|
|
|
|
void ChipErase();
|
|
|
|
|
|
|
|
// write size bytes of data to a page. The caller must ensure that
|
|
|
|
// the data fits within the page, otherwise it will wrap to the
|
|
|
|
// start of the page
|
|
|
|
// If pHeader is not NULL then write the header bytes before the data
|
|
|
|
void BlockWrite(uint8_t BufferNum, uint16_t IntPageAdr,
|
|
|
|
const void *pHeader, uint8_t hdr_size,
|
|
|
|
const void *pBuffer, uint16_t size);
|
|
|
|
|
|
|
|
// read size bytes of data to a page. The caller must ensure that
|
|
|
|
// the data fits within the page, otherwise it will wrap to the
|
|
|
|
// start of the page
|
|
|
|
bool BlockRead(uint8_t BufferNum, uint16_t IntPageAdr,
|
|
|
|
void *pBuffer, uint16_t size);
|
2012-12-07 23:23:09 -04:00
|
|
|
|
|
|
|
AP_HAL::SPIDeviceDriver *_spi;
|
|
|
|
AP_HAL::Semaphore *_spi_sem;
|
2011-11-12 23:29:07 -04:00
|
|
|
|
2013-03-02 02:42:06 -04:00
|
|
|
// take a semaphore safely
|
|
|
|
bool _sem_take(uint8_t timeout);
|
|
|
|
|
2013-02-23 03:52:30 -04:00
|
|
|
public:
|
2013-12-16 20:12:42 -04:00
|
|
|
void Init(const struct LogStructure *structure, uint8_t num_types);
|
2012-08-17 03:21:26 -03:00
|
|
|
void ReadManufacturerID();
|
2012-11-10 02:02:16 -04:00
|
|
|
bool CardInserted();
|
2011-11-12 23:29:07 -04:00
|
|
|
};
|
|
|
|
|
2012-11-10 02:02:16 -04:00
|
|
|
#endif
|