mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into mntm-dev
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
|
||||
#define TAG "FuriHalFlash"
|
||||
|
||||
#ifdef FLASH_OP_DEBUG
|
||||
#undef FURI_LOG_T
|
||||
#define FURI_LOG_T(...)
|
||||
#else
|
||||
#endif
|
||||
|
||||
#define FURI_HAL_CRITICAL_MSG "Critical flash operation fail"
|
||||
#define FURI_HAL_FLASH_READ_BLOCK (8U)
|
||||
#define FURI_HAL_FLASH_WRITE_BLOCK (8U)
|
||||
@@ -295,6 +301,7 @@ bool furi_hal_flash_wait_last_operation(uint32_t timeout) {
|
||||
}
|
||||
|
||||
void furi_hal_flash_erase(uint8_t page) {
|
||||
uint32_t op_stat = DWT->CYCCNT;
|
||||
furi_hal_flash_begin(true);
|
||||
|
||||
/* Ensure that controller state is valid */
|
||||
@@ -317,6 +324,12 @@ void furi_hal_flash_erase(uint8_t page) {
|
||||
furi_hal_flush_cache();
|
||||
|
||||
furi_hal_flash_end(true);
|
||||
op_stat = DWT->CYCCNT - op_stat;
|
||||
FURI_LOG_T(
|
||||
TAG,
|
||||
"erase took %lu clocks or %fus",
|
||||
op_stat,
|
||||
(double)((float)op_stat / (float)furi_hal_cortex_instructions_per_microsecond()));
|
||||
}
|
||||
|
||||
static inline void furi_hal_flash_write_dword_internal_nowait(size_t address, uint64_t* data) {
|
||||
@@ -339,6 +352,7 @@ static inline void furi_hal_flash_write_dword_internal(size_t address, uint64_t*
|
||||
}
|
||||
|
||||
void furi_hal_flash_write_dword(size_t address, uint64_t data) {
|
||||
uint32_t op_stat = DWT->CYCCNT;
|
||||
furi_hal_flash_begin(false);
|
||||
|
||||
/* Ensure that controller state is valid */
|
||||
@@ -361,6 +375,12 @@ void furi_hal_flash_write_dword(size_t address, uint64_t data) {
|
||||
|
||||
/* Wait for last operation to be completed */
|
||||
furi_check(furi_hal_flash_wait_last_operation(FURI_HAL_FLASH_TIMEOUT));
|
||||
op_stat = DWT->CYCCNT - op_stat;
|
||||
FURI_LOG_T(
|
||||
TAG,
|
||||
"write_dword took %lu clocks or %fus",
|
||||
op_stat,
|
||||
(double)((float)op_stat / (float)furi_hal_cortex_instructions_per_microsecond()));
|
||||
}
|
||||
|
||||
static size_t furi_hal_flash_get_page_address(uint8_t page) {
|
||||
@@ -373,6 +393,7 @@ void furi_hal_flash_program_page(const uint8_t page, const uint8_t* data, uint16
|
||||
|
||||
furi_hal_flash_erase(page);
|
||||
|
||||
uint32_t op_stat = DWT->CYCCNT;
|
||||
furi_hal_flash_begin(false);
|
||||
|
||||
furi_check(furi_hal_flash_wait_last_operation(FURI_HAL_FLASH_TIMEOUT));
|
||||
@@ -432,6 +453,12 @@ void furi_hal_flash_program_page(const uint8_t page, const uint8_t* data, uint16
|
||||
CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
|
||||
|
||||
furi_hal_flash_end(false);
|
||||
op_stat = DWT->CYCCNT - op_stat;
|
||||
FURI_LOG_T(
|
||||
TAG,
|
||||
"program_page took %lu clocks or %fus",
|
||||
op_stat,
|
||||
(double)((float)op_stat / (float)furi_hal_cortex_instructions_per_microsecond()));
|
||||
}
|
||||
|
||||
int16_t furi_hal_flash_get_page_number(size_t address) {
|
||||
|
||||
Reference in New Issue
Block a user