| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN 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 0x0001EC00UL
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#define FMC_TIMEOUT_READ ((SystemCoreClock/10)*2)
48#define FMC_TIMEOUT_WRITE ((SystemCoreClock/10)*2)
49#define FMC_TIMEOUT_ERASE ((SystemCoreClock/10)*4)
50#define FMC_TIMEOUT_CHKSUM (SystemCoreClock*2)
52/*---------------------------------------------------------------------------------------------------------*/
53/* ISPCMD constant definitions */
54/*---------------------------------------------------------------------------------------------------------*/
55#define FMC_ISPCMD_READ 0x00
56#define FMC_ISPCMD_PROGRAM 0x21
57#define FMC_ISPCMD_PAGE_ERASE 0x22
58#define FMC_ISPCMD_READ_CID 0x0B
59#define FMC_ISPCMD_READ_PID 0x0C
60#define FMC_ISPCMD_READ_UID 0x04
61#define FMC_ISPCMD_VECMAP 0x2E
63#define IS_BOOT_FROM_APROM 0
64#define IS_BOOT_FROM_LDROM 1 /* end of group NANO100_FMC_EXPORTED_CONSTANTS */
68
69
74/*---------------------------------------------------------------------------------------------------------*/
75/* Macros */
76/*---------------------------------------------------------------------------------------------------------*/
77
84#define FMC_SET_APROM_BOOT() (FMC->ISPCON &= ~FMC_ISPCON_BS_Msk)
85
92#define FMC_SET_LDROM_BOOT() (FMC->ISPCON |= FMC_ISPCON_BS_Msk)
93
100#define FMC_ENABLE_AP_UPDATE() (FMC->ISPCON |= FMC_ISPCON_APUEN_Msk)
101
108#define FMC_DISABLE_AP_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_APUEN_Msk)
109
116#define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCON |= FMC_ISPCON_CFGUEN_Msk)
117
124#define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_CFGUEN_Msk)
125
132#define FMC_ENABLE_LD_UPDATE() (FMC->ISPCON |= FMC_ISPCON_LDUEN_Msk)
133
140#define FMC_DISABLE_LD_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_LDUEN_Msk)
141
148#define FMC_ENABLE_ISP() (FMC->ISPCON |= FMC_ISPCON_ISPEN_Msk)
149
156#define FMC_DISABLE_ISP() (FMC->ISPCON &= ~FMC_ISPCON_ISPEN_Msk)
157
164#define FMC_GET_FAIL_FLAG() ((FMC->ISPCON & FMC_ISPCON_ISPFF_Msk) ? 1 : 0)
165
172#define FMC_CLR_FAIL_FLAG() (FMC->ISPCON |= FMC_ISPCON_ISPFF_Msk)
173
174/*---------------------------------------------------------------------------------------------------------*/
175/* Functions */
176/*---------------------------------------------------------------------------------------------------------*/
177
178 extern void FMC_Close(void);
179 extern int32_t FMC_Erase(uint32_t u32PageAddr);
180 extern int32_t FMC_GetBootSource(void);
181 extern void FMC_Open(void);
182 extern uint32_t FMC_Read(uint32_t u32Addr);
183 extern uint32_t FMC_ReadCID(void);
184 extern uint32_t FMC_ReadPID(void);
185 extern uint32_t FMC_ReadUCID(uint32_t u32Index);
186 extern uint32_t FMC_ReadUID(uint32_t u32Index);
187 extern uint32_t FMC_ReadDataFlashBaseAddr(void);
188 extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr);
189 extern uint32_t FMC_GetVectorPageAddr(void);
190 extern int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data);
191 extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
192 extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count);
193
194 /* end of group NANO100_FMC_EXPORTED_FUNCTIONS */
196 /* end of group NANO100_FMC_Driver */
198 /* end of group NANO100_Device_Driver */
200
201#ifdef __cplusplus
202}
203#endif
204
205#endif // __FMC_H__
206
207/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
FMC_Close
void FMC_Close(void)
Disable FMC ISP function.
Definition: fmc.c:38
FMC_ReadConfig
int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count)
Execute ISP command to read User Configuration.
Definition: fmc.c:296
FMC_SetVectorPageAddr
void FMC_SetVectorPageAddr(uint32_t u32PageAddr)
This function will force re-map assigned flash page to CPU address 0x0.
Definition: fmc.c:239
FMC_ReadCID
uint32_t FMC_ReadCID(void)
Read company ID.
Definition: fmc.c:129
FMC_GetVectorPageAddr
uint32_t FMC_GetVectorPageAddr(void)
Obtain the current vector page address setting.
Definition: fmc.c:256
FMC_ReadUID
uint32_t FMC_ReadUID(uint32_t u32Index)
This function reads one of the three UID.
Definition: fmc.c:204
FMC_Erase
int32_t FMC_Erase(uint32_t u32PageAddr)
Execute ISP command to erase a flash page. The page size is 512 bytes.
Definition: fmc.c:54
FMC_ReadDataFlashBaseAddr
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
Definition: fmc.c:226
FMC_Write
int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Execute ISP command to program a word to flash.
Definition: fmc.c:269
FMC_Read
uint32_t FMC_Read(uint32_t u32Addr)
Execute ISP command to read a word from flash.
Definition: fmc.c:104
FMC_ReadPID
uint32_t FMC_ReadPID(void)
Read product ID.
Definition: fmc.c:153
FMC_GetBootSource
int32_t FMC_GetBootSource(void)
Get the current boot source.
Definition: fmc.c:79
FMC_WriteConfig
int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count)
Execute ISP command to write User Configuration.
Definition: fmc.c:315
FMC_Open
void FMC_Open(void)
Enable FMC ISP function.
Definition: fmc.c:92
FMC_ReadUCID
uint32_t FMC_ReadUCID(uint32_t u32Index)
This function reads one of the four UCID.
Definition: fmc.c:178