AP_RAMTRON.h 813 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. driver for RAMTRON FRAM persistent memory devices
  3. */
  4. #pragma once
  5. #include <AP_Common/AP_Common.h>
  6. #include <AP_HAL/AP_HAL.h>
  7. class AP_RAMTRON {
  8. public:
  9. // initialise the driver
  10. bool init(void);
  11. // get size in bytes
  12. uint32_t get_size(void) const { return ramtron_ids[id].size_kbyte*1024UL; }
  13. // read from device
  14. bool read(uint32_t offset, uint8_t *buf, uint32_t size);
  15. // write to device
  16. bool write(uint32_t offset, const uint8_t *buf, uint32_t size);
  17. private:
  18. AP_HAL::OwnPtr<AP_HAL::SPIDevice> dev;
  19. struct ramtron_id {
  20. uint8_t id1, id2;
  21. uint16_t size_kbyte;
  22. uint8_t addrlen;
  23. };
  24. static const struct ramtron_id ramtron_ids[];
  25. uint8_t id;
  26. // send offset of transfer
  27. void send_offset(uint8_t cmd, uint32_t offset);
  28. };