在线时间14 小时
UID323019
注册时间2014-9-4
NXP金币0
该用户从未签到
注册会员

- 积分
- 128
- 最后登录
- 2014-12-31
|

楼主 |
发表于 2014-12-29 13:54:55
|
显示全部楼层
/* Define globals for address of counters */
#define LONGWORD_COUNTER_ADDR 0x14000000
#define WORD_COUNTER_ADDR 0x14000004
#define BYTE_COUNTER_ADDR 0x14000006
__RAMFUNC void flexmem_eeprom_init(void)
{
SCB_SHCSR|=SCB_SHCSR_BUSFAULTENA_MASK|SCB_SHCSR_MEMFAULTENA_MASK|SCB_SHCSR_USGFAULTENA_MASK;
//FTFE_FEPROT |=FTFE_FEPROT_EPROT(15);
//FTFE_FDPROT |=FTFE_FDPROT_DPROT(15);
partition_flash( EEPROM_8K_8K, DFLASH_SIZE_256);
}
__RAMFUNC void flexmem_ee32bit_write(uint32 flex_addr,uint32 flex_data)
{
*((uint32 *)(flex_addr)) = flex_data;
while(!(FTFE_FCNFG & FTFE_FCNFG_EEERDY_MASK));
}
void flexmem_ee16bit_write(uint16 flex_addr,uint16 flex_data)
{
*((uint16 *)(flex_addr)) = flex_data;
while(!(FTFE_FCNFG & FTFE_FCNFG_EEERDY_MASK));
}
void flexmem_ee8bit_write(uint8 flex_addr,uint8 flex_data)
{
*((uint8 *)(flex_addr)) = flex_data;
while(!(FTFE_FCNFG & FTFE_FCNFG_EEERDY_MASK));
}
uint32 flex_ee32bit_read(uint32 flex_addr)
{
return (*(uint32 *)(flex_addr));
}
uint16 flex_ee16bit_read(uint16 flex_addr)
{
return (*(uint16 *)(flex_addr));
}
uint8 flex_ee8bit_read(uint8 flex_addr)
{
return (*(uint8 *)(flex_addr));
}
__RAMFUNC uint8 partition_flash(uint16 eeprom_size, uint16 dflash_size)
{
/* Test to make sure the device is not already partitioned. If it
* is already partitioned, then return with no action performed.
*/
//FTFE_FCCOB0 = FTFE_FCCOB0_CCOBn(0x44); // Selects the PGMPART command
/* Wait for the command to complete */
// printf("error:%d\n",FTFE_FSTAT);
if ((SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00)
{
// printf("\nDevice is already partitioned.\n");
return 0;
}
/* Write the FCCOB registers */
FTFE_FCCOB0 = FTFE_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
FTFE_FCCOB1 = 0x00;
FTFE_FCCOB2 = 0x00;
FTFE_FCCOB3 = 0x00;
FTFE_FCCOB4 = eeprom_size;
FTFE_FCCOB5 = dflash_size;
FTFE_FSTAT |= FTFE_FSTAT_CCIF_MASK;
while(!(FTFE_FSTAT & FTFE_FSTAT_CCIF_MASK));
return 1;
}
|
|