M480 BSP V3.05.006
The Board Support Package for M480 Series
Functions | Variables

Functions

__STATIC_INLINE uint32_t FMC_ReadCID (void)
 Read company ID. More...
 
__STATIC_INLINE uint32_t FMC_ReadPID (void)
 Read product ID. More...
 
__STATIC_INLINE uint32_t FMC_ReadUID (uint8_t u8Index)
 Read Unique ID. More...
 
__STATIC_INLINE uint32_t FMC_ReadUCID (uint32_t u32Index)
 To read UCID. More...
 
__STATIC_INLINE int32_t FMC_SetVectorPageAddr (uint32_t u32PageAddr)
 Set vector mapping address. More...
 
__STATIC_INLINE uint32_t FMC_GetVECMAP (void)
 Get current vector mapping address. More...
 
void FMC_Close (void)
 Disable FMC ISP function. More...
 
int32_t FMC_ConfigXOM (uint32_t u32XomNum, uint32_t u32XomBase, uint8_t u8XomPage)
 Config XOM Region. More...
 
int32_t FMC_Erase (uint32_t u32PageAddr)
 Execute FMC_ISPCMD_PAGE_ERASE command to erase a flash page. The page size is 4096 bytes. More...
 
int32_t FMC_Erase_SPROM (void)
 Execute FMC_ISPCMD_PAGE_ERASE command to erase SPROM. The page size is 4096 bytes. More...
 
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. More...
 
int32_t FMC_Erase_Bank (uint32_t u32BankAddr)
 Execute FMC_ISPCMD_BANK_ERASE command to erase a flash block. More...
 
int32_t FMC_EraseXOM (uint32_t u32XomNum)
 Execute Erase XOM Region. More...
 
int32_t FMC_GetXOMState (uint32_t u32XomNum)
 Check the XOM is actived or not. More...
 
int32_t FMC_GetBootSource (void)
 Get the current boot source. More...
 
void FMC_Open (void)
 Enable FMC ISP function. More...
 
uint32_t FMC_Read (uint32_t u32Addr)
 Execute FMC_ISPCMD_READ command to read a word from flash. More...
 
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. More...
 
uint32_t FMC_ReadDataFlashBaseAddr (void)
 Get the base address of Data Flash if enabled. More...
 
void FMC_SetBootSource (int32_t i32BootSrc)
 Set boot source from LDROM or APROM after next software reset. More...
 
int32_t FMC_Write (uint32_t u32Addr, uint32_t u32Data)
 Execute ISP FMC_ISPCMD_PROGRAM to program a word to flash. More...
 
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. More...
 
int32_t FMC_WriteMultiple (uint32_t u32Addr, uint32_t pu32Buf[], uint32_t u32Len)
 Program Multi-Word data into specified address of flash. More...
 
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. More...
 
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. More...
 
int32_t FMC_Lock_OTP (uint32_t otp_num)
 Lock the specified OTP. More...
 
int32_t FMC_Is_OTP_Locked (uint32_t otp_num)
 Check the OTP is locked or not. More...
 
int32_t FMC_ReadConfig (uint32_t u32Config[], uint32_t u32Count)
 Execute FMC_ISPCMD_READ command to read User Configuration. More...
 
int32_t FMC_WriteConfig (uint32_t u32Config[], uint32_t u32Count)
 Execute ISP commands to erase then write User Configuration. More...
 
uint32_t FMC_GetChkSum (uint32_t u32addr, uint32_t u32count)
 Run CRC32 checksum calculation and get result. More...
 
uint32_t FMC_CheckAllOne (uint32_t u32addr, uint32_t u32count)
 Run flash all one verification and get result. More...
 
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. More...
 
int32_t FMC_CompareSPKey (uint32_t key[3])
 Execute security key comparison. More...
 

Variables

int32_t g_FMC_i32ErrCode
 

Detailed Description

Function Documentation

◆ FMC_CheckAllOne()

