MINI58_BSP V3.01.005
The Board Support Package for Mini58 Series MCU
fmc.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __FMC_H__
13#define __FMC_H__
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
31/*---------------------------------------------------------------------------------------------------------*/
32/* Define Base Address */
33/*---------------------------------------------------------------------------------------------------------*/
34#define FMC_APROM_BASE 0x00000000UL
35#define FMC_APROM_END 0x00008000UL
36#define FMC_LDROM_BASE 0x00100000UL
37#define FMC_LDROM_END 0x00100A00UL
38#define FMC_SPROM_BASE 0x00200000UL
39#define FMC_SPROM_END 0x00200200UL
40#define FMC_CONFIG_BASE 0x00300000UL
42#define FMC_FLASH_PAGE_SIZE 0x200
43#define FMC_LDROM_SIZE 0xA00
44#define FMC_SPROM_SIZE 0x200
46#define FMC_TIMEOUT_READ ((SystemCoreClock/10)*2)
47#define FMC_TIMEOUT_WRITE ((SystemCoreClock/10)*2)
48#define FMC_TIMEOUT_ERASE ((SystemCoreClock/10)*4)
49#define FMC_TIMEOUT_CHKSUM (SystemCoreClock*2)
52/*---------------------------------------------------------------------------------------------------------*/
53/* ISPCMD constant definitions */
54/*---------------------------------------------------------------------------------------------------------*/
55#define FMC_ISPCMD_READ 0x00
56#define FMC_ISPCMD_READ_UID 0x04
57#define FMC_ISPCMD_READ_CID 0x0B
58#define FMC_ISPCMD_READ_PID 0x0C
59#define FMC_ISPCMD_READ_CRC32 0x0D
60#define FMC_ISPCMD_PROGRAM 0x21
61#define FMC_ISPCMD_PAGE_ERASE 0x22
62#define FMC_ISPCMD_CAL_CRC32 0x2D
63#define FMC_ISPCMD_VECMAP 0x2E /* end of group Mini58_FMC_EXPORTED_CONSTANTS */
67
68/*---------------------------------------------------------------------------------------------------------*/
69/* Global variables */
70/*---------------------------------------------------------------------------------------------------------*/
71extern int32_t g_FMC_i32ErrCode;
72
77#define FMC_SET_APROM_BOOT() (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk)
78#define FMC_SET_LDROM_BOOT() (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk)
79#define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk)
80#define FMC_DISABLE_SP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_SPUEN_Msk)
81#define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk)
82#define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk)
83#define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk)
84#define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk)
85#define FMC_ENABLE_SP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_SPUEN_Msk)
86#define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk)
87#define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk)
88#define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk)
89#define FMC_GET_FAIL_FLAG() ((FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) ? 1 : 0)
92extern void FMC_Close(void);
93extern int32_t FMC_Erase(uint32_t u32PageAddr);
94extern int32_t FMC_GetBootSource(void);
95extern void FMC_Open(void);
96extern uint32_t FMC_Read (uint32_t u32Addr);
97extern uint32_t FMC_ReadCID(void);
98extern uint32_t FMC_ReadPID(void);
99extern uint32_t FMC_ReadUCID(uint32_t u32Index);
100extern uint32_t FMC_ReadUID(uint32_t u32Index);
101extern uint32_t FMC_ReadDataFlashBaseAddr(void);
102extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr);
103extern uint32_t FMC_GetVectorPageAddr(void);
104extern int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data);
105extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
106extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count);
107extern int32_t FMC_GetCRC32Sum(uint32_t addr, uint32_t count, uint32_t *chksum);
108
109 /* end of group Mini58_FMC_EXPORTED_FUNCTIONS */
111 /* end of group Mini58_FMC_Driver */
113 /* end of group Mini58_Device_Driver */
115
116#ifdef __cplusplus
117}
118#endif
119
120
121#endif
122/*** (C) COPYRIGHT 2022 Nuvoton Technology Corp. ***/
123
int32_t g_FMC_i32ErrCode
Definition: fmc.c:30
void FMC_Close(void)
Disable all FMC functions.
Definition: fmc.c:37
int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count)
Read the User Configuration words.
Definition: fmc.c:294
void FMC_SetVectorPageAddr(uint32_t u32PageAddr)
This function will force re-map assigned flash page to CPU address 0x0.
Definition: fmc.c:235
uint32_t FMC_ReadCID(void)
Read company ID.
Definition: fmc.c:125
uint32_t FMC_GetVectorPageAddr(void)
Obtain the current vector page address setting.
Definition: fmc.c:252
uint32_t FMC_ReadUID(uint32_t u32Index)
This function reads one of the three UID.
Definition: fmc.c:200
int32_t FMC_GetCRC32Sum(uint32_t addr, uint32_t count, uint32_t *chksum)
Calculate and read the CRC32 checksum of a specified flash area.
Definition: fmc.c:347
int32_t FMC_Erase(uint32_t u32PageAddr)
Erase a page. The page size is 512 bytes.
Definition: fmc.c:51
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
Definition: fmc.c:222
int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Writes a word data to specified flash address.
Definition: fmc.c:267
uint32_t FMC_Read(uint32_t u32Addr)
Read a word from specified flash address.
Definition: fmc.c:100
uint32_t FMC_ReadPID(void)
Read product ID.
Definition: fmc.c:149
int32_t FMC_GetBootSource(void)
get the current boot source
Definition: fmc.c:74
int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count)
Write User Configuration.
Definition: fmc.c:318
void FMC_Open(void)
Enable FMC ISP function.
Definition: fmc.c:86
uint32_t FMC_ReadUCID(uint32_t u32Index)
This function reads one of the four UCID.
Definition: fmc.c:174