34#define FMC_APROM_BASE 0x00000000UL
35#define FMC_APROM_END 0x00080000UL
36#define FMC_APROM_BANK0_END (FMC_APROM_END/2UL)
37#define FMC_LDROM_BASE 0x00100000UL
38#define FMC_LDROM_END 0x00101000UL
39#define FMC_SPROM_BASE 0x00200000UL
40#define FMC_SPROM_END 0x00201000UL
41#define FMC_XOM_BASE 0x00200000UL
42#define FMC_XOMR0_BASE 0x00200000UL
43#define FMC_XOMR1_BASE 0x00200010UL
44#define FMC_XOMR2_BASE 0x00200020UL
45#define FMC_XOMR3_BASE 0x00200030UL
46#define FMC_CONFIG_BASE 0x00300000UL
47#define FMC_USER_CONFIG_0 0x00300000UL
48#define FMC_USER_CONFIG_1 0x00300004UL
49#define FMC_USER_CONFIG_2 0x00300008UL
50#define FMC_KPROM_BASE 0x00301000UL
51#define FMC_OTP_BASE 0x00310000UL
53#define FMC_FLASH_PAGE_SIZE 0x1000UL
54#define FMC_PAGE_ADDR_MASK 0xFFFFF000UL
55#define FMC_MULTI_WORD_PROG_LEN 512
57#define FMC_APROM_SIZE FMC_APROM_END
58#define FMC_BANK_SIZE (FMC_APROM_SIZE/2UL)
59#define FMC_LDROM_SIZE 0x1000UL
60#define FMC_SPROM_SIZE 0x1000UL
61#define FMC_OTP_ENTRY_CNT 256UL
74#define IS_BOOT_FROM_LDROM 0x1UL
75#define IS_BOOT_FROM_APROM 0x0UL
80#define FMC_ISPCMD_READ 0x00UL
81#define FMC_ISPCMD_READ_UID 0x04UL
82#define FMC_ISPCMD_READ_ALL1 0x08UL
83#define FMC_ISPCMD_READ_CID 0x0BUL
84#define FMC_ISPCMD_READ_DID 0x0CUL
85#define FMC_ISPCMD_READ_CKS 0x0DUL
86#define FMC_ISPCMD_PROGRAM 0x21UL
87#define FMC_ISPCMD_PAGE_ERASE 0x22UL
88#define FMC_ISPCMD_BANK_ERASE 0x23UL
89#define FMC_ISPCMD_BLOCK_ERASE 0x25UL
90#define FMC_ISPCMD_PROGRAM_MUL 0x27UL
91#define FMC_ISPCMD_RUN_ALL1 0x28UL
92#define FMC_ISPCMD_RUN_CKS 0x2DUL
93#define FMC_ISPCMD_VECMAP 0x2EUL
94#define FMC_ISPCMD_READ_64 0x40UL
95#define FMC_ISPCMD_PROGRAM_64 0x61UL
97#define READ_ALLONE_YES 0xA11FFFFFUL
98#define READ_ALLONE_NOT 0xA1100000UL
99#define READ_ALLONE_CMD_FAIL 0xFFFFFFFFUL
101#define FMC_TIMEOUT_READ ((SystemCoreClock/10)*2)
102#define FMC_TIMEOUT_WRITE ((SystemCoreClock/10)*2)
103#define FMC_TIMEOUT_ERASE ((SystemCoreClock/10)*4)
104#define FMC_TIMEOUT_CHKSUM (SystemCoreClock*2)
105#define FMC_TIMEOUT_CHKALLONE (SystemCoreClock*2)
119#define FMC_SET_APROM_BOOT() (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk)
120#define FMC_SET_LDROM_BOOT() (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk)
121#define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk)
122#define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk)
123#define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk)
124#define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk)
125#define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk)
126#define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk)
127#define FMC_ENABLE_SP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_SPUEN_Msk)
128#define FMC_DISABLE_SP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_SPUEN_Msk)
129#define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk)
130#define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk)
131#define FMC_GET_FAIL_FLAG() ((FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) ? 1UL : 0UL)
132#define FMC_CLR_FAIL_FLAG() (FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk)
152__STATIC_INLINE uint32_t
FMC_ReadUID(uint8_t u8Index);
153__STATIC_INLINE uint32_t
FMC_ReadUCID(uint32_t u32Index);
194 if (
FMC->ISPDAT != 0xDA)
218 FMC->ISPADDR = 0x04u;
247 FMC->ISPADDR = ((uint32_t)u8Index << 2u);
277 FMC->ISPADDR = (0x04u * u32Index) + 0x10u;
310 FMC->ISPADDR = u32PageAddr;
330extern int32_t
FMC_ConfigXOM(uint32_t xom_num, uint32_t xom_base, uint8_t xom_page);
331extern int32_t
FMC_Erase(uint32_t u32PageAddr);
339extern uint32_t
FMC_Read(uint32_t u32Addr);
340extern int32_t
FMC_Read_64(uint32_t u32addr, uint32_t * u32data0, uint32_t * u32data1);
343extern int32_t
FMC_Write(uint32_t u32Addr, uint32_t u32Data);
344extern int32_t
FMC_Write8Bytes(uint32_t u32addr, uint32_t u32data0, uint32_t u32data1);
345extern int32_t
FMC_WriteMultiple(uint32_t u32Addr, uint32_t pu32Buf[], uint32_t u32Len);
346extern int32_t
FMC_Write_OTP(uint32_t otp_num, uint32_t low_word, uint32_t high_word);
347extern int32_t
FMC_Read_OTP(uint32_t otp_num, uint32_t *low_word, uint32_t *high_word);
350extern int32_t
FMC_ReadConfig(uint32_t u32Config[], uint32_t u32Count);
351extern int32_t
FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count);
352extern uint32_t
FMC_GetChkSum(uint32_t u32addr, uint32_t u32count);
354extern int32_t
FMC_SetSPKey(uint32_t key[3], uint32_t kpmax, uint32_t kemax,
const int32_t lock_CONFIG,
const int32_t lock_SPROM);
#define FMC_ISPCMD_READ_DID
#define FMC_ISPCMD_READ_CID
#define FMC_ISPCMD_VECMAP
#define FMC_TIMEOUT_WRITE
#define FMC_ISPCMD_READ_UID
int32_t FMC_Read_OTP(uint32_t otp_num, uint32_t *low_word, uint32_t *high_word)
Read the 64-bits data from the specified OTP.
void FMC_Close(void)
Disable FMC ISP function.
int32_t FMC_Lock_OTP(uint32_t otp_num)
Lock the specified OTP.
int32_t FMC_ReadConfig(uint32_t u32Config[], uint32_t u32Count)
Execute FMC_ISPCMD_READ command to read User Configuration.
int32_t FMC_CompareSPKey(uint32_t key[3])
Execute security key comparison.
int32_t FMC_WriteMultiple(uint32_t u32Addr, uint32_t pu32Buf[], uint32_t u32Len)
Program Multi-Word data into specified address of flash.
int32_t FMC_Erase_SPROM(void)
Execute FMC_ISPCMD_PAGE_ERASE command to erase SPROM. The page size is 4096 bytes.
int32_t FMC_Erase_Block(uint32_t u32BlockAddr)
Execute FMC_ISPCMD_BLOCK_ERASE command to erase a flash block. The block size is 4 pages.
__STATIC_INLINE int32_t FMC_SetVectorPageAddr(uint32_t u32PageAddr)
Set vector mapping address.
int32_t FMC_ConfigXOM(uint32_t xom_num, uint32_t xom_base, uint8_t xom_page)
Config XOM Region.
uint32_t FMC_GetChkSum(uint32_t u32addr, uint32_t u32count)
Run CRC32 checksum calculation and get result.
int32_t FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count)
Execute ISP commands to erase then write User Configuration.
uint32_t FMC_CheckAllOne(uint32_t u32addr, uint32_t u32count)
Run flash all one verification and get result.
__STATIC_INLINE uint32_t FMC_ReadPID(void)
Read product ID.
__STATIC_INLINE uint32_t FMC_ReadUID(uint8_t u8Index)
Read Unique ID.
int32_t FMC_GetXOMState(uint32_t xom_num)
Check the XOM is actived or not.
int32_t FMC_Erase(uint32_t u32PageAddr)
Execute FMC_ISPCMD_PAGE_ERASE command to erase a flash page. The page size is 4096 bytes.
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
void FMC_SetBootSource(int32_t i32BootSrc)
Set boot source from LDROM or APROM after next software reset.
int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Execute ISP FMC_ISPCMD_PROGRAM to program a word to flash.
uint32_t FMC_Read(uint32_t u32Addr)
Execute FMC_ISPCMD_READ command to read a word from flash.
int32_t FMC_Is_OTP_Locked(uint32_t otp_num)
Check the OTP is locked or not.
int32_t FMC_Write_OTP(uint32_t otp_num, uint32_t low_word, uint32_t high_word)
Program a 64-bits data to the specified OTP.
int32_t FMC_GetBootSource(void)
Get the current boot source.
__STATIC_INLINE uint32_t FMC_ReadUCID(uint32_t u32Index)
To read UCID.
int32_t FMC_EraseXOM(uint32_t xom_num)
Execute Erase XOM Region.
int32_t FMC_Write8Bytes(uint32_t u32addr, uint32_t u32data0, uint32_t u32data1)
Execute ISP FMC_ISPCMD_PROGRAM_64 to program a double-word to flash.
int32_t FMC_Erase_Bank(uint32_t u32BankAddr)
Execute FMC_ISPCMD_BANK_ERASE command to erase a flash block.
void FMC_Open(void)
Enable FMC ISP function.
int32_t FMC_Read_64(uint32_t u32addr, uint32_t *u32data0, uint32_t *u32data1)
Execute FMC_ISPCMD_READ_64 command to read a double-word from flash.
__STATIC_INLINE uint32_t FMC_ReadCID(void)
Read company ID.
int32_t FMC_SetSPKey(uint32_t key[3], uint32_t kpmax, uint32_t kemax, const int32_t lock_CONFIG, const int32_t lock_SPROM)
Setup security key.
__STATIC_INLINE uint32_t FMC_GetVECMAP(void)
Get current vector mapping address.
#define FMC_ISPSTS_VECMAP_Msk
#define FMC_ISPTRG_ISPGO_Msk