CyFlash.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*******************************************************************************
  2. * File Name: CyFlash.c
  3. * Version 4.0
  4. *
  5. * Description:
  6. * Provides an API for the FLASH/EEPROM.
  7. *
  8. * Note:
  9. * This code is endian agnostic.
  10. *
  11. * Note:
  12. * Documentation of the API's in this file is located in the
  13. * System Reference Guide provided with PSoC Creator.
  14. *
  15. ********************************************************************************
  16. * Copyright 2008-2013, Cypress Semiconductor Corporation. All rights reserved.
  17. * You may use this file only in accordance with the license, terms, conditions,
  18. * disclaimers, and limitations in the end user license agreement accompanying
  19. * the software package with which this file was provided.
  20. *******************************************************************************/
  21. #include "CyFlash.h"
  22. /*******************************************************************************
  23. * Holds die temperature, updated by CySetTemp(). Used for flash writting.
  24. * The first byte is the sign of the temperature (0 = negative, 1 = positive).
  25. * The second byte is the magnitude.
  26. *******************************************************************************/
  27. uint8 dieTemperature[CY_FLASH_DIE_TEMP_DATA_SIZE];
  28. #if(CYDEV_ECC_ENABLE == 0)
  29. static uint8 * rowBuffer = 0;
  30. #endif /* (CYDEV_ECC_ENABLE == 0) */
  31. static cystatus CySetTempInt(void);
  32. /*******************************************************************************
  33. * Function Name: CyFlash_Start
  34. ********************************************************************************
  35. *
  36. * Summary:
  37. * Enable the Flash.
  38. *
  39. * Parameters:
  40. * None
  41. *
  42. * Return:
  43. * None
  44. *
  45. *******************************************************************************/
  46. void CyFlash_Start(void)
  47. {
  48. /* Active Power Mode */
  49. *CY_FLASH_PM_ACT_EEFLASH_PTR |= CY_FLASH_PM_FLASH_MASK;
  50. /* Standby Power Mode */
  51. *CY_FLASH_PM_ALTACT_EEFLASH_PTR |= CY_FLASH_PM_FLASH_MASK;
  52. CyDelayUs(CY_FLASH_EE_STARTUP_DELAY);
  53. }
  54. /*******************************************************************************
  55. * Function Name: CyFlash_Stop
  56. ********************************************************************************
  57. *
  58. * Summary:
  59. * Disable the Flash.
  60. *
  61. * Parameters:
  62. * None
  63. *
  64. * Return:
  65. * None
  66. *
  67. * Side Effects:
  68. * This setting is ignored as long as the CPU is currently running. This will
  69. * only take effect when the CPU is later disabled.
  70. *
  71. *******************************************************************************/
  72. void CyFlash_Stop(void)
  73. {
  74. /* Active Power Mode */
  75. *CY_FLASH_PM_ACT_EEFLASH_PTR &= ((uint8)(~CY_FLASH_PM_FLASH_MASK));
  76. /* Standby Power Mode */
  77. *CY_FLASH_PM_ALTACT_EEFLASH_PTR &= ((uint8)(~CY_FLASH_PM_FLASH_MASK));
  78. }
  79. /*******************************************************************************
  80. * Function Name: CySetTempInt
  81. ********************************************************************************
  82. *
  83. * Summary:
  84. * Sends a command to the SPC to read the die temperature. Sets a global value
  85. * used by the Write functions. This function must be called once before
  86. * executing a series of Flash writing functions.
  87. *
  88. * Parameters:
  89. * None
  90. *
  91. * Return:
  92. * status:
  93. * CYRET_SUCCESS - if successful
  94. * CYRET_LOCKED - if Flash writing already in use
  95. * CYRET_UNKNOWN - if there was an SPC error
  96. *
  97. *******************************************************************************/
  98. static cystatus CySetTempInt(void)
  99. {
  100. cystatus status;
  101. /* Make sure SPC is powered */
  102. CySpcStart();
  103. /* Plan for failure. */
  104. status = CYRET_UNKNOWN;
  105. if(CySpcLock() == CYRET_SUCCESS)
  106. {
  107. /* Write the command. */
  108. if(CYRET_STARTED == CySpcGetTemp(CY_TEMP_NUMBER_OF_SAMPLES))
  109. {
  110. do
  111. {
  112. if(CySpcReadData(dieTemperature, CY_FLASH_DIE_TEMP_DATA_SIZE) == CY_FLASH_DIE_TEMP_DATA_SIZE)
  113. {
  114. status = CYRET_SUCCESS;
  115. while(CY_SPC_BUSY)
  116. {
  117. /* Spin until idle. */
  118. CyDelayUs(1u);
  119. }
  120. break;
  121. }
  122. } while(CY_SPC_BUSY);
  123. }
  124. CySpcUnlock();
  125. }
  126. else
  127. {
  128. status = CYRET_LOCKED;
  129. }
  130. return (status);
  131. }
  132. /*******************************************************************************
  133. * Function Name: CySetTemp
  134. ********************************************************************************
  135. *
  136. * Summary:
  137. * This is a wraparound for CySetTempInt(). It is used to return second
  138. * successful read of temperature value.
  139. *
  140. * Parameters:
  141. * None
  142. *
  143. * Return:
  144. * status:
  145. * CYRET_SUCCESS if successful.
  146. * CYRET_LOCKED if Flash writing already in use
  147. * CYRET_UNKNOWN if there was an SPC error.
  148. *
  149. * uint8 dieTemperature[2]:
  150. * Holds die temperature for the flash writting algorithm. The first byte is
  151. * the sign of the temperature (0 = negative, 1 = positive). The second byte is
  152. * the magnitude.
  153. *
  154. *******************************************************************************/
  155. cystatus CySetTemp(void)
  156. {
  157. cystatus status = CySetTempInt();
  158. if(status == CYRET_SUCCESS)
  159. {
  160. status = CySetTempInt();
  161. }
  162. return (status);
  163. }
  164. /*******************************************************************************
  165. * Function Name: CySetFlashEEBuffer
  166. ********************************************************************************
  167. *
  168. * Summary:
  169. * Sets the user supplied temporary buffer to store SPC data while performing
  170. * flash and EEPROM commands. This buffer is only necessary when Flash ECC is
  171. * disabled.
  172. *
  173. * Parameters:
  174. * buffer:
  175. * Address of block of memory to store temporary memory. The size of the block
  176. * of memory is CYDEV_FLS_ROW_SIZE + CYDEV_ECC_ROW_SIZE.
  177. *
  178. * Return:
  179. * status:
  180. * CYRET_SUCCESS if successful.
  181. * CYRET_BAD_PARAM if the buffer is NULL
  182. *
  183. *******************************************************************************/
  184. cystatus CySetFlashEEBuffer(uint8 * buffer)
  185. {
  186. cystatus status = CYRET_SUCCESS;
  187. CySpcStart();
  188. #if(CYDEV_ECC_ENABLE == 0)
  189. if(NULL == buffer)
  190. {
  191. status = CYRET_BAD_PARAM;
  192. }
  193. else if(CySpcLock() != CYRET_SUCCESS)
  194. {
  195. status = CYRET_LOCKED;
  196. }
  197. else
  198. {
  199. rowBuffer = buffer;
  200. CySpcUnlock();
  201. }
  202. #else
  203. /* To supress the warning */
  204. buffer = buffer;
  205. #endif /* (CYDEV_ECC_ENABLE == 0u) */
  206. return(status);
  207. }
  208. #if(CYDEV_ECC_ENABLE == 1)
  209. /*******************************************************************************
  210. * Function Name: CyWriteRowData
  211. ********************************************************************************
  212. *
  213. * Summary:
  214. * Sends a command to the SPC to load and program a row of data in
  215. * Flash or EEPROM.
  216. *
  217. * Parameters:
  218. * arrayID: ID of the array to write.
  219. * The type of write, Flash or EEPROM, is determined from the array ID.
  220. * The arrays in the part are sequential starting at the first ID for the
  221. * specific memory type. The array ID for the Flash memory lasts from 0x00 to
  222. * 0x3F and for the EEPROM memory it lasts from 0x40 to 0x7F.
  223. * rowAddress: rowAddress of flash row to program.
  224. * rowData: Array of bytes to write.
  225. *
  226. * Return:
  227. * status:
  228. * CYRET_SUCCESS if successful.
  229. * CYRET_LOCKED if the SPC is already in use.
  230. * CYRET_CANCELED if command not accepted
  231. * CYRET_UNKNOWN if there was an SPC error.
  232. *
  233. *******************************************************************************/
  234. cystatus CyWriteRowData(uint8 arrayId, uint16 rowAddress, const uint8 * rowData)
  235. {
  236. uint16 rowSize;
  237. cystatus status;
  238. rowSize = (arrayId > CY_SPC_LAST_FLASH_ARRAYID) ? CYDEV_EEPROM_ROW_SIZE : CYDEV_FLS_ROW_SIZE;
  239. status = CyWriteRowFull(arrayId, rowAddress, rowData, rowSize);
  240. return(status);
  241. }
  242. #else
  243. /*******************************************************************************
  244. * Function Name: CyWriteRowData
  245. ********************************************************************************
  246. *
  247. * Summary:
  248. * Sends a command to the SPC to load and program a row of data in
  249. * Flash or EEPROM.
  250. *
  251. * Parameters:
  252. * arrayID : ID of the array to write.
  253. * The type of write, Flash or EEPROM, is determined from the array ID.
  254. * The arrays in the part are sequential starting at the first ID for the
  255. * specific memory type. The array ID for the Flash memory lasts from 0x00 to
  256. * 0x3F and for the EEPROM memory it lasts from 0x40 to 0x7F.
  257. * rowAddress : rowAddress of flash row to program.
  258. * rowData : Array of bytes to write.
  259. *
  260. * Return:
  261. * status:
  262. * CYRET_SUCCESS if successful.
  263. * CYRET_LOCKED if the SPC is already in use.
  264. * CYRET_CANCELED if command not accepted
  265. * CYRET_UNKNOWN if there was an SPC error.
  266. *
  267. *******************************************************************************/
  268. cystatus CyWriteRowData(uint8 arrayId, uint16 rowAddress, const uint8 * rowData)
  269. {
  270. uint8 i;
  271. uint32 offset;
  272. uint16 rowSize;
  273. cystatus status;
  274. /* Check whether rowBuffer pointer has been initialized by CySetFlashEEBuffer() */
  275. if(NULL != rowBuffer)
  276. {
  277. if(arrayId > CY_SPC_LAST_FLASH_ARRAYID)
  278. {
  279. rowSize = CYDEV_EEPROM_ROW_SIZE;
  280. }
  281. else
  282. {
  283. rowSize = CYDEV_FLS_ROW_SIZE + CYDEV_ECC_ROW_SIZE;
  284. /* Save the ECC area. */
  285. offset = CYDEV_ECC_BASE +
  286. ((uint32)arrayId * CYDEV_ECC_SECTOR_SIZE) +
  287. ((uint32)rowAddress * CYDEV_ECC_ROW_SIZE);
  288. for(i = 0u; i < CYDEV_ECC_ROW_SIZE; i++)
  289. {
  290. *(rowBuffer + CYDEV_FLS_ROW_SIZE + i) = CY_GET_XTND_REG8((void CYFAR *)(offset + i));
  291. }
  292. }
  293. /* Copy the rowdata to the temporary buffer. */
  294. #if(CY_PSOC3)
  295. (void) memcpy((void *) rowBuffer, (void *)((uint32) rowData), (int16) CYDEV_FLS_ROW_SIZE);
  296. #else
  297. (void) memcpy((void *) rowBuffer, (const void *) rowData, CYDEV_FLS_ROW_SIZE);
  298. #endif /* (CY_PSOC3) */
  299. status = CyWriteRowFull(arrayId, rowAddress, rowBuffer, rowSize);
  300. }
  301. else
  302. {
  303. status = CYRET_UNKNOWN;
  304. }
  305. return(status);
  306. }
  307. #endif /* (CYDEV_ECC_ENABLE == 0u) */
  308. #if ((CYDEV_ECC_ENABLE == 0u) && (CYDEV_CONFIGURATION_ECC == 0u))
  309. /*******************************************************************************
  310. * Function Name: CyWriteRowConfig
  311. ********************************************************************************
  312. *
  313. * Summary:
  314. * Sends a command to the SPC to load and program a row of config data in flash.
  315. * This function is only valid for Flash array IDs (not for EEPROM).
  316. *
  317. * Parameters:
  318. * arrayId: ID of the array to write
  319. * The arrays in the part are sequential starting at the first ID for the
  320. * specific memory type. The array ID for the Flash memory lasts
  321. * from 0x00 to 0x3F.
  322. * rowAddress: Address of the sector to erase.
  323. * rowECC: Array of bytes to write.
  324. *
  325. * Return:
  326. * status:
  327. * CYRET_SUCCESS if successful.
  328. * CYRET_LOCKED if the SPC is already in use.
  329. * CYRET_CANCELED if command not accepted
  330. * CYRET_UNKNOWN if there was an SPC error.
  331. *
  332. *******************************************************************************/
  333. cystatus CyWriteRowConfig(uint8 arrayId, uint16 rowAddress, const uint8 * rowECC)\
  334. {
  335. uint32 offset;
  336. uint16 i;
  337. cystatus status;
  338. /* Check whether rowBuffer pointer has been initialized by CySetFlashEEBuffer() */
  339. if(NULL != rowBuffer)
  340. {
  341. /* Read the existing flash data. */
  342. offset = ((uint32)arrayId * CYDEV_FLS_SECTOR_SIZE) +
  343. ((uint32)rowAddress * CYDEV_FLS_ROW_SIZE);
  344. #if (CYDEV_FLS_BASE != 0u)
  345. offset += CYDEV_FLS_BASE;
  346. #endif /* (CYDEV_FLS_BASE != 0u) */
  347. for (i = 0u; i < CYDEV_FLS_ROW_SIZE; i++)
  348. {
  349. rowBuffer[i] = CY_GET_XTND_REG8((void CYFAR *)(offset + i));
  350. }
  351. #if(CY_PSOC3)
  352. (void) memcpy((void *)&rowBuffer[CYDEV_FLS_ROW_SIZE],
  353. (void *)(uint32)rowECC,
  354. (int16)CYDEV_ECC_ROW_SIZE);
  355. #else
  356. (void) memcpy((void *)&rowBuffer[CYDEV_FLS_ROW_SIZE],
  357. (const void *)rowECC,
  358. CYDEV_ECC_ROW_SIZE);
  359. #endif /* (CY_PSOC3) */
  360. status = CyWriteRowFull(arrayId, rowAddress, rowBuffer, CYDEV_FLS_ROW_SIZE + CYDEV_ECC_ROW_SIZE);
  361. }
  362. else
  363. {
  364. status = CYRET_UNKNOWN;
  365. }
  366. return (status);
  367. }
  368. #endif /* ((CYDEV_ECC_ENABLE == 0u) && (CYDEV_CONFIGURATION_ECC == 0u)) */
  369. /*******************************************************************************
  370. * Function Name: CyWriteRowFull
  371. ********************************************************************************
  372. * Summary:
  373. * Sends a command to the SPC to load and program a row of data in flash.
  374. * rowData array is expected to contain Flash and ECC data if needed.
  375. *
  376. * Parameters:
  377. * arrayId: FLASH or EEPROM array id.
  378. * rowData: Pointer to a row of data to write.
  379. * rowNumber: Zero based number of the row.
  380. * rowSize: Size of the row.
  381. *
  382. * Return:
  383. * CYRET_SUCCESS if successful.
  384. * CYRET_LOCKED if the SPC is already in use.
  385. * CYRET_CANCELED if command not accepted
  386. * CYRET_UNKNOWN if there was an SPC error.
  387. *
  388. *******************************************************************************/
  389. cystatus CyWriteRowFull(uint8 arrayId, uint16 rowNumber, const uint8* rowData, uint16 rowSize) \
  390. {
  391. cystatus status;
  392. if(CySpcLock() == CYRET_SUCCESS)
  393. {
  394. /* Load row data into SPC internal latch */
  395. status = CySpcLoadRow(arrayId, rowData, rowSize);
  396. if(CYRET_STARTED == status)
  397. {
  398. while(CY_SPC_BUSY)
  399. {
  400. /* Wait for SPC to finish and get SPC status */
  401. CyDelayUs(1u);
  402. }
  403. /* Hide SPC status */
  404. if(CY_SPC_STATUS_SUCCESS == CY_SPC_READ_STATUS)
  405. {
  406. status = CYRET_SUCCESS;
  407. }
  408. else
  409. {
  410. status = CYRET_UNKNOWN;
  411. }
  412. if(CYRET_SUCCESS == status)
  413. {
  414. /* Erase and program flash with the data from SPC interval latch */
  415. status = CySpcWriteRow(arrayId, rowNumber, dieTemperature[0u], dieTemperature[1u]);
  416. if(CYRET_STARTED == status)
  417. {
  418. while(CY_SPC_BUSY)
  419. {
  420. /* Wait for SPC to finish and get SPC status */
  421. CyDelayUs(1u);
  422. }
  423. /* Hide SPC status */
  424. if(CY_SPC_STATUS_SUCCESS == CY_SPC_READ_STATUS)
  425. {
  426. status = CYRET_SUCCESS;
  427. }
  428. else
  429. {
  430. status = CYRET_UNKNOWN;
  431. }
  432. }
  433. }
  434. }
  435. CySpcUnlock();
  436. }
  437. else
  438. {
  439. status = CYRET_LOCKED;
  440. }
  441. return(status);
  442. }
  443. /*******************************************************************************
  444. * Function Name: CyFlash_SetWaitCycles
  445. ********************************************************************************
  446. *
  447. * Summary:
  448. * Sets the number of clock cycles the cache will wait before it samples data
  449. * coming back from Flash. This function must be called before increasing CPU
  450. * clock frequency. It can optionally be called after lowering CPU clock
  451. * frequency in order to improve CPU performance.
  452. *
  453. * Parameters:
  454. * uint8 freq:
  455. * Frequency of operation in Megahertz.
  456. *
  457. * Return:
  458. * None
  459. *
  460. *******************************************************************************/
  461. void CyFlash_SetWaitCycles(uint8 freq)
  462. {
  463. uint8 interruptState;
  464. /* Save current global interrupt enable and disable it */
  465. interruptState = CyEnterCriticalSection();
  466. /***************************************************************************
  467. * The number of clock cycles the cache will wait before it samples data
  468. * coming back from Flash must be equal or greater to to the CPU frequency
  469. * outlined in clock cycles.
  470. ***************************************************************************/
  471. #if (CY_PSOC3)
  472. if (freq <= 22u)
  473. {
  474. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  475. ((uint8)(CY_FLASH_LESSER_OR_EQUAL_22MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  476. }
  477. else if (freq <= 44u)
  478. {
  479. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  480. ((uint8)(CY_FLASH_LESSER_OR_EQUAL_44MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  481. }
  482. else
  483. {
  484. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  485. ((uint8)(CY_FLASH_GREATER_44MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  486. }
  487. #endif /* (CY_PSOC3) */
  488. #if (CY_PSOC5)
  489. if (freq <= 16u)
  490. {
  491. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  492. ((uint8)(CY_FLASH_LESSER_OR_EQUAL_16MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  493. }
  494. else if (freq <= 33u)
  495. {
  496. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  497. ((uint8)(CY_FLASH_LESSER_OR_EQUAL_33MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  498. }
  499. else if (freq <= 50u)
  500. {
  501. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  502. ((uint8)(CY_FLASH_LESSER_OR_EQUAL_50MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  503. }
  504. else
  505. {
  506. *CY_FLASH_CONTROL_PTR = ((*CY_FLASH_CONTROL_PTR & ((uint8)(~CY_FLASH_CYCLES_MASK))) |
  507. ((uint8)(CY_FLASH_GREATER_51MHz << CY_FLASH_CYCLES_MASK_SHIFT)));
  508. }
  509. #endif /* (CY_PSOC5) */
  510. /* Restore global interrupt enable state */
  511. CyExitCriticalSection(interruptState);
  512. }
  513. /*******************************************************************************
  514. * Function Name: CyEEPROM_Start
  515. ********************************************************************************
  516. *
  517. * Summary:
  518. * Enable the EEPROM.
  519. *
  520. * Parameters:
  521. * None
  522. *
  523. * Return:
  524. * None
  525. *
  526. *******************************************************************************/
  527. void CyEEPROM_Start(void)
  528. {
  529. /* Active Power Mode */
  530. *CY_FLASH_PM_ACT_EEFLASH_PTR |= CY_FLASH_PM_EE_MASK;
  531. /* Standby Power Mode */
  532. *CY_FLASH_PM_ALTACT_EEFLASH_PTR |= CY_FLASH_PM_EE_MASK;
  533. }
  534. /*******************************************************************************
  535. * Function Name: CyEEPROM_Stop
  536. ********************************************************************************
  537. *
  538. * Summary:
  539. * Disable the EEPROM.
  540. *
  541. * Parameters:
  542. * None
  543. *
  544. * Return:
  545. * None
  546. *
  547. *******************************************************************************/
  548. void CyEEPROM_Stop (void)
  549. {
  550. /* Active Power Mode */
  551. *CY_FLASH_PM_ACT_EEFLASH_PTR &= ((uint8)(~CY_FLASH_PM_EE_MASK));
  552. /* Standby Power Mode */
  553. *CY_FLASH_PM_ALTACT_EEFLASH_PTR &= ((uint8)(~CY_FLASH_PM_EE_MASK));
  554. }
  555. /*******************************************************************************
  556. * Function Name: CyEEPROM_ReadReserve
  557. ********************************************************************************
  558. *
  559. * Summary:
  560. * Request access to the EEPROM for reading and wait until access is available.
  561. *
  562. * Parameters:
  563. * None
  564. *
  565. * Return:
  566. * None
  567. *
  568. *******************************************************************************/
  569. void CyEEPROM_ReadReserve(void)
  570. {
  571. /* Make a request for PHUB to have access */
  572. *CY_FLASH_EE_SCR_PTR |= CY_FLASH_EE_SCR_AHB_EE_REQ;
  573. while (0u == (*CY_FLASH_EE_SCR_PTR & CY_FLASH_EE_SCR_AHB_EE_ACK))
  574. {
  575. /* Wait for acknowledgement from PHUB */
  576. }
  577. }
  578. /*******************************************************************************
  579. * Function Name: CyEEPROM_ReadRelease
  580. ********************************************************************************
  581. *
  582. * Summary:
  583. * Release the read reservation of the EEPROM.
  584. *
  585. * Parameters:
  586. * None
  587. *
  588. * Return:
  589. * None
  590. *
  591. *******************************************************************************/
  592. void CyEEPROM_ReadRelease(void)
  593. {
  594. *CY_FLASH_EE_SCR_PTR |= 0x00u;
  595. }
  596. /* [] END OF FILE */