diff --git a/include/libopencm3/stm32/h7/flash.h b/include/libopencm3/stm32/h7/flash.h index 52b2c165e1..dc0c54f4b4 100644 --- a/include/libopencm3/stm32/h7/flash.h +++ b/include/libopencm3/stm32/h7/flash.h @@ -206,6 +206,8 @@ bool flash_is_busy(enum flash_bank bank); void flash_clear_eop_flag(enum flash_bank bank); /** Clear all status flags. */ void flash_clear_status_flags(enum flash_bank bank); +/** Get back the status flags for a bank. */ +uint32_t flash_get_status_flags(enum flash_bank bank); /** Wait until Last Operation has Ended. * This loops indefinitely until an operation (write or erase) has completed by * testing for EOP and nothing being left in the queue. diff --git a/lib/stm32/h7/flash.c b/lib/stm32/h7/flash.c index 42ea745ac4..fe8aff87d6 100644 --- a/lib/stm32/h7/flash.c +++ b/lib/stm32/h7/flash.c @@ -115,6 +115,12 @@ void flash_clear_status_flags(const enum flash_bank bank) REBASE(FLASH_CCR) = FLASH_SR_ERROR_MASK | FLASH_SR_EOP; } +uint32_t flash_get_status_flags(enum flash_bank bank) +{ + const uintptr_t bank_base_address = flash_bank_address(bank); + return REBASE(FLASH_SR) & FLASH_SR_ERROR_MASK; +} + bool flash_wait_for_last_operation(const enum flash_bank bank) { const uintptr_t bank_base_address = flash_bank_address(bank);