Nano100AN Series BSP  V3.02.002
The Board Support Package for Nano100AN Series
fmc.h
Go to the documentation of this file.
1 /**************************************************************************/
13 #ifndef __FMC_H__
14 #define __FMC_H__
15 
16 #ifdef __cplusplus
17 extern "C"
18 {
19 #endif
20 
35 /*---------------------------------------------------------------------------------------------------------*/
36 /* Define Base Address */
37 /*---------------------------------------------------------------------------------------------------------*/
38 #define FMC_APROM_BASE 0x00000000UL
39 #define FMC_APROM_END 0x00010000UL
40 #define FMC_LDROM_BASE 0x00100000UL
41 #define FMC_LDROM_END 0x00101000UL
42 #define FMC_CONFIG_BASE 0x00300000UL
44 #define FMC_FLASH_PAGE_SIZE 0x200
45 #define FMC_LDROM_SIZE 0x1000
47 /*---------------------------------------------------------------------------------------------------------*/
48 /* ISPCMD constant definitions */
49 /*---------------------------------------------------------------------------------------------------------*/
50 #define FMC_ISPCMD_READ 0x00
51 #define FMC_ISPCMD_PROGRAM 0x21
52 #define FMC_ISPCMD_PAGE_ERASE 0x22
53 #define FMC_ISPCMD_READ_CID 0x0B
54 #define FMC_ISPCMD_READ_PID 0x0C
55 #define FMC_ISPCMD_READ_UID 0x04
56 #define FMC_ISPCMD_VECMAP 0x2E
58 #define IS_BOOT_FROM_APROM 0
59 #define IS_BOOT_FROM_LDROM 1
62  /* end of group NANO100_FMC_EXPORTED_CONSTANTS */
63 
64 
69 /*---------------------------------------------------------------------------------------------------------*/
70 /* Macros */
71 /*---------------------------------------------------------------------------------------------------------*/
72 
79 #define FMC_SET_APROM_BOOT() (FMC->ISPCON &= ~FMC_ISPCON_BS_Msk)
80 
87 #define FMC_SET_LDROM_BOOT() (FMC->ISPCON |= FMC_ISPCON_BS_Msk)
88 
95 #define FMC_ENABLE_AP_UPDATE() (FMC->ISPCON |= FMC_ISPCON_APUEN_Msk)
96 
103 #define FMC_DISABLE_AP_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_APUEN_Msk)
104 
111 #define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCON |= FMC_ISPCON_CFGUEN_Msk)
112 
119 #define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_CFGUEN_Msk)
120 
127 #define FMC_ENABLE_LD_UPDATE() (FMC->ISPCON |= FMC_ISPCON_LDUEN_Msk)
128 
135 #define FMC_DISABLE_LD_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_LDUEN_Msk)
136 
143 #define FMC_ENABLE_ISP() (FMC->ISPCON |= FMC_ISPCON_ISPEN_Msk)
144 
151 #define FMC_DISABLE_ISP() (FMC->ISPCON &= ~FMC_ISPCON_ISPEN_Msk)
152 
159 #define FMC_GET_FAIL_FLAG() ((FMC->ISPCON & FMC_ISPCON_ISPFF_Msk) ? 1 : 0)
160 
167 #define FMC_CLR_FAIL_FLAG() (FMC->ISPCON |= FMC_ISPCON_ISPFF_Msk)
168 
169 /*---------------------------------------------------------------------------------------------------------*/
170 /* Functions */
171 /*---------------------------------------------------------------------------------------------------------*/
172 
173 extern void FMC_Close(void);
174 extern int32_t FMC_Erase(uint32_t u32PageAddr);
175 extern int32_t FMC_GetBootSource(void);
176 extern void FMC_Open(void);
177 extern uint32_t FMC_Read(uint32_t u32Addr);
178 extern uint32_t FMC_ReadCID(void);
179 extern uint32_t FMC_ReadPID(void);
180 extern uint32_t FMC_ReadUCID(uint32_t u32Index);
181 extern uint32_t FMC_ReadUID(uint32_t u32Index);
182 extern uint32_t FMC_ReadDataFlashBaseAddr(void);
183 extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr);
184 extern uint32_t FMC_GetVectorPageAddr(void);
185 extern void FMC_Write(uint32_t u32Addr, uint32_t u32Data);
186 extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
187 extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count);
188 
189  /* end of group NANO100_FMC_EXPORTED_FUNCTIONS */
191  /* end of group NANO100_FMC_Driver */
193  /* end of group NANO100_Device_Driver */
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif // __FMC_H__
201 
202 /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
uint32_t FMC_ReadUID(uint32_t u32Index)
This function reads one of the three UID.
Definition: fmc.c:161
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
Definition: fmc.c:177
void FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Execute ISP command to program a word to flash.
Definition: fmc.c:214
void FMC_Open(void)
Enable FMC ISP function.
Definition: fmc.c:87
int32_t FMC_Erase(uint32_t u32PageAddr)
Execute ISP command to erase a flash page. The page size is 512 bytes.
Definition: fmc.c:51
uint32_t FMC_GetVectorPageAddr(void)
Obtain the current vector page address setting.
Definition: fmc.c:201
uint32_t FMC_ReadUCID(uint32_t u32Index)
This function reads one of the four UCID.
Definition: fmc.c:144
uint32_t FMC_ReadCID(void)
Read company ID.
Definition: fmc.c:115
uint32_t FMC_Read(uint32_t u32Addr)
Execute ISP command to read a word from flash.
Definition: fmc.c:99
uint32_t FMC_ReadPID(void)
Read product ID.
Definition: fmc.c:129
void FMC_SetVectorPageAddr(uint32_t u32PageAddr)
This function will force re-map assigned flash page to CPU address 0x0.
Definition: fmc.c:188
int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count)
Execute ISP command to read User Configuration.
Definition: fmc.c:233
int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count)
Execute ISP command to write User Configuration.
Definition: fmc.c:252
void FMC_Close(void)
Disable FMC ISP function.
Definition: fmc.c:37
int32_t FMC_GetBootSource(void)
Get the current boot source.
Definition: fmc.c:74