ardupilot/libraries/DataFlash/DataFlash_APM2.h

54 lines
2.0 KiB
C
Raw Normal View History

/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/* ************************************************************ */
2011-11-25 19:11:14 -04:00
/* DataFlash_APM2 Log library */
/* ************************************************************ */
2011-11-25 19:11:14 -04:00
#ifndef __DATAFLASH_APM2_H__
#define __DATAFLASH_APM2_H__
2012-12-08 00:24:06 -04:00
#include <AP_HAL.h>
#include "DataFlash.h"
class DataFlash_APM2 : public DataFlash_Block
{
private:
//Methods
void BufferToPage (uint8_t BufferNum, uint16_t PageAdr, uint8_t wait);
void PageToBuffer(uint8_t BufferNum, uint16_t PageAdr);
void WaitReady();
uint8_t ReadStatusReg();
uint8_t ReadStatus();
uint16_t PageSize();
// 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);
uint8_t BufferRead (uint8_t BufferNum, uint16_t IntPageAdr);
void PageErase (uint16_t PageAdr);
void BlockErase (uint16_t BlockAdr);
2012-12-08 00:24:06 -04:00
void ChipErase();
// take a semaphore safely
bool _sem_take(uint8_t timeout);
AP_HAL::SPIDeviceDriver* _spi;
AP_HAL::Semaphore* _spi_sem;
public:
void Init(const struct LogStructure *structure, uint8_t num_types);
void ReadManufacturerID();
bool CardInserted();
};
#endif