NANO102/112 BSP V3.03.003
The Board Support Package for Nano102/112 Series
fmc.h
Go to the documentation of this file.
1/**************************************************************************/
13#ifndef __FMC_H__
14#define __FMC_H__
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif
20
35/*---------------------------------------------------------------------------------------------------------*/
36/* Define Base Address */
37/*---------------------------------------------------------------------------------------------------------*/
38#define FMC_APROM_BASE 0x00000000UL
39#define FMC_APROM_END 0x00008000UL
40#define FMC_LDROM_BASE 0x00100000UL
41#define FMC_LDROM_END 0x00101000UL
42#define FMC_SPROM_BASE 0x00200000UL
43#define FMC_SPROM_END 0x00200200UL
44#define FMC_CONFIG_BASE 0x00300000UL
46#define FMC_FLASH_PAGE_SIZE 0x200
47#define FMC_LDROM_SIZE 0x1000
49#define FMC_TIMEOUT_READ ((SystemCoreClock/10)*2)
50#define FMC_TIMEOUT_WRITE ((SystemCoreClock/10)*2)
51#define FMC_TIMEOUT_ERASE ((SystemCoreClock/10)*4)
52#define FMC_TIMEOUT_CHKSUM (SystemCoreClock*2)
54/*---------------------------------------------------------------------------------------------------------*/
55/* ISPCMD constant definitions */
56/*---------------------------------------------------------------------------------------------------------*/
57#define FMC_ISPCMD_READ 0x00
58#define FMC_ISPCMD_PROGRAM 0x21
59#define FMC_ISPCMD_PAGE_ERASE 0x22
60#define FMC_ISPCMD_READ_CID 0x0B
61#define FMC_ISPCMD_READ_PID 0x0C
62#define FMC_ISPCMD_READ_UID 0x04
63#define FMC_ISPCMD_VECMAP 0x2E
65#define IS_BOOT_FROM_APROM 0
66#define IS_BOOT_FROM_LDROM 1 /* end of group NANO1X2_FMC_EXPORTED_CONSTANTS */
70
71
76/*---------------------------------------------------------------------------------------------------------*/
77/* Macros */
78/*---------------------------------------------------------------------------------------------------------*/
79
80#define FMC_SET_APROM_BOOT() (FMC->ISPCON &= ~FMC_ISPCON_BS_Msk)
81#define FMC_SET_LDROM_BOOT() (FMC->ISPCON |= FMC_ISPCON_BS_Msk)
82#define FMC_ENABLE_AP_UPDATE() (FMC->ISPCON |= FMC_ISPCON_APUEN_Msk)
83#define FMC_DISABLE_AP_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_APUEN_Msk)
84#define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCON |= FMC_ISPCON_CFGUEN_Msk)
85#define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_CFGUEN_Msk)
86#define FMC_ENABLE_LD_UPDATE() (FMC->ISPCON |= FMC_ISPCON_LDUEN_Msk)
87#define FMC_DISABLE_LD_UPDATE() (FMC->ISPCON &= ~FMC_ISPCON_LDUEN_Msk)
88#define FMC_DISABLE_ISP() (FMC->ISPCON &= ~FMC_ISPCON_ISPEN_Msk)
89#define FMC_ENABLE_ISP() (FMC->ISPCON |= FMC_ISPCON_ISPEN_Msk)
90#define FMC_GET_FAIL_FLAG() ((FMC->ISPCON & FMC_ISPCON_ISPFF_Msk) ? 1 : 0)
91#define FMC_CLR_FAIL_FLAG() (FMC->ISPCON |= FMC_ISPCON_ISPFF_Msk)
93/*---------------------------------------------------------------------------------------------------------*/
94/* Functions */
95/*---------------------------------------------------------------------------------------------------------*/
96
97extern void FMC_Close(void);
98extern int32_t FMC_Erase(uint32_t u32PageAddr);
99extern int32_t FMC_GetBootSource(void);
100extern void FMC_Open(void);
101extern uint32_t FMC_Read(uint32_t u32Addr);
102extern uint32_t FMC_ReadCID(void);
103extern uint32_t FMC_ReadPID(void);
104extern uint32_t FMC_ReadUCID(uint32_t u32Index);
105extern uint32_t FMC_ReadUID(uint32_t u32Index);
106extern uint32_t FMC_ReadDataFlashBaseAddr(void);
107extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr);
108extern uint32_t FMC_GetVectorPageAddr(void);
109extern int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data);
110extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
111extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count);
112
113 /* end of group NANO1X2_FMC_EXPORTED_FUNCTIONS */
115 /* end of group NANO1X2_FMC_Driver */
117 /* end of group NANO1X2_Device_Driver */
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif // __FMC_H__
125
126/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
void FMC_Close(void)
Disable FMC ISP function.
Definition: fmc.c:38
int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count)
Execute ISP command to read User Configuration.
Definition: fmc.c:292
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:127
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:202
int32_t FMC_Erase(uint32_t u32PageAddr)
Execute ISP command to erase a flash page. The page size is 512 bytes.
Definition: fmc.c:52
uint32_t FMC_ReadDataFlashBaseAddr(void)
Get the base address of Data Flash if enabled.
Definition: fmc.c:224
int32_t FMC_Write(uint32_t u32Addr, uint32_t u32Data)
Execute ISP command to program a word to flash.
Definition: fmc.c:265
uint32_t FMC_Read(uint32_t u32Addr)
Execute ISP command to read a word from flash.
Definition: fmc.c:102
uint32_t FMC_ReadPID(void)
Read product ID.
Definition: fmc.c:151
int32_t FMC_GetBootSource(void)
Get the current boot source.
Definition: fmc.c:77
int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count)
Execute ISP command to write User Configuration.
Definition: fmc.c:311
void FMC_Open(void)
Enable FMC ISP function.
Definition: fmc.c:90
uint32_t FMC_ReadUCID(uint32_t u32Index)
This function reads one of the four UCID.
Definition: fmc.c:176