| MINI58_BSP V3.01.003 The Board Support Package for Mini58 Series MCU

Macros | Functions | Variables
FMC Exported Functions
Mini58 Device Driver » FMC Driver » FMC Exported Constants
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_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk)
#define | FMC_DISABLE_SP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_SPUEN_Msk)
#define | FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_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_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk)
#define | FMC_ENABLE_SP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_SPUEN_Msk)
#define | FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk)
#define | FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk)
#define | FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk)
#define | FMC_GET_FAIL_FLAG() ((FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) ? 1 : 0)

## Functions
void | FMC_Close (void)
| Disable all FMC functions. More...
int32_t | FMC_Erase (uint32_t u32PageAddr)
| Erase a 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)
| Read a word from specified flash address. 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)
| Writes a word data to specified flash address. 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...
int32_t | FMC_GetCRC32Sum (uint32_t addr, uint32_t count, uint32_t *chksum)
| Calculate and read the CRC32 checksum of a specified flash area. More...

## Variables
int32_t | g_FMC_i32ErrCode

## Detailed Description

## Macro Definition Documentation

## ◆ FMC_DISABLE_AP_UPDATE

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

Disable APROM update

Definition at line 79 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 81 of file fmc.h.

## ◆ FMC_DISABLE_ISP

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

Disable ISP function

Definition at line 83 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 82 of file fmc.h.

## ◆ FMC_DISABLE_SP_UPDATE

#define FMC_DISABLE_SP_UPDATE | ( |  | ) | (FMC->ISPCTL &= ~FMC_ISPCTL_SPUEN_Msk)

Disable SPROM update

Definition at line 80 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 84 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 87 of file fmc.h.

## ◆ FMC_ENABLE_ISP

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

Enable ISP function

Definition at line 88 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 86 of file fmc.h.

## ◆ FMC_ENABLE_SP_UPDATE

#define FMC_ENABLE_SP_UPDATE | ( |  | ) | (FMC->ISPCTL |= FMC_ISPCTL_SPUEN_Msk)

Enable SPROM update

Definition at line 85 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 89 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 77 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 78 of file fmc.h.

## Function Documentation

## ◆ FMC_Close()

void FMC_Close | ( | void |  | ) |

Disable all FMC functions.

Returns
  None

Definition at line 37 of file fmc.c.

## ◆ FMC_Erase()

int32_t FMC_Erase | ( | uint32_t | u32PageAddr | ) |

Erase a page. The page size is 512 bytes.

Parameters

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

Return values

  0 | Success
  -1 | Erase failed or time-out

Note
  Global error code g_FMC_i32ErrCode -1 time-out error

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

Return values

  0 | This chip is currently booting from APROM
  1 | This chip is currently booting from LDROM

Definition at line 74 of file fmc.c.

## ◆ FMC_GetCRC32Sum()

int32_t FMC_GetCRC32Sum | ( | uint32_t | addr,
|  | uint32_t | count,
|  | uint32_t * | chksum
| ) |  |

Calculate and read the CRC32 checksum of a specified flash area.

Parameters

  [in] | addr | Start address of the flash area to be executed CRC32 checksum calculation.
  [in] | count | Number of bytes to be calculated.
  [out] | chksum | If success, it will contain the result of CRC32 checksum calculation.

Return values

  0 | Success
  -1 | Timeout or error.

Note
  Global error code g_FMC_i32ErrCode -1 time-out

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

## ◆ FMC_Open()

void FMC_Open | ( | void |  | ) |

Enable FMC ISP function.

Definition at line 86 of file fmc.c.

## ◆ FMC_Read()

uint32_t FMC_Read | ( | uint32_t | u32Addr | ) |

Read a word from specified flash address.

Parameters

  [in] | u32Addr | Flash word address. Must be a word aligned address.

Returns
  The word data stored in the flash address "u32Addr".

Note
  Global error code g_FMC_i32ErrCode -1 Read time-out

To read word data from Flash include APROM, LDROM, Data Flash, and CONFIG.

Definition at line 100 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. Return 0xFFFFFFFF if read failed.

Note
  Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 125 of file fmc.c.

## ◆ FMC_ReadConfig()

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

Read the User Configuration words.

Parameters

  [in] | u32Config | The word array to store data.
  [in] | u32Count | Maximum length of "u32Config".

Return values

  0 | Success
  -1 | Failed

Note
  Global error code g_FMC_i32ErrCode -1 time-out

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

## ◆ FMC_ReadPID()

uint32_t FMC_ReadPID | ( | void |  | ) |

Read product ID.

Returns
  The product ID. Return 0xFFFFFFFF if read failed.

Note
  Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 149 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. Return 0xFFFFFFFF if read failed.

Note
  Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 174 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 UID. Return 0xFFFFFFFF if read failed.

Note
  Global error code g_FMC_i32ErrCode -1 Read time-out

Definition at line 200 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] | u32PageAddr | Address 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 235 of file fmc.c.

## ◆ FMC_Write()

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

Writes a word data to specified flash address.

Parameters

  [in] | u32Addr | Destination address
  [in] | u32Data | Word data to be written

Returns
  None

Note
  Global error code g_FMC_i32ErrCode -1 time-out

Definition at line 267 of file fmc.c.

Here is the caller graph for this function:

## ◆ FMC_WriteConfig()

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

Write User Configuration.

Parameters

  [in] | u32Config | The word array to store data.
  [in] | u32Count | Maximum length of "u32Config".

Return values

  0 | Success
  -1 | Failed

Note
  Global error code g_FMC_i32ErrCode -1 time-out

Definition at line 318 of file fmc.c.

Here is the call graph for this function:

## Variable Documentation

## ◆ g_FMC_i32ErrCode

int32_t g_FMC_i32ErrCode

Definition at line 30 of file fmc.c.