AP_Logger_DataFlash.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. logging for block based dataflash devices on SPI
  3. */
  4. #pragma once
  5. #include <AP_HAL/AP_HAL.h>
  6. #ifdef HAL_LOGGING_DATAFLASH
  7. #include "AP_Logger_Backend.h"
  8. #include "AP_Logger_Block.h"
  9. class AP_Logger_DataFlash : public AP_Logger_Block {
  10. public:
  11. AP_Logger_DataFlash(AP_Logger &front, LoggerMessageWriter_DFLogStart *writer) :
  12. AP_Logger_Block(front, writer) {}
  13. void Init(void) override;
  14. bool CardInserted() const override { return !flash_died && df_NumPages > 0; }
  15. private:
  16. void BufferToPage(uint32_t PageAdr) override;
  17. void PageToBuffer(uint32_t PageAdr) override;
  18. void SectorErase(uint32_t SectorAdr) override;
  19. void StartErase() override;
  20. bool InErase() override;
  21. void send_command_addr(uint8_t cmd, uint32_t address);
  22. void WaitReady();
  23. bool Busy();
  24. uint8_t ReadStatusReg();
  25. void Enter4ByteAddressMode(void);
  26. void WriteEnable();
  27. bool getSectorCount(void);
  28. void flash_test(void);
  29. AP_HAL::OwnPtr<AP_HAL::SPIDevice> dev;
  30. AP_HAL::Semaphore *dev_sem;
  31. bool flash_died;
  32. uint32_t erase_start_ms;
  33. uint8_t erase_cmd;
  34. bool use_32bit_address;
  35. };
  36. #endif // HAL_LOGGING_DATAFLASH