void Init_FlashData(void) { // unsigned char buf[4]; /* Enable MCU access to the data flash area */ R_FlashDataAreaAccess(0xFFFF, 0xFFFF); /* Initialise the ADC unit */ //--InitADC_FlashData(); fptr1 =(unsigned long*) block_addresses[BLOCK_DB0]; /* Erase flash memory before writing to it */ //--Erase_FlashData(); //--R_FlashWrite(block_addresses[BLOCK_DB0],(uint32_t)st,256); }
/*---------------------------------------------------------------------------* * Routine: Flash_Renesas_RX63N_Close *---------------------------------------------------------------------------* * Description: * Close the flash device. For the Renesas RX63N, the flash area access * needs to be closed using IExitProgramMode. * Inputs: * void *aW -- Workspace * TUInt32 aAddress -- Base address into device to read * TUInt8 *aBuffer -- Pointer to buffer to receive data * TUInt32 aNumBytes -- Number of bytes to read * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Flash_Renesas_RX63N_Close(void *aWorkspace) { T_Flash_Renesas_RX63N_Workspace *p = (T_Flash_Renesas_RX63N_Workspace *)aWorkspace; if (p->iNumOpen) { p->iNumOpen--; if (p->iNumOpen == 0){ IExitProgramMode(p); } //Grant Read Access Here R_FlashDataAreaAccess(0xFFFF, 0x0000); current_mode = READ_MODE; return UEZ_ERROR_NONE; } else { return UEZ_ERROR_NOT_OPEN; } }
/*---------------------------------------------------------------------------* * Routine: Flash_Renesas_RX63N_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for Data Flash. For the Renesas RX63N, we allow the MCU to * access the data flash area. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Flash_Renesas_RX63N_InitializeWorkspace(void *aW) { T_uezError error; T_Flash_Renesas_RX63N_Workspace *p = (T_Flash_Renesas_RX63N_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); p->iBaseAddr = 0; p->iNumOpen = 0; p->iIsProgramMode = EFalse; p->iIsChipInfoReady = EFalse; // Grant Read Access here R_FlashDataAreaAccess(0xFFFF, 0x0000); return error; }
/*---------------------------------------------------------------------------* * Routine: Flash_Renesas_RX63N_Open *---------------------------------------------------------------------------* * Description: * Open the flash device. Initialize the flash * Inputs: * void *aW -- Workspace * TUInt32 aAddress -- Base address into device to read * TUInt8 *aBuffer -- Pointer to buffer to receive data * TUInt32 aNumBytes -- Number of bytes to read * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Flash_Renesas_RX63N_Open(void *aWorkspace) { T_Flash_Renesas_RX63N_Workspace *p = (T_Flash_Renesas_RX63N_Workspace *)aWorkspace; /* Declare erase operation result container variable */ p->iNumOpen++; if (p->iNumOpen == 1) { // If the first time, assume we were in some programming mode // and need to reset and Re-enable access to the Flash Data area p->iIsProgramMode = ETrue; IExitProgramMode(p); } // Grant full access if we want to open and operate on flash R_FlashDataAreaAccess(0xFFFF, 0xFFFF); current_mode = READ_MODE; //<<---- Since we want to program the data flash only return ((T_uezError)UEZ_ERROR_NONE); }
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 rdk_meta_init(void) * * This function simply enables flash for reading and writing. * ******************************************************************************/ void rdk_meta_init(void) { R_FlashDataAreaAccess(0xFFFF, 0xFFFF); }
/************************************************************************************ * config_init() - called once on hard reset * * Performs one of 2 actions: * (1) if persistence is set up or out-of-rev load RAM and NVM with settings.h defaults * (2) if persistence is set up and at current config version use NVM data for config * * You can assume the cfg struct has been zeroed by a hard reset. * Do not clear it as the version and build numbers have already been set by tg_init() * * NOTE: Config assertions are handled from the controller */ void config_init() { nvObj_t *nv = nv_reset_nv_list(); char *P_str_axis[3] = {"x","y", "z"}; config_init_assertions(); #ifdef __ARM // ++++ The following code is offered until persistence is implemented. // ++++ Then you can use the AVR code (or something like it) cfg.comm_mode = JSON_MODE; // initial value until EEPROM is read _set_defa(nv); #endif #ifdef __AVR cm_set_units_mode(MILLIMETERS); // must do inits in millimeter mode nv->index = 0; // this will read the first record in NVM read_persistent_value(nv); if (nv->value != cs.fw_build) { // case (1) NVM is not setup or not in revision // if (fp_NE(nv->value, cs.fw_build)) { _set_defa(nv); } else { // case (2) NVM is setup and in revision rpt_print_loading_configs_message(); for (nv->index=0; nv_index_is_single(nv->index); nv->index++) { if (GET_TABLE_BYTE(flags) & F_INITIALIZE) { strncpy_P(nv->token, cfgArray[nv->index].token, TOKEN_LEN); // read the token from the array read_persistent_value(nv); nv_set(nv); } } sr_init_status_report(); } #endif #ifdef __RX // ++++ The following code is offered until persistence is implemented. // ++++ Then you can use the AVR code (or something like it) cm_set_units_mode(MILLIMETERS); // must do inits in millimeter mode nv->index = 0; // this will read the first record in NVM spiffs_DIR sf_dir; struct spiffs_dirent e; struct spiffs_dirent *pe = &e; spiffs_file *fd = &uspiffs[0].f; spiffs *fs = &uspiffs[0].gSPIFFS; R_FlashDataAreaAccess(0xFFFF,0xFFFF); checkifParFlashed = (char *)(0x00100000); if (SPIFFS_opendir(fs, "/", &sf_dir) == NULL) { } pe = SPIFFS_readdir(&sf_dir, pe); *fd = SPIFFS_open(fs, "config.met", SPIFFS_RDWR | SPIFFS_DIRECT, 0); SPIFFS_close(fs, *fd); if (*fd == SPIFFS_ERR_NOT_FOUND && strcmp(checkifParFlashed,checkParPhrase)) { // case (1) NVM is not setup or not in revision *fd = SPIFFS_open(fs, "config.met", SPIFFS_CREAT | SPIFFS_RDWR | SPIFFS_DIRECT, 0); SPIFFS_close(fs, *fd); R_FlashEraseRange(0x00100000,0x20); R_FlashWrite(0x00100000,(uint32_t)checkParPhrase, 0x20); _set_defa(nv); } else { // case (2) NVM is setup and in revision rpt_print_loading_configs_message(); for (nv->index=0; nv_index_is_single(nv->index); nv->index++) { if (GET_TABLE_BYTE(flags) & F_INITIALIZE) { strncpy_P(nv->token, cfgArray[nv->index].token, TOKEN_LEN); // read the token from the array read_persistent_value(nv); nv_set(nv); } } sr_init_status_report(); } z_step_pulse = (M1_TRAVEL_PER_REV*M1_STEP_ANGLE)/(360*M1_MICROSTEPS); #endif }
void Datalog::setup(){ R_FlashDataAreaAccess(0xFFFF, 0xFFFF); }