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