Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_fmc.h@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /**************************************************************************//** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * @file fmc.h |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V1.10 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 11 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 14/10/06 1:47p $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief NUC472/NUC442 Flash Memory Controller Driver Header File |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * @note |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 10 | * |
sahilmgandhi | 18:6a4db94011d3 | 11 | ******************************************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 12 | #ifndef __FMC_H__ |
sahilmgandhi | 18:6a4db94011d3 | 13 | #define __FMC_H__ |
sahilmgandhi | 18:6a4db94011d3 | 14 | |
sahilmgandhi | 18:6a4db94011d3 | 15 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 16 | extern "C" |
sahilmgandhi | 18:6a4db94011d3 | 17 | { |
sahilmgandhi | 18:6a4db94011d3 | 18 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 19 | |
sahilmgandhi | 18:6a4db94011d3 | 20 | /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver |
sahilmgandhi | 18:6a4db94011d3 | 21 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 22 | */ |
sahilmgandhi | 18:6a4db94011d3 | 23 | |
sahilmgandhi | 18:6a4db94011d3 | 24 | /** @addtogroup NUC472_442_FMC_Driver FMC Driver |
sahilmgandhi | 18:6a4db94011d3 | 25 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 26 | */ |
sahilmgandhi | 18:6a4db94011d3 | 27 | |
sahilmgandhi | 18:6a4db94011d3 | 28 | |
sahilmgandhi | 18:6a4db94011d3 | 29 | /** @addtogroup NUC472_442_FMC_EXPORTED_CONSTANTS FMC Exported Constants |
sahilmgandhi | 18:6a4db94011d3 | 30 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 31 | */ |
sahilmgandhi | 18:6a4db94011d3 | 32 | |
sahilmgandhi | 18:6a4db94011d3 | 33 | |
sahilmgandhi | 18:6a4db94011d3 | 34 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 35 | /* Define Base Address */ |
sahilmgandhi | 18:6a4db94011d3 | 36 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 37 | #define FMC_APROM_BASE 0x00000000UL /*!< APROM Base Address \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 38 | #define FMC_APROM_END 0x00080000UL /*!< APROM End Address \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 39 | #define FMC_LDROM_BASE 0x00100000UL /*!< LDROM Base Address \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define FMC_LDROM_END 0x00104000UL /*!< LDROM End Address \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 41 | #define FMC_CONFIG_BASE 0x00300000UL /*!< User Configuration Address \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 42 | |
sahilmgandhi | 18:6a4db94011d3 | 43 | #define FMC_FLASH_PAGE_SIZE 0x800 /*!< Flash Page Size (2 Kbytes) \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 44 | #define FMC_LDROM_SIZE 0x4000 /*!< LDROM Size (16 Kbytes) \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 45 | |
sahilmgandhi | 18:6a4db94011d3 | 46 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 47 | /* ISPCMD constant definitions */ |
sahilmgandhi | 18:6a4db94011d3 | 48 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 49 | #define FMC_ISPCMD_READ 0x00 /*!< ISP Command: Read flash word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 50 | #define FMC_ISPCMD_READ_64 0x40 /*!< ISP Command: Read flash double word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 51 | #define FMC_ISPCMD_WRITE 0x21 /*!< ISP Command: Write flash word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 52 | #define FMC_ISPCMD_WRITE_64 0x61 /*!< ISP Command: Write flash double word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 53 | #define FMC_ISPCMD_PAGE_ERASE 0x22 /*!< ISP Command: Page Erase Flash \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 54 | #define FMC_ISPCMD_READ_CID 0x0B /*!< ISP Command: Read Company ID \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 55 | #define FMC_ISPCMD_READ_DID 0x0C /*!< ISP Command: Read Device ID \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 56 | #define FMC_ISPCMD_READ_UID 0x04 /*!< ISP Command: Read Unique ID \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 57 | #define ISP_ISPCMD_MULTI_WRITE 0x27 /*!< ISP Command: Multiple program \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 58 | #define FMC_ISPCMD_VECMAP 0x2E /*!< ISP Command: Vector Page Remap \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 59 | |
sahilmgandhi | 18:6a4db94011d3 | 60 | #define IS_BOOT_FROM_APROM 0 /*!< Is booting from APROM \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 61 | #define IS_BOOT_FROM_LDROM 1 /*!< Is booting from LDROM \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 62 | |
sahilmgandhi | 18:6a4db94011d3 | 63 | |
sahilmgandhi | 18:6a4db94011d3 | 64 | /*@}*/ /* end of group NUC472_442_FMC_EXPORTED_CONSTANTS */ |
sahilmgandhi | 18:6a4db94011d3 | 65 | |
sahilmgandhi | 18:6a4db94011d3 | 66 | |
sahilmgandhi | 18:6a4db94011d3 | 67 | |
sahilmgandhi | 18:6a4db94011d3 | 68 | /** @addtogroup NUC472_442_FMC_EXPORTED_FUNCTIONS FMC Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 69 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 70 | */ |
sahilmgandhi | 18:6a4db94011d3 | 71 | |
sahilmgandhi | 18:6a4db94011d3 | 72 | |
sahilmgandhi | 18:6a4db94011d3 | 73 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 74 | /* Macros */ |
sahilmgandhi | 18:6a4db94011d3 | 75 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 76 | |
sahilmgandhi | 18:6a4db94011d3 | 77 | /** |
sahilmgandhi | 18:6a4db94011d3 | 78 | * @brief This macro selects booting from APROM. |
sahilmgandhi | 18:6a4db94011d3 | 79 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 80 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 81 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 82 | */ |
sahilmgandhi | 18:6a4db94011d3 | 83 | #define FMC_SET_APROM_BOOT() (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 84 | |
sahilmgandhi | 18:6a4db94011d3 | 85 | /** |
sahilmgandhi | 18:6a4db94011d3 | 86 | * @brief This macro selects booting from LDROM. |
sahilmgandhi | 18:6a4db94011d3 | 87 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 88 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 89 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 90 | */ |
sahilmgandhi | 18:6a4db94011d3 | 91 | #define FMC_SET_LDROM_BOOT() (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 92 | |
sahilmgandhi | 18:6a4db94011d3 | 93 | /** |
sahilmgandhi | 18:6a4db94011d3 | 94 | * @brief This macro enables APROM update function. |
sahilmgandhi | 18:6a4db94011d3 | 95 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 96 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 97 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 98 | */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | #define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 100 | |
sahilmgandhi | 18:6a4db94011d3 | 101 | /** |
sahilmgandhi | 18:6a4db94011d3 | 102 | * @brief This macro disables APROM update function. |
sahilmgandhi | 18:6a4db94011d3 | 103 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 104 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 105 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 106 | */ |
sahilmgandhi | 18:6a4db94011d3 | 107 | #define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 108 | |
sahilmgandhi | 18:6a4db94011d3 | 109 | /** |
sahilmgandhi | 18:6a4db94011d3 | 110 | * @brief This macro enables User Configuration update function. |
sahilmgandhi | 18:6a4db94011d3 | 111 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 112 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 113 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 114 | */ |
sahilmgandhi | 18:6a4db94011d3 | 115 | #define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 116 | |
sahilmgandhi | 18:6a4db94011d3 | 117 | /** |
sahilmgandhi | 18:6a4db94011d3 | 118 | * @brief This macro disables User Configuration update function. |
sahilmgandhi | 18:6a4db94011d3 | 119 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 120 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 121 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 122 | */ |
sahilmgandhi | 18:6a4db94011d3 | 123 | #define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 124 | |
sahilmgandhi | 18:6a4db94011d3 | 125 | /** |
sahilmgandhi | 18:6a4db94011d3 | 126 | * @brief This macro enables LDROM update function. |
sahilmgandhi | 18:6a4db94011d3 | 127 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 128 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 129 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 130 | */ |
sahilmgandhi | 18:6a4db94011d3 | 131 | #define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 132 | |
sahilmgandhi | 18:6a4db94011d3 | 133 | /** |
sahilmgandhi | 18:6a4db94011d3 | 134 | * @brief This macro disables LDROM update function. |
sahilmgandhi | 18:6a4db94011d3 | 135 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 136 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 137 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 138 | */ |
sahilmgandhi | 18:6a4db94011d3 | 139 | #define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 140 | |
sahilmgandhi | 18:6a4db94011d3 | 141 | /** |
sahilmgandhi | 18:6a4db94011d3 | 142 | * @brief This macro enables ISP function. |
sahilmgandhi | 18:6a4db94011d3 | 143 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 144 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 145 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 146 | */ |
sahilmgandhi | 18:6a4db94011d3 | 147 | #define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk) /*!< Enable ISP function \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 148 | |
sahilmgandhi | 18:6a4db94011d3 | 149 | /** |
sahilmgandhi | 18:6a4db94011d3 | 150 | * @brief This macro disables ISP function. |
sahilmgandhi | 18:6a4db94011d3 | 151 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 152 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 153 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 154 | */ |
sahilmgandhi | 18:6a4db94011d3 | 155 | #define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 156 | |
sahilmgandhi | 18:6a4db94011d3 | 157 | /** |
sahilmgandhi | 18:6a4db94011d3 | 158 | * @brief This macro gets ISP fail flag value. |
sahilmgandhi | 18:6a4db94011d3 | 159 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 160 | * @return ISP fail flag value. |
sahilmgandhi | 18:6a4db94011d3 | 161 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 162 | */ |
sahilmgandhi | 18:6a4db94011d3 | 163 | #define FMC_GET_FAIL_FLAG() (FMC->ISPSTS & FMC_ISPSTS_ISPFF_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 164 | |
sahilmgandhi | 18:6a4db94011d3 | 165 | /** |
sahilmgandhi | 18:6a4db94011d3 | 166 | * @brief This macro clears ISP fail flag. |
sahilmgandhi | 18:6a4db94011d3 | 167 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 168 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 169 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 170 | */ |
sahilmgandhi | 18:6a4db94011d3 | 171 | #define FMC_CLR_FAIL_FLAG() (FMC->ISPSTS |= FMC_ISPSTS_ISPFF_Msk) /*!< Clear ISP fail flag \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 172 | |
sahilmgandhi | 18:6a4db94011d3 | 173 | |
sahilmgandhi | 18:6a4db94011d3 | 174 | |
sahilmgandhi | 18:6a4db94011d3 | 175 | |
sahilmgandhi | 18:6a4db94011d3 | 176 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 177 | /* Functions */ |
sahilmgandhi | 18:6a4db94011d3 | 178 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 179 | |
sahilmgandhi | 18:6a4db94011d3 | 180 | extern void FMC_SetBootSource(int32_t i32BootSrc); |
sahilmgandhi | 18:6a4db94011d3 | 181 | extern void FMC_Close(void); |
sahilmgandhi | 18:6a4db94011d3 | 182 | extern void FMC_DisableAPUpdate(void); |
sahilmgandhi | 18:6a4db94011d3 | 183 | extern void FMC_DisableConfigUpdate(void); |
sahilmgandhi | 18:6a4db94011d3 | 184 | extern void FMC_DisableLDUpdate(void); |
sahilmgandhi | 18:6a4db94011d3 | 185 | extern void FMC_EnableAPUpdate(void); |
sahilmgandhi | 18:6a4db94011d3 | 186 | extern void FMC_EnableConfigUpdate(void); |
sahilmgandhi | 18:6a4db94011d3 | 187 | extern void FMC_EnableLDUpdate(void); |
sahilmgandhi | 18:6a4db94011d3 | 188 | extern int32_t FMC_Erase(uint32_t u32PageAddr); |
sahilmgandhi | 18:6a4db94011d3 | 189 | extern int32_t FMC_GetBootSource(void); |
sahilmgandhi | 18:6a4db94011d3 | 190 | extern void FMC_Open(void); |
sahilmgandhi | 18:6a4db94011d3 | 191 | extern uint32_t FMC_Read(uint32_t u32Addr); |
sahilmgandhi | 18:6a4db94011d3 | 192 | extern void FMC_Read_64(uint32_t u32Addr, uint32_t *u32Data0, uint32_t *u32Data1); |
sahilmgandhi | 18:6a4db94011d3 | 193 | extern uint32_t FMC_ReadCID(void); |
sahilmgandhi | 18:6a4db94011d3 | 194 | extern uint32_t FMC_ReadDID(void); |
sahilmgandhi | 18:6a4db94011d3 | 195 | extern uint32_t FMC_ReadPID(void); |
sahilmgandhi | 18:6a4db94011d3 | 196 | extern uint32_t FMC_ReadUCID(uint32_t u32Index); |
sahilmgandhi | 18:6a4db94011d3 | 197 | extern uint32_t FMC_ReadUID(uint32_t u32Index); |
sahilmgandhi | 18:6a4db94011d3 | 198 | extern uint32_t FMC_ReadDataFlashBaseAddr(void); |
sahilmgandhi | 18:6a4db94011d3 | 199 | extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr); |
sahilmgandhi | 18:6a4db94011d3 | 200 | extern void FMC_Write(uint32_t u32Addr, uint32_t u32Data); |
sahilmgandhi | 18:6a4db94011d3 | 201 | extern void FMC_Write_64(uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1); |
sahilmgandhi | 18:6a4db94011d3 | 202 | extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count); |
sahilmgandhi | 18:6a4db94011d3 | 203 | extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count); |
sahilmgandhi | 18:6a4db94011d3 | 204 | extern uint32_t FMC_CRC8(uint32_t au32Data[], int i32Count); |
sahilmgandhi | 18:6a4db94011d3 | 205 | |
sahilmgandhi | 18:6a4db94011d3 | 206 | |
sahilmgandhi | 18:6a4db94011d3 | 207 | /*@}*/ /* end of group NUC472_442_FMC_EXPORTED_FUNCTIONS */ |
sahilmgandhi | 18:6a4db94011d3 | 208 | |
sahilmgandhi | 18:6a4db94011d3 | 209 | /*@}*/ /* end of group NUC472_442_FMC_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 210 | |
sahilmgandhi | 18:6a4db94011d3 | 211 | /*@}*/ /* end of group NUC472_442_Device_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 212 | |
sahilmgandhi | 18:6a4db94011d3 | 213 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 214 | } |
sahilmgandhi | 18:6a4db94011d3 | 215 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 216 | |
sahilmgandhi | 18:6a4db94011d3 | 217 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 218 | |
sahilmgandhi | 18:6a4db94011d3 | 219 | /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ |