api-hal-flash.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. /** Get flash base address
  6. * @return pointer to flash base
  7. */
  8. size_t api_hal_flash_get_base();
  9. /** Get flash read block size
  10. * @return size in bytes
  11. */
  12. size_t api_hal_flash_get_read_block_size();
  13. /** Get flash write block size
  14. * @return size in bytes
  15. */
  16. size_t api_hal_flash_get_write_block_size();
  17. /** Get flash page size
  18. * @return size in bytes
  19. */
  20. size_t api_hal_flash_get_page_size();
  21. /** Get expected flash cycles count
  22. * @return count of erase-write operations
  23. */
  24. size_t api_hal_flash_get_cycles_count();
  25. /** Get free flash start address
  26. * @return pointer to free region start
  27. */
  28. const void* api_hal_flash_get_free_start_address();
  29. /** Get free flash end address
  30. * @return pointer to free region end
  31. */
  32. const void* api_hal_flash_get_free_end_address();
  33. /** Get first free page start address
  34. * @return first free page memory address
  35. */
  36. size_t api_hal_flash_get_free_page_start_address();
  37. /** Get free page count
  38. * @return free page count
  39. */
  40. size_t api_hal_flash_get_free_page_count();
  41. /*
  42. * Erase Flash
  43. * Locking operation, uses HSEM to manage shared access.
  44. * @param page, page number
  45. * @param count, page count to erase
  46. */
  47. bool api_hal_flash_erase(uint8_t page, uint8_t count);
  48. /*
  49. * Write double word (64 bits)
  50. * Locking operation, uses HSEM to manage shared access.
  51. * @param address - destination address, must be double word aligned.
  52. * @param data - data to write
  53. */
  54. bool api_hal_flash_write_dword(size_t address, uint64_t data);
  55. /*
  56. * Write double word (64 bits) from address
  57. * Locking operation, uses HSEM to manage shared access.
  58. * @param address - destination address, must be block aligned
  59. * @param source_address - source address
  60. */
  61. bool api_hal_flash_write_dword_from(size_t address, size_t source_address);