2021-05-18 09:23:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
/** Get flash base address
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return pointer to flash base
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_base();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get flash read block size
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return size in bytes
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_read_block_size();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get flash write block size
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return size in bytes
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_write_block_size();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get flash page size
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return size in bytes
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_page_size();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get expected flash cycles count
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return count of erase-write operations
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_cycles_count();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get free flash start address
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return pointer to free region start
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
const void* furi_hal_flash_get_free_start_address();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get free flash end address
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return pointer to free region end
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
const void* furi_hal_flash_get_free_end_address();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get first free page start address
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return first free page memory address
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_free_page_start_address();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
|
|
|
/** Get free page count
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return free page count
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
size_t furi_hal_flash_get_free_page_count();
|
2021-05-18 09:23:14 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Erase Flash
|
|
|
|
*
|
2021-11-10 09:53:00 +00:00
|
|
|
* @warning locking operation with critical section, stales execution
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
2021-11-10 09:53:00 +00:00
|
|
|
* @param page The page to erase
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return true on success
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-11-10 09:53:00 +00:00
|
|
|
bool furi_hal_flash_erase(uint8_t page);
|
2021-05-18 09:23:14 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Write double word (64 bits)
|
|
|
|
*
|
2021-11-10 09:53:00 +00:00
|
|
|
* @warning locking operation with critical section, stales execution
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param address destination address, must be double word aligned.
|
|
|
|
* @param data data to write
|
|
|
|
*
|
|
|
|
* @return true on success
|
2021-05-18 09:23:14 +00:00
|
|
|
*/
|
2021-08-08 18:03:25 +00:00
|
|
|
bool furi_hal_flash_write_dword(size_t address, uint64_t data);
|