uint32_t FMC_CheckAllOne ( uint32_t  u32addr,
uint32_t  u32count 
)

Run flash all one verification and get result.

Parameters
[in]u32addrStarting flash address. It must be a page aligned address.
[in]u32countByte count of flash to be calculated. It must be multiple of 4KB bytes.
Return values
READ_ALLONE_YESThe contents of verified flash area are 0xFFFFFFFF.
READ_ALLONE_NOTSome contents of verified flash area are not 0xFFFFFFFF.
READ_ALLONE_CMD_FAILUnexpected error occurred.
Note
Global error code g_FMC_i32ErrCode -1 RUN_ALL_ONE or CHECK_ALL_ONE commands time-out

Definition at line 1091 of file fmc.c.

◆ FMC_Close()

void FMC_Close ( void  )

Disable FMC ISP function.

Returns
None

Definition at line 35 of file fmc.c.

◆ FMC_CompareSPKey()

int32_t FMC_CompareSPKey ( uint32_t  key[3])

Execute security key comparison.

Parameters
[in]keyKey 0~2 to be compared.
Return values
0Key matched.
-1Command failed.
-2Forbidden. Times of key comparison mismatch reach the maximum count.
-3Key mismatched.
-4No security key lock. Key comparison is not required.
-5Key matched, but failed to unlock.
Note
Global error code g_FMC_i32ErrCode Same as the return value of this function.

Definition at line 1257 of file fmc.c.

◆ FMC_ConfigXOM()

int32_t FMC_ConfigXOM ( uint32_t  u32XomNum,
uint32_t  u32XomBase,
uint8_t  u8XomPage 
)

Config XOM Region.

Parameters
[in]u32XomNumThe XOM number(0~3)
[in]u32XomBaseThe XOM region base address.
[in]u8XomPageThe XOM page number of region size.
Return values
0Success
1XOM is has already actived.
-1Program failed.
-2Invalid XOM number.

Program XOM base address and XOM size(page)

Note
Global error code g_FMC_i32ErrCode -1 Program failed or program time-out -2 Invalid XOM number.

Definition at line 56 of file fmc.c.

◆ FMC_Erase()

int32_t FMC_Erase ( uint32_t  u32PageAddr)

Execute FMC_ISPCMD_PAGE_ERASE command to erase a flash page. The page size is 4096 bytes.

Parameters
[in]u32PageAddrAddress of the flash page to be erased. It must be a 4096 bytes aligned address.
Returns
ISP page erase success or not.
Return values
0Success
-1Erase failed
Note
Global error code g_FMC_i32ErrCode -1 Erase failed or erase time-out

Definition at line 143 of file fmc.c.

◆ FMC_Erase_Bank()

int32_t FMC_Erase_Bank ( uint32_t  u32BankAddr)

Execute FMC_ISPCMD_BANK_ERASE command to erase a flash block.

Parameters
[in]u32BankAddrBase address of the flash bank to be erased.
Returns
ISP page erase success or not.
Return values
0Success
-1Erase failed
Note
Global error code g_FMC_i32ErrCode -1 Erase failed or erase time-out

Definition at line 259 of file fmc.c.

◆ FMC_Erase_Block()

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.

Parameters
[in]u32BlockAddrAddress of the flash block to be erased. It must be a 4 pages aligned address.
Returns
ISP page erase success or not.
Return values
0Success
-1Erase failed
Note
Global error code g_FMC_i32ErrCode -1 Erase failed or erase time-out

Definition at line 223 of file fmc.c.

◆ FMC_Erase_SPROM()

int32_t FMC_Erase_SPROM ( void  )

Execute FMC_ISPCMD_PAGE_ERASE command to erase SPROM. The page size is 4096 bytes.

Returns
SPROM page erase success or not.
Return values
0Success
-1Erase failed
Note
Global error code g_FMC_i32ErrCode -1 Erase failed or erase time-out

Definition at line 185 of file fmc.c.

