flash_storage.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. *
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2022-01-29 supperthomas first version
  8. *
  9. */
  10. #include <stdint.h>
  11. /**
  12. * @brief initialize of flash storage
  13. *
  14. */
  15. void fstorage_init(void);
  16. /**
  17. * @brief read data from flash
  18. *
  19. * @param addr read address from flash
  20. * @param read_len length of data to read
  21. * @param p_data point to read buf
  22. * @return read length is success, other is error
  23. */
  24. int fstorage_read(uint32_t addr, uint32_t read_len, void *p_data);
  25. /**
  26. * @brief write data to flash, must erase before write
  27. *
  28. * @param addr write address in flash
  29. * @param write_len length of data to write
  30. * @param p_data point to write buf
  31. * @return write length is success, other is error
  32. */
  33. int fstorage_write(uint32_t addr, uint32_t write_len, void const *p_data);
  34. /**
  35. * @brief erase one page
  36. *
  37. * @param addr address must align to page. For example, one page is 4096 bytes,
  38. * you want to erase address 0x1020, you should set address 0x1000
  39. * @return 0 is succcess, other is error
  40. */
  41. int fstorage_erase(uint32_t addr);