NANO103 BSP V3.01.004
The Board Support Package for Nano103 Series
Macros | Functions
Collaboration diagram for FMC Exported Functions:

Macros

#define FMC_SET_APROM_BOOT()   (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk)
 
#define FMC_SET_LDROM_BOOT()   (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk)
 
#define FMC_ENABLE_AP_UPDATE()   (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk)
 
#define FMC_DISABLE_AP_UPDATE()   (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk)
 
#define FMC_ENABLE_CFG_UPDATE()   (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk)
 
#define FMC_DISABLE_CFG_UPDATE()   (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk)
 
#define FMC_ENABLE_LD_UPDATE()   (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk)
 
#define FMC_DISABLE_LD_UPDATE()   (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk)
 
#define FMC_DISABLE_ISP()   (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk)
 
#define FMC_ENABLE_ISP()   (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk)
 
#define FMC_GET_FAIL_FLAG()   ((FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) ? 1 : 0)
 
#define FMC_CLR_FAIL_FLAG()   (FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk)
 

Functions

void FMC_Close (void)
 Disable FMC ISP function. More...
 
int32_t FMC_Erase (uint32_t u32PageAddr)
 Execute FMC_ISPCMD_PAGE_ERASE command to erase a flash page. The page size is 512 bytes. 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 ISP command to read a word from flash. More...
 
uint32_t FMC_ReadCID (void)
 Read company ID. More...
 
uint32_t FMC_ReadPID (void)
 Read product ID. More...
 
uint32_t FMC_ReadUCID (uint32_t u32Index)
 This function reads one of the four UCID. More...
 
uint32_t FMC_ReadUID (uint32_t u32Index)
 This function reads one of the three UID. More...
 
uint32_t FMC_ReadDataFlashBaseAddr (void)
 Get the base address of Data Flash if enabled. More...
 
void FMC_SetVectorPageAddr (uint32_t u32PageAddr)
 This function will force re-map assigned flash page to CPU address 0x0. More...
 
uint32_t FMC_GetVectorPageAddr (void)
 Obtain the current vector page address setting. More...
 
int32_t FMC_Write (uint32_t u32Addr, uint32_t u32Data)
 Execute ISP command to program a word to flash. More...
 
int32_t FMC_ReadConfig (uint32_t *u32Config, uint32_t u32Count)
 Execute ISP command to read User Configuration. More...
 
int32_t FMC_WriteConfig (uint32_t *u32Config, uint32_t u32Count)
 Execute ISP command to write User Configuration. More...
 
int32_t FMC_GetChkSum (uint32_t u32Addr, uint32_t u32Count, uint32_t *u32ChkSum)
 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_SKey_Setup (uint32_t key[3], uint32_t kpmax, uint32_t kemax, int lock_CONFIG)
 Setup security key. More...
 
int32_t FMC_SKey_Compare (uint32_t key[3])
 Execute security key comparison. More...
 

Detailed Description

Macro Definition Documentation

◆ FMC_CLR_FAIL_FLAG

#define FMC_CLR_FAIL_FLAG ( )    (FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk)

Clear ISP fail flag

Definition at line 104 of file fmc.h.

◆ FMC_DISABLE_AP_UPDATE

#define FMC_DISABLE_AP_UPDATE ( )    (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk)

Disable APROM update

Definition at line 96 of file fmc.h.

◆ FMC_DISABLE_CFG_UPDATE

#define FMC_DISABLE_CFG_UPDATE ( )    (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk)

Disable User Config update

Definition at line 98 of file fmc.h.

◆ FMC_DISABLE_ISP

#define FMC_DISABLE_ISP ( )    (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk)

Disable ISP function

Definition at line 101 of file fmc.h.

◆ FMC_DISABLE_LD_UPDATE

#define FMC_DISABLE_LD_UPDATE ( )    (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk)

Disable LDROM update

Definition at line 100 of file fmc.h.

◆ FMC_ENABLE_AP_UPDATE

#define FMC_ENABLE_AP_UPDATE ( )    (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk)

Enable APROM update

Definition at line 95 of file fmc.h.

◆ FMC_ENABLE_CFG_UPDATE

#define FMC_ENABLE_CFG_UPDATE ( )    (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk)

Enable User Config update

Definition at line 97 of file fmc.h.

◆ FMC_ENABLE_ISP

#define FMC_ENABLE_ISP ( )    (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk)

Enable ISP function

Definition at line 102 of file fmc.h.

◆ FMC_ENABLE_LD_UPDATE

#define FMC_ENABLE_LD_UPDATE ( )    (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk)

Enable LDROM update

Definition at line 99 of file fmc.h.

◆ FMC_GET_FAIL_FLAG

#define FMC_GET_FAIL_FLAG ( )    ((FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) ? 1 : 0)

Get ISP fail flag

Definition at line 103 of file fmc.h.

◆ FMC_SET_APROM_BOOT

#define FMC_SET_APROM_BOOT ( )    (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk)

Select booting from APROM

Definition at line 93 of file fmc.h.

◆ FMC_SET_LDROM_BOOT