◆ FMC_EraseXOM()

int32_t FMC_EraseXOM ( uint32_t  u32XomNum)

Execute Erase XOM Region.

Parameters
[in]u32XomNumThe XOMRn(n=0~3)
Returns
XOM erase success or not.
Return values
0Success
-1Erase failed
-2Invalid XOM number.

Execute FMC_ISPCMD_PAGE_ERASE command to erase XOM.

Note
Global error code g_FMC_i32ErrCode -1 Erase failed or erase time-out -2 Invalid XOM number.

Definition at line 301 of file fmc.c.

◆ FMC_GetBootSource()

int32_t FMC_GetBootSource ( void  )

Get the current boot source.

Returns
The current boot source.
Return values
0Is boot from APROM.
1Is boot from LDROM.
2Is boot from Boot Loader.

Definition at line 397 of file fmc.c.

◆ FMC_GetChkSum()

uint32_t FMC_GetChkSum ( uint32_t  u32addr,
uint32_t  u32count 
)

Run CRC32 checksum calculation and get result.

Parameters
[in]u32addrStarting flash address. It must be a page aligned address.
[in]u32countByte count of flash to be calculated. It must be multiple of 4 KB.
Returns
Success or not.
Return values
0Success.
0xFFFFFFFFInvalid parameter or command failed.
Note
Global error code g_FMC_i32ErrCode -1 Run/Read check sum time-out failed -2 u32addr or u32count must be aligned with 4K

Definition at line 1039 of file fmc.c.

◆ FMC_GetVECMAP()

__STATIC_INLINE uint32_t FMC_GetVECMAP ( void  )

Get current vector mapping address.

Parameters
None
Returns
The current vector mapping address.

To get VECMAP value which is the page address for remapping to vector page (0x0).

Note
VECMAP only valid when new IAP function is enabled. (CBS = 10'b or 00'b)

Definition at line 165 of file fmc.h.

◆ FMC_GetXOMState()

int32_t FMC_GetXOMState ( uint32_t  u32XomNum)

Check the XOM is actived or not.

Parameters
[in]u32XomNumThe xom number(0~3).
Return values
1XOM is actived.
0XOM is not actived.
-2Invalid XOM number.

To get specify XOMRn(n=0~3) active status

Definition at line 374 of file fmc.c.

◆ FMC_Is_OTP_Locked()

int32_t FMC_Is_OTP_Locked ( uint32_t  otp_num)

Check the OTP is locked or not.

Parameters
[in]otp_numThe OTP number.
Return values
1OTP is locked.
0OTP is not locked.
-1Failed to read OTP lock bits.
-2Invalid OTP number.
Note
Global error code g_FMC_i32ErrCode -1 Failed to read OTP lock bits or read time-out -2 Invalid OTP number

Definition at line 891 of file fmc.c.

◆ FMC_Lock_OTP()

int32_t FMC_Lock_OTP ( uint32_t  otp_num)

Lock the specified OTP.

Parameters
[in]otp_numThe OTP number.
Return values
0Success
-1Failed to write OTP lock bits.
-2Invalid OTP number.
Note
Global error code g_FMC_i32ErrCode -1 Failed to write OTP lock bits or write time-out -2 Invalid OTP number

Definition at line 845 of file fmc.c.

◆ FMC_Open()

void FMC_Open ( void  )

Enable FMC ISP function.

Returns
None

Definition at line 415 of file fmc.c.

◆ FMC_Read()

uint32_t FMC_Read ( uint32_t  u32Addr)

Execute FMC_ISPCMD_READ command to read a word from flash.

Parameters
[in]u32AddrAddress of the flash location to be read. It must be a word aligned address.
Returns
The word data read from specified flash address. Return 0xFFFFFFFF if read failed.
Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 431 of file fmc.c.

◆ FMC_Read_64()

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.

