38#define FMC_APROM_BASE 0x00000000UL
39#define FMC_APROM_END 0x00080000UL
40#define FMC_LDROM_BASE 0x00100000UL
41#define FMC_LDROM_END 0x00104000UL
42#define FMC_CONFIG_BASE 0x00300000UL
44#define FMC_FLASH_PAGE_SIZE 0x800
45#define FMC_LDROM_SIZE 0x4000
50#define FMC_ISPCMD_READ 0x00
51#define FMC_ISPCMD_READ_64 0x40
52#define FMC_ISPCMD_PROGRAM 0x21
53#define FMC_ISPCMD_WRITE 0x21
54#define FMC_ISPCMD_WRITE_64 0x61
55#define FMC_ISPCMD_PAGE_ERASE 0x22
56#define FMC_ISPCMD_READ_CID 0x0B
57#define FMC_ISPCMD_READ_PID 0x0C
58#define FMC_ISPCMD_READ_UID 0x04
59#define ISP_ISPCMD_MULTI_WRITE 0x27
60#define FMC_ISPCMD_VECMAP 0x2E
62#define IS_BOOT_FROM_APROM 0
63#define IS_BOOT_FROM_LDROM 1
65#define FMC_TIMEOUT_READ ((SystemCoreClock/10))
66#define FMC_TIMEOUT_WRITE ((SystemCoreClock/10))
67#define FMC_TIMEOUT_ERASE ((SystemCoreClock/10)*2)
88#define FMC_SET_APROM_BOOT() (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk)
96#define FMC_SET_LDROM_BOOT() (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk)
104#define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk)
112#define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk)
120#define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk)
128#define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk)
136#define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk)
144#define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk)
152#define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk)
160#define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk)
168#define FMC_GET_FAIL_FLAG() ((FMC->ISPSTS & FMC_ISPSTS_ISPFF_Msk) ? 1 : 0)
176#define FMC_CLR_FAIL_FLAG() (FMC->ISPSTS |= FMC_ISPSTS_ISPFF_Msk)
190extern int32_t
FMC_Erase(uint32_t u32PageAddr);
193extern uint32_t
FMC_Read(uint32_t u32Addr);
194extern int32_t
FMC_Read_64(uint32_t u32Addr, uint32_t *u32Data0, uint32_t *u32Data1);
202extern int32_t
FMC_Write(uint32_t u32Addr, uint32_t u32Data);
203extern int32_t
FMC_Write_64(uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1);
204extern int32_t
FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
206extern uint32_t
FMC_CRC8(uint32_t au32Data[],
int i32Count);
void FMC_Close(void)
Disable FMC ISP function.
int32_t FMC_Write_64(uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1)
Execute ISP 64-bits write command to program two words to flash.
int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count)
Read the User Configuration words.
uint32_t FMC_ReadCID(void)
Read company ID.
uint32_t FMC_GetVectorPageAddr(void)
Obtain the current vector page address setting.
uint32_t FMC_ReadUID(uint32_t u32Index)
This function reads one of the three UID.
int32_t FMC_Erase(uint32_t u32PageAddr)
Erase a page. The page size is 2048 bytes.
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Execute ISP command to program a word to flash.
uint32_t FMC_Read(uint32_t u32Addr)
Execute ISP command to read a word from flash.
uint32_t FMC_ReadPID(void)
Read product ID.
uint32_t FMC_CRC8(uint32_t au32Data[], int i32Count)
CRC8 Calculator.
int32_t FMC_GetBootSource(void)
Get the current boot source.
int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count)
Write User Configuration.
int32_t FMC_Read_64(uint32_t u32Addr, uint32_t *u32Data0, uint32_t *u32Data1)
Execute ISP 64-bits read command to read two words from flash.
int32_t FMC_SetVectorPageAddr(uint32_t u32PageAddr)
This function will force re-map assigned flash page to CPU address 0x0.
void FMC_Open(void)
Enable FMC ISP function.
uint32_t FMC_ReadUCID(uint32_t u32Index)
This function reads one of the four UCID.