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 114 #define FMC_SET_APROM_BOOT() (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk) 115 #define FMC_SET_LDROM_BOOT() (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk) 116 #define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk) 117 #define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk) 118 #define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk) 119 #define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk) 120 #define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk) 121 #define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk) 122 #define FMC_ENABLE_SP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_SPUEN_Msk) 123 #define FMC_DISABLE_SP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_SPUEN_Msk) 124 #define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk) 125 #define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk) 126 #define FMC_GET_FAIL_FLAG() ((FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) ? 1UL : 0UL) 127 #define FMC_CLR_FAIL_FLAG() (FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk) 142 __STATIC_INLINE uint32_t
FMC_ReadUID(uint8_t u8Index);
143 __STATIC_INLINE uint32_t
FMC_ReadUCID(uint32_t u32Index);
188 FMC->ISPADDR = 0x04u;
207 FMC->ISPADDR = ((uint32_t)u8Index << 2u);
213 while(
FMC->ISPTRG) {}
227 FMC->ISPADDR = (0x04u * u32Index) + 0x10u;
248 FMC->ISPADDR = u32PageAddr;
253 while(
FMC->ISPTRG) {}
262 extern int32_t
FMC_ConfigXOM(uint32_t xom_num, uint32_t xom_base, uint8_t xom_page);
263 extern int32_t
FMC_Erase(uint32_t u32PageAddr);
271 extern uint32_t
FMC_Read(uint32_t u32Addr);
272 extern int32_t
FMC_Read_64(uint32_t u32addr, uint32_t * u32data0, uint32_t * u32data1);
275 extern void FMC_Write(uint32_t u32Addr, uint32_t u32Data);
276 extern int32_t
FMC_Write8Bytes(uint32_t u32addr, uint32_t u32data0, uint32_t u32data1);
277 extern int32_t
FMC_WriteMultiple(uint32_t u32Addr, uint32_t pu32Buf[], uint32_t u32Len);
278 extern int32_t
FMC_Write_OTP(uint32_t otp_num, uint32_t low_word, uint32_t high_word);
279 extern int32_t
FMC_Read_OTP(uint32_t otp_num, uint32_t *low_word, uint32_t *high_word);
282 extern int32_t
FMC_ReadConfig(uint32_t u32Config[], uint32_t u32Count);
283 extern int32_t
FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count);
284 extern uint32_t
FMC_GetChkSum(uint32_t u32addr, uint32_t u32count);
286 extern 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_ISPSTS_VECMAP_Msk
__STATIC_INLINE uint32_t FMC_GetVECMAP(void)
Get current vector mapping address.
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
int32_t FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count)
Execute ISP commands to erase then write User Configuration.
int32_t FMC_Erase_Bank(uint32_t u32BankAddr)
Execute FMC_ISPCMD_BANK_ERASE command to erase a flash block.
int32_t FMC_GetXOMState(uint32_t xom_num)
Check the XOM is actived or not.
void FMC_Close(void)
Disable FMC ISP function.
uint32_t FMC_CheckAllOne(uint32_t u32addr, uint32_t u32count)
Run flash all one verification and get result.
__STATIC_INLINE uint32_t FMC_ReadCID(void)
Read company ID.
#define FMC_ISPCMD_READ_UID
int32_t FMC_ConfigXOM(uint32_t xom_num, uint32_t xom_base, uint8_t xom_page)
Config XOM Region.
int32_t FMC_Is_OTP_Locked(uint32_t otp_num)
Check the OTP is locked 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.
int32_t FMC_Lock_OTP(uint32_t otp_num)
Lock the specified OTP.
int32_t FMC_GetBootSource(void)
Get the current boot source.
void FMC_Open(void)
Enable FMC ISP function.
__STATIC_INLINE void FMC_SetVectorPageAddr(uint32_t u32PageAddr)
Set vector mapping address.
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.
uint32_t FMC_Read(uint32_t u32Addr)
Execute FMC_ISPCMD_READ command to read a word from flash.
uint32_t FMC_GetChkSum(uint32_t u32addr, uint32_t u32count)
Run CRC32 checksum calculation and get result.
#define FMC_ISPCMD_READ_DID
#define FMC_ISPCMD_VECMAP
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.
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.
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.
void FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Execute ISP FMC_ISPCMD_PROGRAM to program a word to flash.
int32_t FMC_CompareSPKey(uint32_t key[3])
Execute security key comparison.
#define FMC_ISPTRG_ISPGO_Msk
__STATIC_INLINE uint32_t FMC_ReadUCID(uint32_t u32Index)
To read UCID.
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.
#define FMC_ISPCMD_READ_CID
__STATIC_INLINE uint32_t FMC_ReadUID(uint8_t u8Index)
Read Unique ID.
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_EraseXOM(uint32_t xom_num)
Execute Erase XOM Region.
__STATIC_INLINE uint32_t FMC_ReadPID(void)
Read product ID.
int32_t FMC_ReadConfig(uint32_t u32Config[], uint32_t u32Count)
Execute FMC_ISPCMD_READ command to read User Configuration.
void FMC_SetBootSource(int32_t i32BootSrc)
Set boot source from LDROM or APROM after next software reset.
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.