Parameters
[in]u32addrAddress of the flash location to be read. It must be a double-word aligned address.
[out]u32data0Place holder of word 0 read from flash address u32addr.
[out]u32data1Place holder of word 0 read from flash address u32addr+4.
Returns
0 Success
-1 Failed
Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 463 of file fmc.c.

◆ FMC_Read_OTP()

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.

Parameters
[in]otp_numThe OTP number.
[in]low_wordLow word of the 64-bits data.
[in]high_wordLow word of the 64-bits data.
Return values
0Success
-1Read failed.
-2Invalid OTP number.
Note
Global error code g_FMC_i32ErrCode -1 Read failed or time-out -2 Invalid OTP number

Definition at line 795 of file fmc.c.

◆ FMC_ReadCID()

__STATIC_INLINE uint32_t FMC_ReadCID ( void  )

Read company ID.

Parameters
None
Returns
The company ID (32-bit). 0xFFFFFFFF means read failed.

The company ID of Nuvoton is fixed to be 0xDA

Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 179 of file fmc.h.

◆ FMC_ReadConfig()

int32_t FMC_ReadConfig ( uint32_t  u32Config[],
uint32_t  u32Count 
)

Execute FMC_ISPCMD_READ command to read User Configuration.

Parameters
[out]u32ConfigA two-word array. u32Config[0] holds CONFIG0, while u32Config[1] holds CONFIG1.
[in]u32CountAvailable word count in u32Config.
Returns
Success or not.
Return values
0Success.
-1Read failed
-2Invalid parameter.
Note
Global error code g_FMC_i32ErrCode -1 Read failed -2 Invalid parameter

Definition at line 946 of file fmc.c.

◆ FMC_ReadDataFlashBaseAddr()

uint32_t FMC_ReadDataFlashBaseAddr ( void  )

Get the base address of Data Flash if enabled.

Return values
Thebase address of Data Flash

Definition at line 500 of file fmc.c.

◆ FMC_ReadPID()

__STATIC_INLINE uint32_t FMC_ReadPID ( void  )

Read product ID.

Parameters
None
Returns
The product ID (32-bit). 0xFFFFFFFF means read failed.

This function is used to read product ID.

Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 212 of file fmc.h.

◆ FMC_ReadUCID()

__STATIC_INLINE uint32_t FMC_ReadUCID ( uint32_t  u32Index)

To read UCID.

Parameters
[in]u32IndexIndex of the UCID to read. u32Index must be 0, 1, 2, or 3.
Returns
The UCID of specified index. 0xFFFFFFFF means read failed.

This function is used to read unique chip ID (UCID).

Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 271 of file fmc.h.

◆ FMC_ReadUID()

__STATIC_INLINE uint32_t FMC_ReadUID ( uint8_t  u8Index)

Read Unique ID.

Parameters
[in]u8IndexUID index. 0 = UID[31:0], 1 = UID[63:32], 2 = UID[95:64]
Returns
The 32-bit unique ID data of specified UID index. 0xFFFFFFFF means read failed.

To read out 96-bit Unique ID.

Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 241 of file fmc.h.

◆ FMC_SetBootSource()

void FMC_SetBootSource ( int32_t  i32BootSrc)

Set boot source from LDROM or APROM after next software reset.

Parameters
[in]i32BootSrc1: Boot from LDROM 0: Boot from APROM
Returns
None

This function is used to switch APROM boot or LDROM boot. User need to call FMC_SetBootSource to select boot source first, then use CPU reset or System Reset Request to reset system.

Definition at line 515 of file fmc.c.

◆ FMC_SetSPKey()

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.

Parameters
[in]keyKey 0~2 to be setup.
[in]kpmaxMaximum unmatched power-on counting number.
[in]kemaxMaximum unmatched counting number.
[in]lock_CONFIG1: Security key lock CONFIG to write-protect. 0: Don't lock CONFIG.
[in]lock_SPROM1: Security key lock SPROM to write-protect. 0: Don't lock SPROM.
Return values
0Success.
-1Key is locked. Cannot overwrite the current key.
-2Failed to erase flash.
-3Program key time-out failed
-4Key lock function failed.
-5CONFIG lock function failed.
-6SPROM lock function failed.
-7KPMAX function failed.
-8KEMAX function failed.
Note
Global error code g_FMC_i32ErrCode Same as the return value of this function.

