2019-01-18 18:45:36 -04:00
|
|
|
/*
|
|
|
|
logging for block based dataflash devices on SPI
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
|
|
|
|
#include "AP_Logger_Block.h"
|
|
|
|
|
2021-01-06 22:04:09 -04:00
|
|
|
#if HAL_LOGGING_DATAFLASH_ENABLED
|
2019-01-18 18:45:36 -04:00
|
|
|
|
|
|
|
class AP_Logger_DataFlash : public AP_Logger_Block {
|
|
|
|
public:
|
|
|
|
AP_Logger_DataFlash(AP_Logger &front, LoggerMessageWriter_DFLogStart *writer) :
|
|
|
|
AP_Logger_Block(front, writer) {}
|
2021-11-02 22:34:52 -03:00
|
|
|
static AP_Logger_Backend *probe(AP_Logger &front,
|
|
|
|
LoggerMessageWriter_DFLogStart *ls) {
|
|
|
|
return new AP_Logger_DataFlash(front, ls);
|
|
|
|
}
|
2019-01-18 18:45:36 -04:00
|
|
|
void Init(void) override;
|
|
|
|
bool CardInserted() const override { return !flash_died && df_NumPages > 0; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void BufferToPage(uint32_t PageAdr) override;
|
|
|
|
void PageToBuffer(uint32_t PageAdr) override;
|
|
|
|
void SectorErase(uint32_t SectorAdr) override;
|
2019-12-15 18:08:10 -04:00
|
|
|
void Sector4kErase(uint32_t SectorAdr) override;
|
2019-01-18 18:45:36 -04:00
|
|
|
void StartErase() override;
|
|
|
|
bool InErase() override;
|
|
|
|
void send_command_addr(uint8_t cmd, uint32_t address);
|
|
|
|
void WaitReady();
|
|
|
|
bool Busy();
|
|
|
|
uint8_t ReadStatusReg();
|
2019-10-03 11:58:13 -03:00
|
|
|
void Enter4ByteAddressMode(void);
|
|
|
|
|
2019-01-18 18:45:36 -04:00
|
|
|
void WriteEnable();
|
|
|
|
bool getSectorCount(void);
|
|
|
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::SPIDevice> dev;
|
|
|
|
AP_HAL::Semaphore *dev_sem;
|
|
|
|
|
|
|
|
bool flash_died;
|
|
|
|
uint32_t erase_start_ms;
|
|
|
|
uint8_t erase_cmd;
|
|
|
|
bool use_32bit_address;
|
2022-10-01 16:48:25 -03:00
|
|
|
bool read_cache_valid;
|
2019-01-18 18:45:36 -04:00
|
|
|
};
|
|
|
|
|
2021-01-06 22:04:09 -04:00
|
|
|
#endif // HAL_LOGGING_DATAFLASH_ENABLED
|