mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
Api Symbols: replace asserts with checks
merge ofw commit
This commit is contained in:
@@ -51,37 +51,37 @@
|
||||
/* Free flash space borders, exported by linker */
|
||||
extern const void __free_flash_start__;
|
||||
|
||||
size_t furi_hal_flash_get_base() {
|
||||
size_t furi_hal_flash_get_base(void) {
|
||||
return FLASH_BASE;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_read_block_size() {
|
||||
size_t furi_hal_flash_get_read_block_size(void) {
|
||||
return FURI_HAL_FLASH_READ_BLOCK;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_write_block_size() {
|
||||
size_t furi_hal_flash_get_write_block_size(void) {
|
||||
return FURI_HAL_FLASH_WRITE_BLOCK;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_page_size() {
|
||||
size_t furi_hal_flash_get_page_size(void) {
|
||||
return FURI_HAL_FLASH_PAGE_SIZE;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_cycles_count() {
|
||||
size_t furi_hal_flash_get_cycles_count(void) {
|
||||
return FURI_HAL_FLASH_CYCLES_COUNT;
|
||||
}
|
||||
|
||||
const void* furi_hal_flash_get_free_start_address() {
|
||||
const void* furi_hal_flash_get_free_start_address(void) {
|
||||
return &__free_flash_start__;
|
||||
}
|
||||
|
||||
const void* furi_hal_flash_get_free_end_address() {
|
||||
const void* furi_hal_flash_get_free_end_address(void) {
|
||||
uint32_t sfr_reg_val = READ_REG(FLASH->SFR);
|
||||
uint32_t sfsa = (READ_BIT(sfr_reg_val, FLASH_SFR_SFSA) >> FLASH_SFR_SFSA_Pos);
|
||||
return (const void*)((sfsa * FURI_HAL_FLASH_PAGE_SIZE) + FLASH_BASE);
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_free_page_start_address() {
|
||||
size_t furi_hal_flash_get_free_page_start_address(void) {
|
||||
size_t start = (size_t)furi_hal_flash_get_free_start_address();
|
||||
size_t page_start = start - start % FURI_HAL_FLASH_PAGE_SIZE;
|
||||
if(page_start != start) {
|
||||
@@ -90,13 +90,13 @@ size_t furi_hal_flash_get_free_page_start_address() {
|
||||
return page_start;
|
||||
}
|
||||
|
||||
size_t furi_hal_flash_get_free_page_count() {
|
||||
size_t furi_hal_flash_get_free_page_count(void) {
|
||||
size_t end = (size_t)furi_hal_flash_get_free_end_address();
|
||||
size_t page_start = (size_t)furi_hal_flash_get_free_page_start_address();
|
||||
return (end - page_start) / FURI_HAL_FLASH_PAGE_SIZE;
|
||||
}
|
||||
|
||||
void furi_hal_flash_init() {
|
||||
void furi_hal_flash_init(void) {
|
||||
/* Errata 2.2.9, Flash OPTVERR flag is always set after system reset */
|
||||
// WRITE_REG(FLASH->SR, FLASH_SR_OPTVERR);
|
||||
/* Actually, reset all error flags on start */
|
||||
@@ -106,7 +106,7 @@ void furi_hal_flash_init() {
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_flash_unlock() {
|
||||
static void furi_hal_flash_unlock(void) {
|
||||
/* verify Flash is locked */
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != 0U);
|
||||
|
||||
@@ -450,7 +450,7 @@ uint32_t furi_hal_flash_ob_get_word(size_t word_idx, bool complementary) {
|
||||
return ob_data[raw_word_idx];
|
||||
}
|
||||
|
||||
void furi_hal_flash_ob_unlock() {
|
||||
void furi_hal_flash_ob_unlock(void) {
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) != 0U);
|
||||
furi_hal_flash_begin(true);
|
||||
WRITE_REG(FLASH->OPTKEYR, FURI_HAL_FLASH_OPT_KEY1);
|
||||
@@ -460,7 +460,7 @@ void furi_hal_flash_ob_unlock() {
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) == 0U);
|
||||
}
|
||||
|
||||
void furi_hal_flash_ob_lock() {
|
||||
void furi_hal_flash_ob_lock(void) {
|
||||
furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) == 0U);
|
||||
SET_BIT(FLASH->CR, FLASH_CR_OPTLOCK);
|
||||
furi_hal_flash_end(true);
|
||||
@@ -511,7 +511,7 @@ static const FuriHalFlashObMapping furi_hal_flash_ob_reg_map[FURI_HAL_FLASH_OB_T
|
||||
};
|
||||
#undef OB_REG_DEF
|
||||
|
||||
void furi_hal_flash_ob_apply() {
|
||||
void furi_hal_flash_ob_apply(void) {
|
||||
furi_hal_flash_ob_unlock();
|
||||
/* OBL_LAUNCH: When set to 1, this bit forces the option byte reloading.
|
||||
* It cannot be written if OPTLOCK is set */
|
||||
@@ -558,6 +558,6 @@ bool furi_hal_flash_ob_set_word(size_t word_idx, const uint32_t value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr() {
|
||||
const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr(void) {
|
||||
return (const FuriHalFlashRawOptionByteData*)OPTION_BYTE_BASE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user