fmc.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /**************************************************************************//**
  2. * @file FMC.h
  3. * @version V2.1
  4. * $Revision: 19 $
  5. * $Date: 15/08/11 10:26a $
  6. * @brief M451 Series Flash Memory Controller Driver Header File
  7. *
  8. * @note
  9. * Copyright (C) 2011~2015 Nuvoton Technology Corp. All rights reserved.
  10. *
  11. ******************************************************************************/
  12. #ifndef __FMC_H__
  13. #define __FMC_H__
  14. #include "M451Series.h"
  15. #ifdef __cplusplus
  16. extern "C"
  17. {
  18. #endif
  19. /** @addtogroup Standard_Driver Standard Driver
  20. @{
  21. */
  22. /** @addtogroup FMC_Driver FMC Driver
  23. @{
  24. */
  25. /** @addtogroup FMC_EXPORTED_CONSTANTS FMC Exported Constants
  26. @{
  27. */
  28. /*---------------------------------------------------------------------------------------------------------*/
  29. /* Global constant definitions */
  30. /*---------------------------------------------------------------------------------------------------------*/
  31. #define ISBEN 0
  32. /*---------------------------------------------------------------------------------------------------------*/
  33. /* Define Base Address */
  34. /*---------------------------------------------------------------------------------------------------------*/
  35. #define FMC_APROM_BASE 0x00000000UL /*!< APROM Base Address */
  36. #define FMC_LDROM_BASE 0x00100000UL /*!< LDROM Base Address */
  37. #define FMC_SPROM_BASE 0x00200000UL /*!< SPROM Base Address */
  38. #define FMC_CONFIG_BASE 0x00300000UL /*!< CONFIG Base Address */
  39. #define FMC_CONFIG0_ADDR (FMC_CONFIG_BASE) /*!< CONFIG 0 Address */
  40. #define FMC_CONFIG1_ADDR (FMC_CONFIG_BASE + 4) /*!< CONFIG 1 Address */
  41. #define FMC_FLASH_PAGE_SIZE 0x800 /*!< Flash Page Size (2048 Bytes) */
  42. #define FMC_LDROM_SIZE 0x1000 /*!< LDROM Size (4 kBytes) */
  43. /*---------------------------------------------------------------------------------------------------------*/
  44. /* ISPCTL constant definitions */
  45. /*---------------------------------------------------------------------------------------------------------*/
  46. #define FMC_ISPCTL_BS_LDROM 0x2 /*!< ISPCTL setting to select to boot from LDROM */
  47. #define FMC_ISPCTL_BS_APROM 0x0 /*!< ISPCTL setting to select to boot from APROM */
  48. /*---------------------------------------------------------------------------------------------------------*/
  49. /* ISPCMD constant definitions */
  50. /*---------------------------------------------------------------------------------------------------------*/
  51. #define FMC_ISPCMD_READ 0x00 /*!< ISP Command: Read Flash */
  52. #define FMC_ISPCMD_PROGRAM 0x21 /*!< ISP Command: 32-bit Program Flash */
  53. #define FMC_ISPCMD_WRITE_8 0x61 /*!< ISP Command: 64-bit program Flash */
  54. #define FMC_ISPCMD_PAGE_ERASE 0x22 /*!< ISP Command: Page Erase Flash */
  55. #define FMC_ISPCMD_READ_CID 0x0B /*!< ISP Command: Read Company ID */
  56. #define FMC_ISPCMD_READ_UID 0x04 /*!< ISP Command: Read Unique ID */
  57. #define FMC_ISPCMD_READ_DID 0x0C /*!< ISP Command: Read Device ID */
  58. #define FMC_ISPCMD_VECMAP 0x2E /*!< ISP Command: Set vector mapping */
  59. #define FMC_ISPCMD_CHECKSUM 0x0D /*!< ISP Command: Read Checksum */
  60. #define FMC_ISPCMD_CAL_CHECKSUM 0x2D /*!< ISP Command: Run Check Calculation */
  61. #define FMC_ISPCMD_MULTI_PROG 0x27 /*!< ISP Command: Flash Multi-Word Program */
  62. /*---------------------------------------------------------------------------------------------------------*/
  63. /* FTCTL constant definitions */
  64. /*---------------------------------------------------------------------------------------------------------*/
  65. #define FMC_FTCTL_OPTIMIZE_DISABLE 0x00 /*!< Frequency Optimize Mode disable */
  66. #define FMC_FTCTL_OPTIMIZE_12MHZ 0x01 /*!< Frequency Optimize Mode <= 12Mhz */
  67. #define FMC_FTCTL_OPTIMIZE_36MHZ 0x02 /*!< Frequency Optimize Mode <= 36Mhz */
  68. #define FMC_FTCTL_OPTIMIZE_60MHZ 0x04 /*!< Frequency Optimize Mode <= 60Mhz */
  69. #define FMC_FTCTL_OPTIMIZE_72MHZ 0x05 /*!< Frequency Optimize Mode <= 72Mhz */
  70. /*@}*/ /* end of group FMC_EXPORTED_CONSTANTS */
  71. /** @addtogroup FMC_EXPORTED_FUNCTIONS FMC Exported Functions
  72. @{
  73. */
  74. /*---------------------------------------------------------------------------------------------------------*/
  75. /* FMC Macro Definitions */
  76. /*---------------------------------------------------------------------------------------------------------*/
  77. /**
  78. * @brief Enable ISP Function
  79. *
  80. * @param None
  81. *
  82. * @return None
  83. *
  84. * @details This function will set ISPEN bit of ISPCTL control register to enable ISP function.
  85. *
  86. */
  87. #define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk) /*!< Enable ISP Function */
  88. /**
  89. * @brief Disable ISP Function
  90. *
  91. * @param None
  92. *
  93. * @return None
  94. *
  95. * @details This function will clear ISPEN bit of ISPCTL control register to disable ISP function.
  96. *
  97. */
  98. #define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk) /*!< Disable ISP Function */
  99. /**
  100. * @brief Enable LDROM Update Function
  101. *
  102. * @param None
  103. *
  104. * @return None
  105. *
  106. * @details This function will set LDUEN bit of ISPCTL control register to enable LDROM update function.
  107. * User needs to set LDUEN bit before they can update LDROM.
  108. *
  109. */
  110. #define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk) /*!< Enable LDROM Update Function */
  111. /**
  112. * @brief Disable LDROM Update Function
  113. *
  114. * @param None
  115. *
  116. * @return None
  117. *
  118. * @details This function will set ISPEN bit of ISPCTL control register to disable LDROM update function.
  119. *
  120. */
  121. #define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk) /*!< Disable LDROM Update Function */
  122. /**
  123. * @brief Enable User Configuration Update Function
  124. *
  125. * @param None
  126. *
  127. * @return None
  128. *
  129. * @details This function will set CFGUEN bit of ISPCTL control register to enable User Configuration update function.
  130. * User needs to set CFGUEN bit before they can update User Configuration area.
  131. *
  132. */
  133. #define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk) /*!< Enable CONFIG Update Function */
  134. /**
  135. * @brief Disable User Configuration Update Function
  136. *
  137. * @param None
  138. *
  139. * @return None
  140. *
  141. * @details This function will clear CFGUEN bit of ISPCTL control register to disable User Configuration update function.
  142. *
  143. */
  144. #define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk) /*!< Disable CONFIG Update Function */
  145. /**
  146. * @brief Enable APROM Update Function
  147. *
  148. * @param None
  149. *
  150. * @return None
  151. *
  152. * @details This function will set APUEN bit of ISPCTL control register to enable APROM update function.
  153. * User needs to set APUEN bit before they can update APROM in APROM boot mode.
  154. *
  155. */
  156. #define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk) /*!< Enable APROM Update Function */
  157. /**
  158. * @brief Disable APROM Update Function
  159. *
  160. * @param None
  161. *
  162. * @return None
  163. *
  164. * @details This function will clear APUEN bit of ISPCTL control register to disable APROM update function.
  165. *
  166. */
  167. #define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk) /*!< Disable APROM Update Function */
  168. /**
  169. * @brief Next Booting Selection function
  170. *
  171. * @param[in] x Booting from APROM(0)/LDROM(1)
  172. *
  173. * @return None
  174. *
  175. * @details This function will set MCU next booting from LDROM/APROM.
  176. *
  177. * @note When use this macro, the Boot Loader booting selection MBS(CONFIG0[5]) must be set.
  178. *
  179. */
  180. #define FMC_SELECT_NEXT_BOOT(x) (FMC->ISPCTL = (FMC->ISPCTL & ~FMC_ISPCTL_BS_Msk) | ((x) << FMC_ISPCTL_BS_Pos)) /*!< Select Next Booting, x = 0 or 1 */
  181. /**
  182. * @brief Get MCU Booting Status
  183. *
  184. * @param None
  185. *
  186. * @return None
  187. *
  188. * @details This function will get status of chip next booting from LDROM/APROM.
  189. *
  190. */
  191. #define FMC_GET_BOOT_STATUS() ((FMC->ISPCTL & FMC_ISPCTL_BS_Msk)?1:0) /*!< Get MCU Booting Status */
  192. /*---------------------------------------------------------------------------------------------------------*/
  193. /* inline functions */
  194. /*---------------------------------------------------------------------------------------------------------*/
  195. /**
  196. * @brief Program 32-bit data into specified address of flash
  197. *
  198. * @param[in] u32Addr Flash address include APROM, LDROM, Data Flash, and CONFIG
  199. * @param[in] u32Data 32-bit Data to program
  200. *
  201. * @return None
  202. *
  203. * @details To program word data into Flash include APROM, LDROM, Data Flash, and CONFIG.
  204. * The corresponding functions in CONFIG are listed in FMC section of Technical Reference Manual.
  205. *
  206. */
  207. static __INLINE void FMC_Write(uint32_t u32Addr, uint32_t u32Data)
  208. {
  209. FMC->ISPCMD = FMC_ISPCMD_PROGRAM;
  210. FMC->ISPADDR = u32Addr;
  211. FMC->ISPDAT = u32Data;
  212. FMC->ISPTRG = 0x1;
  213. #if ISBEN
  214. __ISB();
  215. #endif
  216. while(FMC->ISPTRG);
  217. }
  218. /**
  219. * @brief Program 64-bit data into specified address of flash
  220. *
  221. * @param[in] u32Addr Flash address include APROM, LDROM, Data Flash, and CONFIG
  222. * @param[in] u32Data0 32-bit Data to program
  223. * @param[in] u32Data1 32-bit Data to program
  224. *
  225. * @return None
  226. *
  227. * @details To program two words data into Flash include APROM, LDROM, Data Flash, and CONFIG.
  228. * The corresponding functions in CONFIG are listed in FMC section of Technical Reference Manual.
  229. *
  230. */
  231. static __INLINE void FMC_Write8(uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1)
  232. {
  233. FMC->ISPCMD = FMC_ISPCMD_WRITE_8;
  234. FMC->ISPADDR = u32Addr;
  235. FMC->MPDAT0 = u32Data0;
  236. FMC->MPDAT1 = u32Data1;
  237. FMC->ISPTRG = 0x1;
  238. #if ISBEN
  239. __ISB();
  240. #endif
  241. while(FMC->ISPTRG);
  242. }
  243. /**
  244. * @brief Read 32-bit Data from specified address of flash
  245. *
  246. * @param[in] u32Addr Flash address include APROM, LDROM, Data Flash, and CONFIG
  247. *
  248. * @return The data of specified address
  249. *
  250. * @details To read word data from Flash include APROM, LDROM, Data Flash, and CONFIG.
  251. *
  252. */
  253. static __INLINE uint32_t FMC_Read(uint32_t u32Addr)
  254. {
  255. FMC->ISPCMD = FMC_ISPCMD_READ;
  256. FMC->ISPADDR = u32Addr;
  257. FMC->ISPDAT = 0;
  258. FMC->ISPTRG = 0x1;
  259. #if ISBEN
  260. __ISB();
  261. #endif
  262. while(FMC->ISPTRG);
  263. return FMC->ISPDAT;
  264. }
  265. /**
  266. * @brief Flash page erase
  267. *
  268. * @param[in] u32Addr Flash address including APROM, LDROM, Data Flash, and CONFIG
  269. *
  270. * @details To do flash page erase. The target address could be APROM, LDROM, Data Flash, or CONFIG.
  271. * The page size is 2048 bytes.
  272. *
  273. * @retval 0 Success
  274. * @retval -1 Erase failed
  275. *
  276. */
  277. static __INLINE int32_t FMC_Erase(uint32_t u32Addr)
  278. {
  279. FMC->ISPCMD = FMC_ISPCMD_PAGE_ERASE;
  280. FMC->ISPADDR = u32Addr;
  281. FMC->ISPTRG = 0x1;
  282. #if ISBEN
  283. __ISB();
  284. #endif
  285. while(FMC->ISPTRG);
  286. /* Check ISPFF flag to know whether erase OK or fail. */
  287. if(FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk)
  288. {
  289. FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk;
  290. return -1;
  291. }
  292. return 0;
  293. }
  294. /**
  295. * @brief Read Unique ID
  296. *
  297. * @param[in] u8Index UID index. 0 = UID[31:0], 1 = UID[63:32], 2 = UID[95:64]
  298. *
  299. * @return The 32-bit unique ID data of specified UID index.
  300. *
  301. * @details To read out 96-bit Unique ID.
  302. *
  303. */
  304. static __INLINE uint32_t FMC_ReadUID(uint8_t u8Index)
  305. {
  306. FMC->ISPCMD = FMC_ISPCMD_READ_UID;
  307. FMC->ISPADDR = (u8Index << 2);
  308. FMC->ISPDAT = 0;
  309. FMC->ISPTRG = 0x1;
  310. #if ISBEN
  311. __ISB();
  312. #endif
  313. while(FMC->ISPTRG);
  314. return FMC->ISPDAT;
  315. }
  316. /**
  317. * @brief Read company ID
  318. *
  319. * @param None
  320. *
  321. * @return The company ID (32-bit)
  322. *
  323. * @details The company ID of Nuvoton is fixed to be 0xDA
  324. *
  325. */
  326. static __INLINE uint32_t FMC_ReadCID(void)
  327. {
  328. FMC->ISPCMD = FMC_ISPCMD_READ_CID; /* Set ISP Command Code */
  329. FMC->ISPADDR = 0x0; /* Must keep 0x0 when read CID */
  330. FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; /* Trigger to start ISP procedure */
  331. #if ISBEN
  332. __ISB();
  333. #endif /* To make sure ISP/CPU be Synchronized */
  334. while(FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; /* Waiting for ISP Done */
  335. return FMC->ISPDAT;
  336. }
  337. /**
  338. * @brief Read product ID
  339. *
  340. * @param None
  341. *
  342. * @return The product ID (32-bit)
  343. *
  344. * @details This function is used to read product ID.
  345. *
  346. */
  347. static __INLINE uint32_t FMC_ReadPID(void)
  348. {
  349. FMC->ISPCMD = FMC_ISPCMD_READ_DID; /* Set ISP Command Code */
  350. FMC->ISPADDR = 0x04; /* Must keep 0x4 when read PID */
  351. FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; /* Trigger to start ISP procedure */
  352. #if ISBEN
  353. __ISB();
  354. #endif /* To make sure ISP/CPU be Synchronized */
  355. while(FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk); /* Waiting for ISP Done */
  356. return FMC->ISPDAT;
  357. }
  358. /**
  359. * @brief To read UCID
  360. *
  361. * @param[in] u32Index Index of the UCID to read. u32Index must be 0, 1, 2, or 3.
  362. *
  363. * @return The UCID of specified index
  364. *
  365. * @details This function is used to read unique chip ID (UCID).
  366. *
  367. */
  368. static __INLINE uint32_t FMC_ReadUCID(uint32_t u32Index)
  369. {
  370. FMC->ISPCMD = FMC_ISPCMD_READ_UID; /* Set ISP Command Code */
  371. FMC->ISPADDR = (0x04 * u32Index) + 0x10; /* The UCID is at offset 0x10 with word alignment. */
  372. FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; /* Trigger to start ISP procedure */
  373. #if ISBEN
  374. __ISB();
  375. #endif /* To make sure ISP/CPU be Synchronized */
  376. while(FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk); /* Waiting for ISP Done */
  377. return FMC->ISPDAT;
  378. }
  379. /**
  380. * @brief Set vector mapping address
  381. *
  382. * @param[in] u32PageAddr The page address to remap to address 0x0. The address must be page alignment.
  383. *
  384. * @return To set VECMAP to remap specified page address to 0x0.
  385. *
  386. * @details This function is used to set VECMAP to map specified page to vector page (0x0).
  387. *
  388. * @note
  389. * VECMAP only valid when new IAP function is enabled. (CBS = 10'b or 00'b)
  390. *
  391. */
  392. static __INLINE void FMC_SetVectorPageAddr(uint32_t u32PageAddr)
  393. {
  394. FMC->ISPCMD = FMC_ISPCMD_VECMAP; /* Set ISP Command Code */
  395. FMC->ISPADDR = u32PageAddr; /* The address of specified page which will be map to address 0x0. It must be page alignment. */
  396. FMC->ISPTRG = 0x1; /* Trigger to start ISP procedure */
  397. #if ISBEN
  398. __ISB();
  399. #endif /* To make sure ISP/CPU be Synchronized */
  400. while(FMC->ISPTRG); /* Waiting for ISP Done */
  401. }
  402. /**
  403. * @brief Get current vector mapping address.
  404. *
  405. * @param None
  406. *
  407. * @return The current vector mapping address.
  408. *
  409. * @details To get VECMAP value which is the page address for remapping to vector page (0x0).
  410. *
  411. * @note
  412. * VECMAP only valid when new IAP function is enabled. (CBS = 10'b or 00'b)
  413. *
  414. */
  415. static __INLINE uint32_t FMC_GetVECMAP(void)
  416. {
  417. return (FMC->ISPSTS & FMC_ISPSTS_VECMAP_Msk);
  418. }
  419. /**
  420. * @brief Get Flash Checksum
  421. *
  422. * @param[in] u32Addr Specific flash start address
  423. * @param[in] i32Size Specific a size of Flash area
  424. *
  425. * @return A checksum value of a flash block.
  426. *
  427. * @details To get VECMAP value which is the page address for remapping to vector page (0x0).
  428. *
  429. */
  430. static __INLINE uint32_t FMC_GetCheckSum(uint32_t u32Addr, int32_t i32Size)
  431. {
  432. FMC->ISPCMD = FMC_ISPCMD_CAL_CHECKSUM;
  433. FMC->ISPADDR = u32Addr;
  434. FMC->ISPDAT = i32Size;
  435. FMC->ISPTRG = 0x1;
  436. #if ISBEN
  437. __ISB();
  438. #endif
  439. while(FMC->ISPTRG);
  440. FMC->ISPCMD = FMC_ISPCMD_CHECKSUM;
  441. FMC->ISPTRG = 0x1;
  442. while(FMC->ISPTRG);
  443. return FMC->ISPDAT;
  444. }
  445. /**
  446. * @brief Program Multi-Word data into specified address of flash
  447. *
  448. * @param[in] u32Addr Flash address include APROM, LDROM, Data Flash, and CONFIG
  449. * @param[in] pu32Buf A data pointer is point to a data buffer start address;
  450. *
  451. * @return None
  452. *
  453. * @details To program multi-words data into Flash include APROM, LDROM, Data Flash, and CONFIG.
  454. * The corresponding functions in CONFIG are listed in FMC section of Technical Reference Manual.
  455. *
  456. */
  457. static __INLINE void FMC_Write256(uint32_t u32Addr, uint32_t *pu32Buf)
  458. {
  459. int32_t i, idx;
  460. volatile uint32_t *pu32IspData;
  461. //int32_t i32Err;
  462. //i32Err = 0;
  463. idx = 0;
  464. FMC->ISPCMD = FMC_ISPCMD_MULTI_PROG;
  465. FMC->ISPADDR = u32Addr;
  466. retrigger:
  467. //if(i32Err)
  468. // printf("idx=%d ISPADDR = 0x%08x\n",idx, FMC->ISPADDR);
  469. FMC->MPDAT0 = pu32Buf[idx + 0];
  470. FMC->MPDAT1 = pu32Buf[idx + 1];
  471. FMC->MPDAT2 = pu32Buf[idx + 2];
  472. FMC->MPDAT3 = pu32Buf[idx + 3];
  473. FMC->ISPTRG = 0x1;
  474. pu32IspData = &FMC->MPDAT0;
  475. idx += 4;
  476. for(i = idx; i < 256 / 4; i += 4) // Max data length is 256 bytes (256/4 words)
  477. {
  478. __set_PRIMASK(1); // Mask interrupt to avoid status check coherence error
  479. do
  480. {
  481. if((FMC->MPSTS & FMC_MPSTS_MPBUSY_Msk) == 0)
  482. {
  483. __set_PRIMASK(0);
  484. //printf("%d %x\n", i, FMC->MPADDR);
  485. FMC->ISPADDR = FMC->MPADDR & (~0xful);
  486. idx = (FMC->ISPADDR - u32Addr) / 4;
  487. //i32Err = -1;
  488. goto retrigger;
  489. }
  490. }
  491. while(FMC->MPSTS & (3 << FMC_MPSTS_D0_Pos));
  492. // Update new data for D0
  493. pu32IspData[0] = pu32Buf[i ];
  494. pu32IspData[1] = pu32Buf[i + 1];
  495. do
  496. {
  497. if((FMC->MPSTS & FMC_MPSTS_MPBUSY_Msk) == 0)
  498. {
  499. __set_PRIMASK(0);
  500. //printf("%d %x\n", i, FMC->MPADDR);
  501. FMC->ISPADDR = FMC->MPADDR & (~0xful);
  502. idx = (FMC->ISPADDR - u32Addr) / 4;
  503. //i32Err = -1;
  504. goto retrigger;
  505. }
  506. }
  507. while(FMC->MPSTS & (3 << FMC_MPSTS_D2_Pos));
  508. // Update new data for D2
  509. pu32IspData[2] = pu32Buf[i + 2];
  510. pu32IspData[3] = pu32Buf[i + 3];
  511. __set_PRIMASK(0);
  512. }
  513. while(FMC->ISPSTS & FMC_ISPSTS_ISPBUSY_Msk);
  514. }
  515. void FMC_Open(void);
  516. void FMC_Close(void);
  517. void FMC_EnableAPUpdate(void);
  518. void FMC_DisableAPUpdate(void);
  519. void FMC_EnableConfigUpdate(void);
  520. void FMC_DisableConfigUpdate(void);
  521. void FMC_EnableLDUpdate(void);
  522. void FMC_DisableLDUpdate(void);
  523. int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count);
  524. int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count);
  525. void FMC_SetBootSource(int32_t i32BootSrc);
  526. int32_t FMC_GetBootSource(void);
  527. uint32_t FMC_ReadDataFlashBaseAddr(void);
  528. void FMC_EnableFreqOptimizeMode(uint32_t u32Mode);
  529. void FMC_DisableFreqOptimizeMode(void);
  530. /*@}*/ /* end of group FMC_EXPORTED_FUNCTIONS */
  531. /*@}*/ /* end of group FMC_Driver */
  532. /*@}*/ /* end of group Standard_Driver */
  533. #ifdef __cplusplus
  534. }
  535. #endif
  536. #endif