| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

Macros | Functions | Variables
FMC Exported Functions
NUC472/NUC442 Device Driver » FMC Driver » FMC Exported Constants
Collaboration diagram for FMC Exported Functions:

## Macros
#define | FMC_SET_APROM_BOOT()
| This macro selects booting from APROM. More...
#define | FMC_SET_LDROM_BOOT()
| This macro selects booting from LDROM. More...
#define | FMC_ENABLE_AP_UPDATE()
| This macro enables APROM update function. More...
#define | FMC_DISABLE_AP_UPDATE()
| This macro disables APROM update function. More...
#define | FMC_ENABLE_CFG_UPDATE()
| This macro enables User Configuration update function. More...
#define | FMC_DISABLE_CFG_UPDATE()
| This macro disables User Configuration update function. More...
#define | FMC_ENABLE_LD_UPDATE()
| This macro enables LDROM update function. More...
#define | FMC_DISABLE_LD_UPDATE()
| This macro disables LDROM update function. More...
#define | FMC_ENABLE_ISP()
| This macro enables ISP function. More...
#define | FMC_DISABLE_ISP()
| This macro disables ISP function. More...
#define | FMC_GET_FAIL_FLAG()
| This macro gets ISP fail flag value. More...
#define | FMC_CLR_FAIL_FLAG()
| This macro clears ISP fail flag. More...

## Functions
void | FMC_Close (void)
| Disable FMC ISP function. More...
int32_t | FMC_Erase (uint32_t u32PageAddr)
| Erase a page. The page size is 2048 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...
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. 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...
int32_t | 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_Write_64 (uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1)
| Execute ISP 64-bits write command to program two words to flash. More...
int32_t | FMC_ReadConfig (uint32_t *u32Config, uint32_t u32Count)
| Read the User Configuration words. More...
int32_t | FMC_WriteConfig (uint32_t *u32Config, uint32_t u32Count)
| Write User Configuration. More...
uint32_t | FMC_CRC8 (uint32_t au32Data[], int i32Count)
| CRC8 Calculator. More...

## Variables
int32_t | g_FMC_i32ErrCode
int32_t | g_FMC_i32ErrCode

## Detailed Description

## Macro Definition Documentation

## ◆ FMC_CLR_FAIL_FLAG

#define FMC_CLR_FAIL_FLAG | ( |  | ) |

This macro clears ISP fail flag.

Parameters

  None |

Returns
  None Clear ISP fail flag

Definition at line 176 of file fmc.h.

## ◆ FMC_DISABLE_AP_UPDATE

#define FMC_DISABLE_AP_UPDATE | ( |  | ) |

This macro disables APROM update function.

Parameters

  None |

Returns
  None

Definition at line 112 of file fmc.h.

## ◆ FMC_DISABLE_CFG_UPDATE

#define FMC_DISABLE_CFG_UPDATE | ( |  | ) |

This macro disables User Configuration update function.

Parameters

  None |

Returns
  None

Definition at line 128 of file fmc.h.

## ◆ FMC_DISABLE_ISP

#define FMC_DISABLE_ISP | ( |  | ) |

This macro disables ISP function.

Parameters

  None |

Returns
  None

Definition at line 160 of file fmc.h.

## ◆ FMC_DISABLE_LD_UPDATE

#define FMC_DISABLE_LD_UPDATE | ( |  | ) |

This macro disables LDROM update function.

Parameters

  None |

Returns
  None

Definition at line 144 of file fmc.h.

## ◆ FMC_ENABLE_AP_UPDATE

#define FMC_ENABLE_AP_UPDATE | ( |  | ) |

This macro enables APROM update function.

Parameters

  None |

Returns
  None

Definition at line 104 of file fmc.h.

## ◆ FMC_ENABLE_CFG_UPDATE

#define FMC_ENABLE_CFG_UPDATE | ( |  | ) |

This macro enables User Configuration update function.

Parameters

  None |

Returns
  None

Definition at line 120 of file fmc.h.

## ◆ FMC_ENABLE_ISP

#define FMC_ENABLE_ISP | ( |  | ) |

This macro enables ISP function.

Parameters

  None |

Returns
  None Enable ISP function

Definition at line 152 of file fmc.h.

## ◆ FMC_ENABLE_LD_UPDATE

#define FMC_ENABLE_LD_UPDATE | ( |  | ) |

This macro enables LDROM update function.

Parameters

  None |

Returns
  None

Definition at line 136 of file fmc.h.

## ◆ FMC_GET_FAIL_FLAG

#define FMC_GET_FAIL_FLAG | ( |  | ) |

This macro gets ISP fail flag value.

Parameters

  None |

Returns
  ISP fail flag value.

Definition at line 168 of file fmc.h.

## ◆ FMC_SET_APROM_BOOT

#define FMC_SET_APROM_BOOT | ( |  | ) |

This macro selects booting from APROM.

Parameters

  None |

Returns
  None

Definition at line 88 of file fmc.h.

## ◆ FMC_SET_LDROM_BOOT

#define FMC_SET_LDROM_BOOT | ( |  | ) |

This macro selects booting from LDROM.

Parameters

  None |

Returns
  None

Definition at line 96 of file fmc.h.

## Function Documentation

## ◆ FMC_Close()

void FMC_Close | ( | void |  | ) |

