int partition_flash(int eeprom_size, int dflash_size)
{
// unsigned char rrr;
/* Test to make sure the device is not already partitioned. If it
* is already partitioned, then return with no action performed.
*/
if ((SIM->FCFG1 & SIM_FCFG1_DEPART(0xF))!= 0x00000F00)
{
printf("\nDevice is already partitioned.\n");
return 0;
}
/* Write the FCCOB registers */
FTFL->FCCOB0 = FTFL_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
FTFL->FCCOB1 = 0x00;
FTFL->FCCOB2 = 0x00;
FTFL->FCCOB3 = 0x00;
/* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */
FTFL->FCCOB4 =eeprom_size;// eeprom_size;
/* FFCOB5 is written with the code for the Dflash size (dflash_size define) */
FTFL->FCCOB5 = dflash_size;//dflash_size;
/* All required FCCOBx registers are written, so launch the command */
ftfl_flex.FSTAT = FTFL_FSTAT_CCIF_MASK;
while(!(FTFL->FSTAT & FTFL_FSTAT_CCIF_MASK));
// FTFL->FCCOB0 = FTFL_FCCOB0_CCOBn(0x81); // Selects the PGMPART command,0X80±à3ìeeprom?üá?
// FTFL->FCCOB1 = 0x00;
// FTFL->FSTAT = FTFL_FSTAT_CCIF_MASK;//??CCIF±ê????D'1-?'??3yCCIF±ê??????'ó?????ˉ?üá?
// /* Wait for the command to complete */
// while(!(FTFL->FSTAT & FTFL_FSTAT_CCIF_MASK));//FTFE_FSTATμ?CCIF???ú?üá??'DD?ú??ê???±?3??a0???±μ??üá??'DDíê3é2?±??a1??μè'y?üá?'?ê?íê3é
return 1;
}
|