Flash_Access.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _Flash_Access_H_
  14. #define _Flash_Access_H_
  15. #include "esp_err.h"
  16. /**
  17. * @brief Universal flash access interface class
  18. *
  19. */
  20. class Flash_Access
  21. {
  22. public:
  23. virtual size_t chip_size() = 0;
  24. virtual esp_err_t erase_sector(size_t sector) = 0;
  25. virtual esp_err_t erase_range(size_t start_address, size_t size) = 0;
  26. virtual esp_err_t write(size_t dest_addr, const void *src, size_t size) = 0;
  27. virtual esp_err_t read(size_t src_addr, void *dest, size_t size) = 0;
  28. virtual size_t sector_size() = 0;
  29. virtual esp_err_t flush()
  30. {
  31. return ESP_OK;
  32. };
  33. virtual ~Flash_Access() {};
  34. };
  35. #endif // _Flash_Access_H_