Code: Select all
static inline flash_error_t stm32_flash_check_errors(EFlashDriver *eflp) {
uint32_t sr = eflp->flash->SR;
/* Clearing error conditions.*/
eflp->flash->SR = sr & 0x0000FFFFU;
/* Some errors are only caught by assertion.*/
osalDbgAssert((sr & (FLASH_SR_FASTERR |
FLASH_SR_MISERR |
FLASH_SR_SIZERR)) == 0U, "unexpected flash error");
/* Decoding relevant errors.*/
if ((sr & FLASH_SR_WRPERR) != 0U) {
return FLASH_ERROR_HW_FAILURE;
}
if ((sr & (FLASH_SR_PGAERR | FLASH_SR_PROGERR | FLASH_SR_OPERR)) != 0U) {
return eflp->state == FLASH_PGM ? FLASH_ERROR_PROGRAM : FLASH_ERROR_ERASE;
}
return FLASH_NO_ERROR;
}
On here it returns FLASH_ERROR_PROGRAM at last if condition since the sr value is 168 which means my flash status registers' Bit 3 PROGERR, Bit 5 PGAERR and Bit 7 PGSERR are 1.
Am I using the mfsWriteRecord() function wrong? From what I understand from the documentation I just need to give unique id values for each different record. And of course, this id must be between 1 and MFS_CFG_MAX_RECORDS (32).