u8 FLASH_EraseBank( u16* BankAddress ) { if ( ((u16)BankAddress >= 0x1800) && ((u16)BankAddress < (0x1A00)) ) { if (FLASH->CTL3 & 0x0040) { //FLASH->CTL3 |= 0x0040; } } return FLASH_Erase( (FLASH_CTL_MERAS), BankAddress ); }
u8 FLASH_EraseSegment( u16* SegAddress ) { if ( ((u16)SegAddress >= 0x1980) && ((u16)SegAddress < (0x1A00)) ) { if (FLASH->CTL3 & 0x0040) { FLASH->CTL3 |= 0x0040; } } return FLASH_Erase( (FLASH_CTL_ERASE), SegAddress ); }
/**----------------------------------------------------------------------------- * @brief Effacement d'un secteur de Flash en fonction de l'adresse. * * @param[in] Address Adresse du debut de l'ecriture. * * @return Status Statut de l'effacement. */ uint8_t FLASH_EraseAddress(uint32_t Address) { int32_t FlashSector; FlashSector = FLASH_GetSectorNum(Address); if (FlashSector >= 0) return FLASH_Erase(FlashSector); return Status_KO; }
static int flash_mcux_erase(struct device *dev, off_t offset, size_t len) { struct flash_priv *priv = dev->driver_data; u32_t addr; status_t rc; int key; addr = offset + priv->config.PFlashBlockBase; key = irq_lock(); rc = FLASH_Erase(&priv->config, addr, len, kFLASH_ApiEraseKey); irq_unlock(key); return (rc == kStatus_Success) ? 0 : -EINVAL; }
static int mk64f12_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address) { int sr; int rc; OS_ENTER_CRITICAL(sr); rc = FLASH_Erase(&mk64f12_config, sector_address, mk64f12_config.PFlashSectorSize, kFLASH_apiEraseKey); OS_EXIT_CRITICAL(sr); if (rc == kStatus_Success) { return 0; } return -1; }
static int flash_mcux_erase(struct device *dev, off_t offset, size_t len) { struct flash_priv *priv = dev->driver_data; u32_t addr; status_t rc; unsigned int key; if (k_sem_take(&priv->write_lock, K_NO_WAIT)) { return -EACCES; } addr = offset + priv->pflash_block_base; key = irq_lock(); rc = FLASH_Erase(&priv->config, addr, len, kFLASH_ApiEraseKey); irq_unlock(key); k_sem_give(&priv->write_lock); return (rc == kStatus_Success) ? 0 : -EINVAL; }
otError utilsFlashErasePage(uint32_t aAddress) { otError error; status_t status; status = FLASH_Erase(&sFlashConfig, aAddress, FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE, kFLASH_ApiEraseKey); if (status == kStatus_FLASH_Success) { error = OT_ERROR_NONE; } else if (status == kStatus_FLASH_AlignmentError) { error = OT_ERROR_INVALID_ARGS; } else { error = OT_ERROR_FAILED; } return error; }
u8 FLASH_EraseAll( ) { if (FLASH->CTL3 & 0x0040) { FLASH->CTL3 |= 0x0040; } return FLASH_Erase( (FLASH_CTL_MERAS | FLASH_CTL_ERASE), (u16*)FLASH_BankBase_Main0 ); }