stm32l1xx_hal_flash_ramfunc.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_flash_ramfunc.c
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 5-September-2014
  7. * @brief FLASH RAMFUNC driver.
  8. * This file provides a Flash firmware functions which should be
  9. * executed from internal SRAM
  10. *
  11. * @verbatim
  12. *** ARM Compiler ***
  13. --------------------
  14. [..] RAM functions are defined using the toolchain options.
  15. Functions that are be executed in RAM should reside in a separate
  16. source module. Using the 'Options for File' dialog you can simply change
  17. the 'Code / Const' area of a module to a memory space in physical RAM.
  18. Available memory areas are declared in the 'Target' tab of the
  19. Options for Target' dialog.
  20. *** ICCARM Compiler ***
  21. -----------------------
  22. [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
  23. *** GNU Compiler ***
  24. --------------------
  25. [..] RAM functions are defined using a specific toolchain attribute
  26. "__attribute__((section(".RamFunc")))".
  27. @endverbatim
  28. ******************************************************************************
  29. * @attention
  30. *
  31. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  32. *
  33. * Redistribution and use in source and binary forms, with or without modification,
  34. * are permitted provided that the following conditions are met:
  35. * 1. Redistributions of source code must retain the above copyright notice,
  36. * this list of conditions and the following disclaimer.
  37. * 2. Redistributions in binary form must reproduce the above copyright notice,
  38. * this list of conditions and the following disclaimer in the documentation
  39. * and/or other materials provided with the distribution.
  40. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  41. * may be used to endorse or promote products derived from this software
  42. * without specific prior written permission.
  43. *
  44. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  45. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  46. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  47. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  48. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  49. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  50. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  51. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  52. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  53. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. *
  55. ******************************************************************************
  56. */
  57. /* Includes ------------------------------------------------------------------*/
  58. #include "stm32l1xx_hal.h"
  59. /** @addtogroup STM32L1xx_HAL_Driver
  60. * @{
  61. */
  62. /** @defgroup FLASHRamfunc FLASHRamfunc
  63. * @brief FLASH functions executed from RAM
  64. * @{
  65. */
  66. #ifdef HAL_FLASH_MODULE_ENABLED
  67. /* Private typedef -----------------------------------------------------------*/
  68. /* Private define ------------------------------------------------------------*/
  69. /* Private macro -------------------------------------------------------------*/
  70. /* Private variables ---------------------------------------------------------*/
  71. /* Private function prototypes -----------------------------------------------*/
  72. static __RAM_FUNC FLASHRAM_WaitForLastOperation(uint32_t Timeout);
  73. /* Private functions ---------------------------------------------------------*/
  74. /** @defgroup FLASHRamfunc_Exported_Functions FLASH RAM Exported Functions
  75. *
  76. @verbatim
  77. ===============================================================================
  78. ##### ramfunc functions #####
  79. ===============================================================================
  80. [..]
  81. This subsection provides a set of functions that should be executed from RAM
  82. transfers.
  83. @endverbatim
  84. * @{
  85. */
  86. /** @defgroup FLASHRamfunc_Exported_Functions_Group1 FLASH RAM Peripheral features functions
  87. * @{
  88. */
  89. /**
  90. * @brief Enable the power down mode during RUN mode.
  91. * @note This function can be used only when the user code is running from Internal SRAM.
  92. * @retval None
  93. */
  94. __RAM_FUNC HAL_FLASHEx_EnableRunPowerDown(void)
  95. {
  96. /* Enable the Power Down in Run mode*/
  97. __HAL_FLASH_POWER_DOWN_ENABLE();
  98. return HAL_OK;
  99. }
  100. /**
  101. * @brief Disable the power down mode during RUN mode.
  102. * @note This function can be used only when the user code is running from Internal SRAM.
  103. * @retval None
  104. */
  105. __RAM_FUNC HAL_FLASHEx_DisableRunPowerDown(void)
  106. {
  107. /* Disable the Power Down in Run mode*/
  108. __HAL_FLASH_POWER_DOWN_DISABLE();
  109. return HAL_OK;
  110. }
  111. /**
  112. * @}
  113. */
  114. /** @defgroup FLASHRamfunc_Exported_Functions_Group2 FLASH RAM Programming and erasing operation functions
  115. *
  116. @verbatim
  117. @endverbatim
  118. * @{
  119. */
  120. #if defined (STM32L151xD) || defined (STM32L152xD) || defined (STM32L162xD) || \
  121. defined(STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE)
  122. /**
  123. * @brief Erases a specified 2 page in program memory in parallel.
  124. * @note This function can be used only for STM32L151xD, STM32L152xD), STM32L162xD and Cat5 devices.
  125. * To correctly run this function, the HAL_FLASH_Unlock() function
  126. * must be called before.
  127. * Call the HAL_FLASH_Lock() to disable the flash memory access
  128. * (recommended to protect the FLASH memory against possible unwanted operation).
  129. * @param Page_Address1: The page address in program memory to be erased in
  130. * the first Bank (BANK1). This parameter should be between FLASH_BASE
  131. * and FLASH_BANK1_END.
  132. * @param Page_Address2: The page address in program memory to be erased in
  133. * the second Bank (BANK2). This parameter should be between FLASH_BANK2_BASE
  134. * and FLASH_BANK2_END.
  135. * @note A Page is erased in the Program memory only if the address to load
  136. * is the start address of a page (multiple of 256 bytes).
  137. * @retval HAL Status: The returned value can be:
  138. * HAL_ERROR, HAL_OK or HAL_TIMEOUT.
  139. */
  140. __RAM_FUNC HAL_FLASHEx_EraseParallelPage(uint32_t Page_Address1, uint32_t Page_Address2)
  141. {
  142. HAL_StatusTypeDef status = HAL_OK;
  143. /* Wait for last operation to be completed */
  144. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  145. if(status == HAL_OK)
  146. {
  147. /* If the previous operation is completed, proceed to erase the page */
  148. /* Set the PARALLBANK bit */
  149. FLASH->PECR |= FLASH_PECR_PARALLBANK;
  150. /* Set the ERASE bit */
  151. FLASH->PECR |= FLASH_PECR_ERASE;
  152. /* Set PROG bit */
  153. FLASH->PECR |= FLASH_PECR_PROG;
  154. /* Write 00000000h to the first word of the first program page to erase */
  155. *(__IO uint32_t *)Page_Address1 = 0x00000000;
  156. /* Write 00000000h to the first word of the second program page to erase */
  157. *(__IO uint32_t *)Page_Address2 = 0x00000000;
  158. /* Wait for last operation to be completed */
  159. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  160. /* If the erase operation is completed, disable the ERASE, PROG and PARALLBANK bits */
  161. FLASH->PECR &= (uint32_t)(~FLASH_PECR_PROG);
  162. FLASH->PECR &= (uint32_t)(~FLASH_PECR_ERASE);
  163. FLASH->PECR &= (uint32_t)(~FLASH_PECR_PARALLBANK);
  164. }
  165. /* Return the Erase Status */
  166. return status;
  167. }
  168. /**
  169. * @brief Programs 2 half page in program memory in parallel.
  170. * @note This function can be used only for STM32L151xD, STM32L152xD), STM32L162xD and Cat5 devices.
  171. * @param Address1: specifies the first address to be written in the first bank
  172. * (BANK1). This parameter should be between FLASH_BASE and (FLASH_BANK1_END - FLASH_PAGE_SIZE).
  173. * @param pBuffer1: pointer to the buffer containing the data to be written
  174. * to the first half page in the first bank.
  175. * @param Address2: specifies the second address to be written in the second bank
  176. * (BANK2). This parameter should be between FLASH_BANK2_BASE and (FLASH_BANK2_END - FLASH_PAGE_SIZE).
  177. * @param pBuffer2: pointer to the buffer containing the data to be written
  178. * to the second half page in the second bank.
  179. * @note To correctly run this function, the HAL_FLASH_Unlock() function
  180. * must be called before.
  181. * Call the HAL_FLASH_Lock() to disable the flash memory access
  182. * (recommended to protect the FLASH memory against possible unwanted operation).
  183. * @note Half page write is possible only from SRAM.
  184. * @note If there are more than 32 words to write, after 32 words another
  185. * Half Page programming operation starts and has to be finished.
  186. * @note A half page is written to the program memory only if the first
  187. * address to load is the start address of a half page (multiple of 128
  188. * bytes) and the 31 remaining words to load are in the same half page.
  189. * @note During the Program memory half page write all read operations are
  190. * forbidden (this includes DMA read operations and debugger read
  191. * operations such as breakpoints, periodic updates, etc.).
  192. * @note If a PGAERR is set during a Program memory half page write, the
  193. * complete write operation is aborted. Software should then reset the
  194. * FPRG and PROG/DATA bits and restart the write operation from the
  195. * beginning.
  196. * @retval HAL Status: The returned value can be:
  197. * HAL_ERROR, HAL_OK or HAL_TIMEOUT.
  198. */
  199. __RAM_FUNC HAL_FLASHEx_ProgramParallelHalfPage(uint32_t Address1, uint32_t* pBuffer1, uint32_t Address2, uint32_t* pBuffer2)
  200. {
  201. uint32_t count = 0;
  202. HAL_StatusTypeDef status = HAL_OK;
  203. /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008)
  204. This bit prevents the interruption of multicycle instructions and therefore
  205. will increase the interrupt latency. of Cortex-M3. */
  206. SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;
  207. /* Wait for last operation to be completed */
  208. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  209. if(status == HAL_OK)
  210. {
  211. /* If the previous operation is completed, proceed to program the new
  212. half page */
  213. FLASH->PECR |= FLASH_PECR_PARALLBANK;
  214. FLASH->PECR |= FLASH_PECR_FPRG;
  215. FLASH->PECR |= FLASH_PECR_PROG;
  216. /* Wait for last operation to be completed */
  217. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  218. if(status == HAL_OK)
  219. {
  220. /* Write the first half page directly with 32 different words */
  221. while(count < 32)
  222. {
  223. *(__IO uint32_t*) ((uint32_t)(Address1 + (4 * count))) = *(pBuffer1++);
  224. count ++;
  225. }
  226. count = 0;
  227. /* Write the second half page directly with 32 different words */
  228. while(count < 32)
  229. {
  230. *(__IO uint32_t*) ((uint32_t)(Address2 + (4 * count))) = *(pBuffer2++);
  231. count ++;
  232. }
  233. /* Wait for last operation to be completed */
  234. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  235. }
  236. /* if the write operation is completed, disable the PROG, FPRG and PARALLBANK bits */
  237. FLASH->PECR &= (uint32_t)(~FLASH_PECR_PROG);
  238. FLASH->PECR &= (uint32_t)(~FLASH_PECR_FPRG);
  239. FLASH->PECR &= (uint32_t)(~FLASH_PECR_PARALLBANK);
  240. }
  241. SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;
  242. /* Return the Write Status */
  243. return status;
  244. }
  245. #endif /* STM32L151xD || STM32L152xD || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
  246. /**
  247. * @brief Programs a half page in program memory.
  248. * @param Address: specifies the address to be written.
  249. * @param pBuffer: pointer to the buffer containing the data to be written to
  250. * the half page.
  251. * @note To correctly run this function, the HAL_FLASH_Unlock() function
  252. * must be called before.
  253. * Call the HAL_FLASH_Lock() to disable the flash memory access
  254. * (recommended to protect the FLASH memory against possible unwanted operation)
  255. * @note Half page write is possible only from SRAM.
  256. * @note If there are more than 32 words to write, after 32 words another
  257. * Half Page programming operation starts and has to be finished.
  258. * @note A half page is written to the program memory only if the first
  259. * address to load is the start address of a half page (multiple of 128
  260. * bytes) and the 31 remaining words to load are in the same half page.
  261. * @note During the Program memory half page write all read operations are
  262. * forbidden (this includes DMA read operations and debugger read
  263. * operations such as breakpoints, periodic updates, etc.).
  264. * @note If a PGAERR is set during a Program memory half page write, the
  265. * complete write operation is aborted. Software should then reset the
  266. * FPRG and PROG/DATA bits and restart the write operation from the
  267. * beginning.
  268. * @retval HAL Status: The returned value can be:
  269. * HAL_ERROR, HAL_OK or HAL_TIMEOUT.
  270. */
  271. __RAM_FUNC HAL_FLASHEx_HalfPageProgram(uint32_t Address, uint32_t* pBuffer)
  272. {
  273. uint32_t count = 0;
  274. HAL_StatusTypeDef status = HAL_OK;
  275. /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008)
  276. This bit prevents the interruption of multicycle instructions and therefore
  277. will increase the interrupt latency. of Cortex-M3. */
  278. SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;
  279. /* Wait for last operation to be completed */
  280. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  281. if(status == HAL_OK)
  282. {
  283. /* if the previous operation is completed, proceed to program the new
  284. half page */
  285. FLASH->PECR |= FLASH_PECR_FPRG;
  286. FLASH->PECR |= FLASH_PECR_PROG;
  287. /* Write one half page directly with 32 different words */
  288. while(count < 32)
  289. {
  290. *(__IO uint32_t*) ((uint32_t)(Address + (4 * count))) = *(pBuffer++);
  291. count ++;
  292. }
  293. /* Wait for last operation to be completed */
  294. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  295. /* if the write operation is completed, disable the PROG and FPRG bits */
  296. FLASH->PECR &= (uint32_t)(~FLASH_PECR_PROG);
  297. FLASH->PECR &= (uint32_t)(~FLASH_PECR_FPRG);
  298. }
  299. SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;
  300. /* Return the Write Status */
  301. return status;
  302. }
  303. /**
  304. * @}
  305. */
  306. /** @defgroup FLASHRamfunc_Exported_Functions_Group3 FLASH RAM DATA EEPROM functions
  307. *
  308. @verbatim
  309. @endverbatim
  310. * @{
  311. */
  312. /**
  313. * @brief Erase a double word in data memory.
  314. * @param Address: specifies the address to be erased.
  315. * @note To correctly run this function, the HAL_FLASH_EEPROM_Unlock() function
  316. * must be called before.
  317. * Call the HAL_FLASH_EEPROM_Lock() to he data EEPROM access
  318. * and Flash program erase control register access(recommended to protect
  319. * the DATA_EEPROM against possible unwanted operation).
  320. * @note Data memory double word erase is possible only from SRAM.
  321. * @note A double word is erased to the data memory only if the first address
  322. * to load is the start address of a double word (multiple of 8 bytes).
  323. * @note During the Data memory double word erase, all read operations are
  324. * forbidden (this includes DMA read operations and debugger read
  325. * operations such as breakpoints, periodic updates, etc.).
  326. * @retval HAL Status: The returned value can be:
  327. * HAL_ERROR, HAL_OK or HAL_TIMEOUT.
  328. */
  329. __RAM_FUNC HAL_FLASHEx_DATAEEPROM_EraseDoubleWord(uint32_t Address)
  330. {
  331. HAL_StatusTypeDef status = HAL_OK;
  332. /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008)
  333. This bit prevents the interruption of multicycle instructions and therefore
  334. will increase the interrupt latency. of Cortex-M3. */
  335. SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;
  336. /* Wait for last operation to be completed */
  337. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  338. if(status == HAL_OK)
  339. {
  340. /* If the previous operation is completed, proceed to erase the next double word */
  341. /* Set the ERASE bit */
  342. FLASH->PECR |= FLASH_PECR_ERASE;
  343. /* Set DATA bit */
  344. FLASH->PECR |= FLASH_PECR_DATA;
  345. /* Write 00000000h to the 2 words to erase */
  346. *(__IO uint32_t *)Address = 0x00000000;
  347. Address += 4;
  348. *(__IO uint32_t *)Address = 0x00000000;
  349. /* Wait for last operation to be completed */
  350. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  351. /* If the erase operation is completed, disable the ERASE and DATA bits */
  352. FLASH->PECR &= (uint32_t)(~FLASH_PECR_ERASE);
  353. FLASH->PECR &= (uint32_t)(~FLASH_PECR_DATA);
  354. }
  355. SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;
  356. /* Return the erase status */
  357. return status;
  358. }
  359. /**
  360. * @brief Write a double word in data memory without erase.
  361. * @param Address: specifies the address to be written.
  362. * @param Data: specifies the data to be written.
  363. * @note To correctly run this function, the HAL_FLASH_EEPROM_Unlock() function
  364. * must be called before.
  365. * Call the HAL_FLASH_EEPROM_Lock() to he data EEPROM access
  366. * and Flash program erase control register access(recommended to protect
  367. * the DATA_EEPROM against possible unwanted operation).
  368. * @note Data memory double word write is possible only from SRAM.
  369. * @note A data memory double word is written to the data memory only if the
  370. * first address to load is the start address of a double word (multiple
  371. * of double word).
  372. * @note During the Data memory double word write, all read operations are
  373. * forbidden (this includes DMA read operations and debugger read
  374. * operations such as breakpoints, periodic updates, etc.).
  375. * @retval HAL Status: The returned value can be:
  376. * HAL_ERROR, HAL_OK or HAL_TIMEOUT.
  377. */
  378. __RAM_FUNC HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord(uint32_t Address, uint64_t Data)
  379. {
  380. HAL_StatusTypeDef status = HAL_OK;
  381. /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008)
  382. This bit prevents the interruption of multicycle instructions and therefore
  383. will increase the interrupt latency. of Cortex-M3. */
  384. SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;
  385. /* Wait for last operation to be completed */
  386. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  387. if(status == HAL_OK)
  388. {
  389. /* If the previous operation is completed, proceed to program the new data*/
  390. FLASH->PECR |= FLASH_PECR_FPRG;
  391. FLASH->PECR |= FLASH_PECR_DATA;
  392. /* Write the 2 words */
  393. *(__IO uint32_t *)Address = (uint32_t) Data;
  394. Address += 4;
  395. *(__IO uint32_t *)Address = (uint32_t) (Data >> 32);
  396. /* Wait for last operation to be completed */
  397. status = FLASHRAM_WaitForLastOperation(HAL_FLASH_TIMEOUT_VALUE);
  398. /* If the write operation is completed, disable the FPRG and DATA bits */
  399. FLASH->PECR &= (uint32_t)(~FLASH_PECR_FPRG);
  400. FLASH->PECR &= (uint32_t)(~FLASH_PECR_DATA);
  401. }
  402. SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;
  403. /* Return the Write Status */
  404. return status;
  405. }
  406. /**
  407. * @}
  408. */
  409. /**
  410. * @}
  411. */
  412. /** @defgroup FLASHRamfunc_Private_Functions FLASH RAM Private Functions
  413. * @{
  414. */
  415. /**
  416. * @brief Wait for a FLASH operation to complete.
  417. * @param Timeout: maximum flash operationtimeout
  418. * @retval HAL status
  419. */
  420. static __RAM_FUNC FLASHRAM_WaitForLastOperation(uint32_t Timeout)
  421. {
  422. /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
  423. Even if the FLASH operation fails, the BUSY flag will be reset and an error
  424. flag will be set */
  425. while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) && (Timeout != 0x00))
  426. {
  427. Timeout--;
  428. }
  429. if(Timeout == 0x00 )
  430. {
  431. return HAL_TIMEOUT;
  432. }
  433. if( (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) != RESET) ||
  434. (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) != RESET) ||
  435. (__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR) != RESET) ||
  436. #if defined (STM32L151xBA) || defined (STM32L152xBA) || \
  437. defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC)
  438. (__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) != RESET) ||
  439. #endif /* STM32L151xBA || STM32L152xBA || STM32L151xC || STM32L152xC || STM32L162xC */
  440. #if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || \
  441. defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || \
  442. defined(STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE)
  443. (__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERRUSR) != RESET) ||
  444. #endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
  445. (__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR) != RESET) )
  446. {
  447. return HAL_ERROR;
  448. }
  449. /* If there is an error flag set */
  450. return HAL_OK;
  451. }
  452. #endif /* HAL_FLASH_MODULE_ENABLED */
  453. /**
  454. * @}
  455. */
  456. /**
  457. * @}
  458. */
  459. /**
  460. * @}
  461. */
  462. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/