#define FMC_SET_LDROM_BOOT ( )    (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk)

Select booting from LDROM

Definition at line 94 of file fmc.h.

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 512 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 448 of file fmc.c.

◆ FMC_Close()

void FMC_Close ( void  )

Disable FMC ISP function.

Returns
None

Definition at line 38 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 512 bytes.

Parameters
[in]u32PageAddrAddress of the flash page to be erased. It must be a 512-byte aligned address.
Returns
ISP page erase success or not.
Return values
0Success
-1Erase failed

Definition at line 51 of file fmc.c.

Here is the caller graph for this function:

◆ 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.

Definition at line 87 of file fmc.c.

◆ FMC_GetChkSum()

int32_t FMC_GetChkSum ( uint32_t  u32Addr,
uint32_t  u32Count,
uint32_t *  u32ChkSum 
)

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 512 bytes.
[out]u32ChkSumThe CRC32 checksum if caculation is successful.
Returns
Success or not.
Return values
0Success
-1Failed
-2Invalid parameter.
Note
Global error code g_FMC_i32ErrCode -1 Run/Read check sum time-out failed -2 u32addr or u32count must be aligned with 512

Definition at line 387 of file fmc.c.

◆ FMC_GetVectorPageAddr()

uint32_t FMC_GetVectorPageAddr ( void  )

Obtain the current vector page address setting.

Returns
The vector page address.

Definition at line 294 of file fmc.c.

◆ FMC_Open()

void FMC_Open ( void  )

Enable FMC ISP function.

Returns
None

Definition at line 100 of file fmc.c.

◆ FMC_Read()

uint32_t FMC_Read ( uint32_t  u32Addr)

Execute ISP 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 116 of file fmc.c.

Here is the caller graph for this function:

◆ FMC_ReadCID()

uint32_t FMC_ReadCID ( void  )

Read company ID.

Returns
The company ID.
Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 144 of file fmc.c.

◆ FMC_ReadConfig()

int32_t FMC_ReadConfig ( uint32_t *  u32Config,
uint32_t  u32Count 
)

Execute ISP 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.
-1Invalid parameter.

Definition at line 343 of file fmc.c.

Here is the call graph for this function:

◆ FMC_ReadDataFlashBaseAddr()

uint32_t FMC_ReadDataFlashBaseAddr ( void  )

Get the base address of Data Flash if enabled.

Returns
The base address of Data Flash

Definition at line 259 of file fmc.c.

◆ FMC_ReadPID()

uint32_t FMC_ReadPID ( void  )

Read product ID.

Returns
The product ID.
Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 173 of file fmc.c.

◆ FMC_ReadUCID()

uint32_t FMC_ReadUCID ( uint32_t  u32Index)

This function reads one of the four UCID.

Parameters
[in]u32IndexIndex of the UCID to read. u32Index must be 0, 1, 2, or 3.
Returns
The UCID.
Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 203 of file fmc.c.

◆ FMC_ReadUID()

uint32_t FMC_ReadUID ( uint32_t  u32Index)

This function reads one of the three UID.

Parameters
[in]u32IndexIndex of the UID to read. u32Index must be 0, 1, or 2.
Returns
The UID.
Note
Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 233 of file fmc.c.

◆ FMC_SetVectorPageAddr()

void FMC_SetVectorPageAddr ( uint32_t  u32PageAddr)

This function will force re-map assigned flash page to CPU address 0x0.

Parameters
[in]u32PageAddrAddress of the page to be mapped to CPU address 0x0.
Returns
None
Note
Global error code g_FMC_i32ErrCode -1 Time-out

Definition at line 273 of file fmc.c.

◆ FMC_SKey_Compare()

int32_t FMC_SKey_Compare ( uint32_t  key[3])

Execute security key comparison.

Parameters
[in]keyKey0~2 to be compared.
Return values
0Key matched.
-1Forbidden. Times of key comparison mismatch has reached the maximum count.
-2Key mismatched.
-3No security key lock. Key comparison is not required.
Note
Global error code g_FMC_i32ErrCode Same as the return value of this function.

Definition at line 610 of file fmc.c.

◆ FMC_SKey_Setup()

int32_t FMC_SKey_Setup ( uint32_t  key[3],
uint32_t  kpmax,
uint32_t  kemax,
int  lock_CONFIG 
)

Setup security key.

Parameters
[in]keyKey0~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.
Return values
0Success.
-1Key has been setup, It's not allowed to setup key again.
-2Failed to erase flash.
-3Failed to program key.
-4Key lock function failed.
-5CONFIG 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 523 of file fmc.c.

Here is the call graph for this function:

◆ FMC_Write()

int32_t FMC_Write ( uint32_t  u32Addr,
uint32_t  u32Data 
)

Execute ISP command 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 311 of file fmc.c.

Here is the caller graph for this function:

◆ FMC_WriteConfig()

int32_t FMC_WriteConfig ( uint32_t *  u32Config,
uint32_t  u32Count 
)

Execute ISP command to write User Configuration.

Parameters
[in]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.
-1Invalid parameter.

Definition at line 362 of file fmc.c.

Here is the call graph for this function: