furi_hal_flash.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. /** Get flash base address
  6. *
  7. * @return pointer to flash base
  8. */
  9. size_t furi_hal_flash_get_base();
  10. /** Get flash read block size
  11. *
  12. * @return size in bytes
  13. */
  14. size_t furi_hal_flash_get_read_block_size();
  15. /** Get flash write block size
  16. *
  17. * @return size in bytes
  18. */
  19. size_t furi_hal_flash_get_write_block_size();
  20. /** Get flash page size
  21. *
  22. * @return size in bytes
  23. */
  24. size_t furi_hal_flash_get_page_size();
  25. /** Get expected flash cycles count
  26. *
  27. * @return count of erase-write operations
  28. */
  29. size_t furi_hal_flash_get_cycles_count();
  30. /** Get free flash start address
  31. *
  32. * @return pointer to free region start
  33. */
  34. const void* furi_hal_flash_get_free_start_address();
  35. /** Get free flash end address
  36. *
  37. * @return pointer to free region end
  38. */
  39. const void* furi_hal_flash_get_free_end_address();
  40. /** Get first free page start address
  41. *
  42. * @return first free page memory address
  43. */
  44. size_t furi_hal_flash_get_free_page_start_address();
  45. /** Get free page count
  46. *
  47. * @return free page count
  48. */
  49. size_t furi_hal_flash_get_free_page_count();
  50. /** Erase Flash
  51. *
  52. * @warning locking operation with critical section, stales execution
  53. *
  54. * @param page The page to erase
  55. *
  56. * @return true on success
  57. */
  58. bool furi_hal_flash_erase(uint8_t page);
  59. /** Write double word (64 bits)
  60. *
  61. * @warning locking operation with critical section, stales execution
  62. *
  63. * @param address destination address, must be double word aligned.
  64. * @param data data to write
  65. *
  66. * @return true on success
  67. */
  68. bool furi_hal_flash_write_dword(size_t address, uint64_t data);