Flash.h 906 B

1234567891011121314151617181920212223
  1. #pragma once
  2. #include <AP_HAL/AP_HAL.h>
  3. #include "AP_HAL_ChibiOS_Namespace.h"
  4. #include "hwdef/common/flash.h"
  5. class ChibiOS::Flash : public AP_HAL::Flash {
  6. public:
  7. uint32_t getpageaddr(uint32_t page) override { return stm32_flash_getpageaddr(page); }
  8. uint32_t getpagesize(uint32_t page) override { return stm32_flash_getpagesize(page); }
  9. uint32_t getnumpages(void) override { return stm32_flash_getnumpages(); }
  10. bool erasepage(uint32_t page) override {
  11. WITH_SEMAPHORE(sem);
  12. return stm32_flash_erasepage(page); }
  13. bool write(uint32_t addr, const void *buf, uint32_t count) override {
  14. WITH_SEMAPHORE(sem);
  15. return stm32_flash_write(addr, buf, count); }
  16. void keep_unlocked(bool set) override { stm32_flash_keep_unlocked(set); }
  17. bool ispageerased(uint32_t page) override { return stm32_flash_ispageerased(page); }
  18. private:
  19. HAL_Semaphore sem;
  20. };