Disable FMC ISP function.

Returns
  None

Definition at line 37 of file fmc.c.

## ◆ FMC_CRC8()

uint32_t FMC_CRC8 | ( | uint32_t | au32Data[],
|  | int | i32Count
| ) |  |

CRC8 Calculator.

Parameters

  [in] | au32Data | CRC8 input data words.
  [in] | i32Count | Number of words in au32Data[].

Returns
  The CRC8 value.

Definition at line 407 of file fmc.c.

Here is the caller graph for this function:

## ◆ FMC_Erase()

int32_t FMC_Erase | ( | uint32_t | u32PageAddr | ) |

Erase a page. The page size is 2048 bytes.

Parameters

  [in] | u32PageAddr | Flash page address. Must be a 2048-byte aligned address.

Returns
  Success or not.

Return values

  0 | Success
  -1 | Erase failed

Note
  Global error code g_FMC_i32ErrCode -1 Erase failed or erase time-out

Definition at line 53 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

  0 | Is boot from APROM.
  1 | Is boot from LDROM.

Definition at line 84 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 319 of file fmc.c.

## ◆ FMC_Open()

void FMC_Open | ( | void |  | ) |

Enable FMC ISP function.

Returns
  None

Definition at line 97 of file fmc.c.

## ◆ FMC_Read()

uint32_t FMC_Read | ( | uint32_t | u32Addr | ) |

Execute ISP command to read a word from flash.

Parameters

  [in] | u32Addr | Address 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 113 of file fmc.c.

Here is the caller graph for this function:

## ◆ FMC_Read_64()

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.

Parameters

  [in] | u32Addr | Flash word address. Must be a double word aligned address.
  [out] | u32Data0 | The first word read from flash.
  [out] | u32Data1 | The second word read from flash.

Returns
  0 Success
  -1 Failed

Note
  Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 143 of file fmc.c.

## ◆ FMC_ReadCID()

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

## ◆ FMC_ReadConfig()

int32_t FMC_ReadConfig | ( | uint32_t * | u32Config,
|  | uint32_t | u32Count
| ) |  |

Read the User Configuration words.

Parameters

  [out] | u32Config | The word array to store words read from flash.
  [in] | u32Count | Maximum length of u32Config.

Returns
  Success or not.

Return values

  0 | Success
  -1 | User Configuration CRC check error

Definition at line 446 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
  Base address of Data Flash

Definition at line 282 of file fmc.c.

## ◆ FMC_ReadPID()

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

## ◆ FMC_ReadUCID()

uint32_t FMC_ReadUCID | ( | uint32_t | u32Index | ) |

This function reads one of the four UCID.

Parameters

  [in] | u32Index | Index 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 233 of file fmc.c.

## ◆ FMC_ReadUID()

uint32_t FMC_ReadUID | ( | uint32_t | u32Index | ) |

This function reads one of the three UID.

Parameters

  [in] | u32Index | Index of the UID to read. u32Index must be 0, 1, or 2.

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

## ◆ FMC_SetVectorPageAddr()

int32_t FMC_SetVectorPageAddr | ( | uint32_t | u32PageAddr | ) |

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

Parameters

  [in] | u32PageAddr | Address of the page to be mapped to CPU address 0x0.

Return values

  0 | Success
  -1 | Failed

Note
  Global error code g_FMC_i32ErrCode -1 Command time-out

Definition at line 297 of file fmc.c.

## ◆ FMC_Write()

int32_t FMC_Write | ( | uint32_t | u32Addr,
|  | uint32_t | u32Data
| ) |  |

Execute ISP command to program a word to flash.

Parameters

  [in] | u32Addr | Address of the flash location to be programmed. It must be a word aligned address.
  [out] | u32Data | The word data to be programmed.

Returns
  None
  0 Success
  -1 Program Failed

Note
  Global error code g_FMC_i32ErrCode -1 Program failed or time-out

Definition at line 337 of file fmc.c.

Here is the caller graph for this function:

## ◆ FMC_Write_64()

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.

Parameters

  [in] | u32Addr | Destination address. It must be double word aligned.
  [in] | u32Data0 | First word data to be written.
  [in] | u32Data1 | Second word data to be written.

Returns
  0 Success
  -1 Failed

Note
  Global error code g_FMC_i32ErrCode -1 Program failed or time-out

Definition at line 374 of file fmc.c.

## ◆ FMC_WriteConfig()

int32_t FMC_WriteConfig | ( | uint32_t * | u32Config,
|  | uint32_t | u32Count
| ) |  |

Write User Configuration.

Parameters

  [in] | u32Config | The word array to store data. MUST be a four word array.
  [in] | u32Count | MUST be 4.

Returns
  Success or not.

Return values

  0 | Success
  -1 | Failed

Note
  Global error code g_FMC_i32ErrCode < 0 Errors caused by erase/program/read failed or time-out

Definition at line 473 of file fmc.c.

Here is the call graph for this function:

## Variable Documentation

## ◆ g_FMC_i32ErrCode [1/2]

int32_t g_FMC_i32ErrCode
| extern

Definition at line 31 of file fmc.c.

## ◆ g_FMC_i32ErrCode [2/2]

int32_t g_FMC_i32ErrCode

Definition at line 31 of file fmc.c.