2012-12-12 18:19:09 -04:00
|
|
|
/* ************************************************************ */
|
|
|
|
/* DataFlash_SITL Log library */
|
|
|
|
/* ************************************************************ */
|
|
|
|
#ifndef __DATAFLASH_SITL_H__
|
|
|
|
#define __DATAFLASH_SITL_H__
|
|
|
|
|
2015-05-04 03:17:39 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
2012-12-12 18:19:09 -04:00
|
|
|
|
2015-08-11 03:28:46 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2015-06-25 10:53:20 -03:00
|
|
|
#include "DataFlash_Block.h"
|
2012-12-12 18:19:09 -04:00
|
|
|
|
2013-02-23 03:52:30 -04:00
|
|
|
class DataFlash_SITL : public DataFlash_Block
|
2012-12-12 18:19:09 -04:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
//Methods
|
2013-02-23 03:52:30 -04:00
|
|
|
void BufferWrite (uint8_t BufferNum, uint16_t IntPageAdr, uint8_t Data);
|
|
|
|
void BufferToPage (uint8_t BufferNum, uint16_t PageAdr, uint8_t wait);
|
|
|
|
void PageToBuffer(uint8_t BufferNum, uint16_t PageAdr);
|
|
|
|
void WaitReady();
|
2012-12-12 18:19:09 -04:00
|
|
|
uint8_t ReadStatusReg();
|
|
|
|
uint8_t ReadStatus();
|
2013-02-23 03:52:30 -04:00
|
|
|
uint16_t PageSize();
|
|
|
|
void PageErase (uint16_t PageAdr);
|
|
|
|
void BlockErase (uint16_t BlockAdr);
|
|
|
|
void ChipErase();
|
2013-01-12 07:28:53 -04:00
|
|
|
|
|
|
|
// 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-12 18:19:09 -04:00
|
|
|
|
|
|
|
AP_HAL::SPIDeviceDriver *_spi;
|
|
|
|
AP_HAL::Semaphore *_spi_sem;
|
|
|
|
public:
|
2015-11-09 18:14:22 -04:00
|
|
|
DataFlash_SITL(DataFlash_Class &front, DFMessageWriter_DFLogStart *writer) :
|
|
|
|
DataFlash_Block(front, writer) { }
|
|
|
|
void Init() override;
|
2012-12-12 18:19:09 -04:00
|
|
|
void ReadManufacturerID();
|
|
|
|
bool CardInserted();
|
|
|
|
};
|
|
|
|
|
2015-05-04 03:17:39 -03:00
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
2012-12-12 18:19:09 -04:00
|
|
|
#endif // __DATAFLASH_SITL_H__
|