Definition at line 1157 of file fmc.c.

◆ FMC_SetVectorPageAddr()

__STATIC_INLINE int32_t FMC_SetVectorPageAddr ( uint32_t  u32PageAddr)

Set vector mapping address.

Parameters
[in]u32PageAddrThe page address to remap to address 0x0. The address must be page alignment.
Returns
To set VECMAP to remap specified page address to 0x0.

This function is used to set VECMAP to map specified page to vector page (0x0).

Return values
0Success
-1Failed
Note
VECMAP only valid when new IAP function is enabled. (CBS = 10'b or 00'b)
Global error code g_FMC_i32ErrCode -1 Command time-out

Definition at line 304 of file fmc.h.

◆ FMC_Write()

int32_t FMC_Write ( uint32_t  u32Addr,
uint32_t  u32Data 
)

Execute ISP FMC_ISPCMD_PROGRAM to program a word to flash.

Parameters
[in]u32AddrAddress of the flash location to be programmed. It must be a word aligned address.
[in]u32DataThe word data to be programmed.
Returns
0 Success
-1 Program Failed
Note
Global error code g_FMC_i32ErrCode -1 Program failed or time-out

Definition at line 538 of file fmc.c.

◆ FMC_Write8Bytes()

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.

Parameters
[in]u32addrAddress of the flash location to be programmed. It must be a double-word aligned address.
[in]u32data0The word data to be programmed to flash address u32addr.
[in]u32data1The word data to be programmed to flash address u32addr+4.
Returns
0 Success
-1 Failed
Note
Global error code g_FMC_i32ErrCode -1 Program failed or time-out

Definition at line 577 of file fmc.c.

◆ FMC_Write_OTP()

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.

Parameters
[in]otp_numThe OTP number.
[in]low_wordLow word of the 64-bits data.
[in]high_wordLow word of the 64-bits data.
Return values
0Success
-1Program failed.
-2Invalid OTP number.
Note
Global error code g_FMC_i32ErrCode -1 Program failed or time-out -2 Invalid OTP number

Definition at line 728 of file fmc.c.

◆ FMC_WriteConfig()

int32_t FMC_WriteConfig ( uint32_t  u32Config[],
uint32_t  u32Count 
)

Execute ISP commands to erase then write User Configuration.

Parameters
[in]u32ConfigA two-word array. u32Config[0] holds CONFIG0, while u32Config[1] holds CONFIG1.
[in]u32CountThe number of User Configuration words to be written.
Returns
Success or not.
Return values
0Success
-1Erase/program/read/verify failed
Note
Global error code g_FMC_i32ErrCode < 0 Errors caused by erase/program/read failed or time-out

Definition at line 979 of file fmc.c.

◆ FMC_WriteMultiple()

int32_t FMC_WriteMultiple ( uint32_t  u32Addr,
uint32_t  pu32Buf[],
uint32_t  u32Len 
)

Program Multi-Word data into specified address of flash.

Parameters
[in]u32AddrStart flash address in APROM where the data chunk to be programmed into. This address must be 8-bytes aligned to flash address.
[in]pu32BufBuffer that carry the data chunk.
[in]u32LenLength of the data chunk in bytes.
Return values
>=0Number of data bytes were programmed.
Returns
-1 Program failed.
-2 Invalid address.
Note
Global error code g_FMC_i32ErrCode -1 Program failed or time-out -2 Invalid address

Definition at line 620 of file fmc.c.

Variable Documentation

◆ g_FMC_i32ErrCode

int32_t g_FMC_i32ErrCode

Definition at line 28 of file fmc.c.