unsigned char EraseAllMemory_FLASH(void) { unsigned char resp = 0; //borro toda la memoria desde pagina 28 a 31 ErasePage(PAGE28,0); ErasePage(PAGE29,0); ErasePage(PAGE30,0); ErasePage(PAGE31,1); //reviso si borre if (*(unsigned int *) PAGE28 == 0xFFFFFFFF) resp++; if (*(unsigned int *) PAGE29 == 0xFFFFFFFF) resp++; if (*(unsigned int *) PAGE30 == 0xFFFFFFFF) resp++; if (*(unsigned int *) PAGE31 == 0xFFFFFFFF) resp++; if (resp == 4) return PASSED; else return FAILED; }
unsigned char Write_Code_To_Memory_FLASH(unsigned short position, unsigned int new_code) { //check if possition is good if (position > PAGE31_END) return FAILED; if (position >= PAGE31_START) { BackupPage(memory_backup.v_bkp, (unsigned int *) PAGE31); ErasePage(PAGE31,0); if (UpdateNewCode(memory_backup.v_bkp, position - PAGE31_START, new_code) == FAILED) return FAILED; if (WritePage(memory_backup.v_bkp, PAGE31, 1) == FAILED) return FAILED; } else if (position >= PAGE30_START) { BackupPage(memory_backup.v_bkp, (unsigned int *) PAGE30); ErasePage(PAGE30,0); if (UpdateNewCode(memory_backup.v_bkp, position - PAGE30_START, new_code) == FAILED) return FAILED; if (WritePage(memory_backup.v_bkp, PAGE30, 1) == FAILED) return FAILED; } else if (position >= PAGE29_START) { BackupPage(memory_backup.v_bkp, (unsigned int *) PAGE29); ErasePage(PAGE29,0); if (UpdateNewCode(memory_backup.v_bkp, position - PAGE29_START, new_code) == FAILED) return FAILED; if (WritePage(memory_backup.v_bkp, PAGE29, 1) == FAILED) return FAILED; } else if (position >= PAGE28_START) { BackupPage(memory_backup.v_bkp, (unsigned int *) PAGE28); ErasePage(PAGE28,0); if (UpdateNewCode(memory_backup.v_bkp, position, new_code) == FAILED) return FAILED; if (WritePage(memory_backup.v_bkp, PAGE28, 1) == FAILED) return FAILED; } return PASSED; }
unsigned char WriteConfigurations (void) { unsigned char * p_dos; //hago bkp de la pagina??? SI SI NO SE TRABA EL PROGRAMA BackupPage(memory_backup.v_bkp, (unsigned int *) PAGE27); ErasePage(PAGE27,0); //update en memoria p_dos = (unsigned char *) &memory_backup.v_bkp[0]; *p_dos = param_struct.b1t; *(p_dos + 1) = param_struct.b1r; *(p_dos + 2) = param_struct.b2t; *(p_dos + 3) = param_struct.b2r; *(p_dos + 4) = param_struct.b3t; *(p_dos + 5) = param_struct.b3r; *(p_dos + 6) = param_struct.b4t; *(p_dos + 7) = param_struct.b4r; //faltan los tiempos internos if (WritePage(memory_backup.v_bkp, PAGE27, 1) == FAILED) return FAILED; return PASSED; }
/** * @brief Erase the partition containing the TFTF Header */ void erase_tftf_header(void) { ErasePage((uint32_t)(PARTITION_TFTF_START)); }