/*---------------------------------------------------------------------------* * Routine: Flash_Renesas_RX63N_BlockErase *---------------------------------------------------------------------------* * Description: * Erase one ore more blocks in the given location * Inputs: * void *aW -- Workspace * TUInt32 aAddress -- Base address into device to write * TUInt8 *aBuffer -- Pointer to buffer of data * TUInt32 aNumBytes -- Number of bytes to write * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Flash_Renesas_RX63N_BlockErase( void *aWorkspace, TUInt32 aBlockNum, TUInt32 aNumBytes) { T_Flash_Renesas_RX63N_Workspace *p = (T_Flash_Renesas_RX63N_Workspace *)aWorkspace; T_uezError error = UEZ_ERROR_NONE; if(aNumBytes!= DF_BLOCK_SIZE) { error = UEZ_ERROR_NOT_ENOUGH_DATA; }else{ IEnsureChipInfo(aWorkspace); // Let's do it UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE); error = (T_uezError)R_FlashErase((TUInt8)aBlockNum); //<<---- Check for Error Here // Go ahead and force out of program mode IExitProgramMode(p); // Done erasing, resume normal control UEZSemaphoreRelease(p->iSem); } return error; }
/****************************************************************************** * void erase_data_flash(unsigned char start_block, unsigned char end_block) * * Erases data flash from start_block to end_block, inclusive. It locks upon * error. * ******************************************************************************/ static void erase_data_flash(unsigned char start_block, unsigned char end_block) { uint8_t ret = 0; uint8_t loop_counter = 0, block_count = BLOCK_DB0 + start_block; uint32_t address = 0x00000000; /* Initialise a for loop to erase each of the data flash blocks */ for (loop_counter = start_block; loop_counter < end_block + 1; loop_counter++) { /* Fetch beginning address of DF block */ address = g_flash_BlockAddresses[BLOCK_DB0 + loop_counter]; /* Erase data flash block */ ret |= R_FlashErase(block_count); /* Check if data flash area is blank */ ret |= R_FlashDataAreaBlankCheck(address,BLANK_CHECK_ENTIRE_BLOCK); /* Increment block counter */ block_count++; } /* Check Blank Checking */ ret |= R_FlashDataAreaBlankCheck(address,BLANK_CHECK_ENTIRE_BLOCK); /* Halt in while loop when flash API errors detected */ while (ret); }
/******************************************************************************* * Outline : Erase_FlashData * Description : This function enters a for loop, and erases a block of data * flash memory each iteration until all blocks have been erased. * Argument : none * Return value : none *******************************************************************************/ void Erase_FlashData(void) { /* Declare flash API error flag */ uint8_t ret = 0; /* Declare loop count and block count variables */ uint8_t loop_counter = 0, block_count = BLOCK_DB0; uint32_t address = 0x00000000; /* Initialise a for loop to erase each of the data flash blocks */ for(loop_counter = 0; loop_counter < DF_NUM_BLOCKS; loop_counter++) { /* Fetch beginning address of DF block */ address = block_addresses[BLOCK_DB0 + loop_counter]; /* Erase data flash block */ ret |= R_FlashErase ( block_count ); /* Check if data flash area is blank */ ret |= R_FlashDataAreaBlankCheck ( address, BLANK_CHECK_ENTIRE_BLOCK ); /* Increment block counter */ block_count++; } /* Check Blank Checking */ ret |= R_FlashDataAreaBlankCheck ( address, BLANK_CHECK_ENTIRE_BLOCK ); /* Halt in while loop when flash API errors detected */ //--while(ret); }
static void eepromFormat(void) { uint32_t loop1; uint32_t ret; /* Enable data flash access. */ R_FlashDataAreaAccess(0xFFFF, 0xFFFF); for (loop1 = 0; loop1 < DF_NUM_BLOCKS; loop1++) { /* Erase data flash. */ ret = R_FlashErase(BLOCK_DB0 + loop1); /* Check for errors */ if(ret != FLASH_SUCCESS) { while(1) { /* Failure in erasing data flash. Something is not setup right. */ } } /* Wait for flash operation to finish. */ while(FLASH_SUCCESS != R_FlashGetStatus()); } memcpy(configVarOx,configVarOxInit,sizeof(configVarOx)); memcpy(configVarPl,configVarPlInit,sizeof(configVarPl)); memcpy(configVarJog,configVarJogInit,sizeof(configVarJog)); memcpy(&configFlags,&configFlagsInit,sizeof(configFlags)); memcpy(&zeroPiece,&zeroPieceInit,sizeof(zeroPiece)); memcpy(configVarMaq,configVarMaqInit,sizeof(configVarMaq)); R_VEE_Open(); eepromWriteConfig(CONFIGVAR_OX); eepromWriteConfig(CONFIGVAR_PL); eepromWriteConfig(CONFIGVAR_JOG); eepromWriteConfig(CONFIGVAR_MAQ); eepromWriteConfig(CONFIGVAR_PAR_MAQ); eepromWriteConfig(CONFIGFLAG); eepromWriteConfig(ZEROPIECE); }
void Datalog::cleanup(){ R_FlashErase(BLOCK_DB0); R_FlashErase(BLOCK_DB1); R_FlashErase(BLOCK_DB2); R_FlashErase(BLOCK_DB3); R_FlashErase(BLOCK_DB4); R_FlashErase(BLOCK_DB5); R_FlashErase(BLOCK_DB6); R_FlashErase(BLOCK_DB7); R_FlashErase(BLOCK_DB8); R_FlashErase(BLOCK_DB9); R_FlashErase(BLOCK_DB10); R_FlashErase(BLOCK_DB11); R_FlashErase(BLOCK_DB12); R_FlashErase(BLOCK_DB13); R_FlashErase(BLOCK_DB14); R_FlashErase(BLOCK_DB15); // uint32_t data[10] = {0}; // for(uint32_t i=0x00100000; i<0x00108000; i+=0x00000008) // R_FlashWrite(i, (uint32_t)(data), 16); }