/** * \brief Inits the flash module * * @return driver API return code */ status_t flashinit(void) { status_t ret; // Store the driver APIs return code /* Install interrupt for Flash Command Complete event */ INT_SYS_InstallHandler(FTFC_IRQn, CCIF_Handler, (isr_t*) 0); INT_SYS_EnableIRQ(FTFC_IRQn); /* Enable global interrupt */ INT_SYS_EnableIRQGlobal(); /* Always initialize the driver before calling other functions */ ret = FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig); DEV_ASSERT(STATUS_SUCCESS == ret); /* Config FlexRAM as EEPROM if it is currently used as traditional RAM */ if (flashSSDConfig.EEESize == 0u) { /* Configure FlexRAM as EEPROM and FlexNVM as EEPROM backup region, * DEFlashPartition will be failed if the IFR region isn't blank. * Refer to the device document for valid EEPROM Data Size Code * and FlexNVM Partition Code. For example on S32K148: * - EEEDataSizeCode = 0x02u: EEPROM size = 4 Kbytes * - DEPartitionCode = 0x04u: EEPROM backup size = 64 Kbytes */ ret = FLASH_DRV_DEFlashPartition(&flashSSDConfig, 0x02u, 0x04u, 0x0u, false, true); DEV_ASSERT(STATUS_SUCCESS == ret); /* Re-initialize the driver to update the new EEPROM configuration */ ret = FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig); DEV_ASSERT(STATUS_SUCCESS == ret); /* Make FlexRAM available for EEPROM */ ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL); DEV_ASSERT(STATUS_SUCCESS == ret); } else /* FLexRAM is already configured as EEPROM */ { /* Make FlexRAM available for EEPROM, make sure that FlexNVM and FlexRAM * are already partitioned successfully before */ ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL); DEV_ASSERT(STATUS_SUCCESS == ret); } return ret; }