]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_STM32L152_Discovery_IAR/ST_Code/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_flash_ramfunc.c
Tidy up STM32L low power demo and add 'comprehensive demo' option.
[freertos] / FreeRTOS / Demo / CORTEX_STM32L152_Discovery_IAR / ST_Code / Libraries / STM32L1xx_StdPeriph_Driver / src / stm32l1xx_flash_ramfunc.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_flash_ramfunc.c\r
4   * @author  MCD Application Team\r
5   * @version V1.1.1\r
6   * @date    05-March-2012\r
7   * @brief   This file provides all the Flash firmware functions which should be\r
8   *          executed from the internal SRAM. This file should be placed in \r
9   *          internal SRAM. \r
10   *          Other FLASH memory functions that can be used from the FLASH are \r
11   *          defined in the "stm32l1xx_flash.c" file. \r
12 @verbatim\r
13 \r
14     *** ARM Compiler ***\r
15     --------------------\r
16     [..] RAM functions are defined using the toolchain options. \r
17          Functions that are be executed in RAM should reside in a separate\r
18          source module. Using the 'Options for File' dialog you can simply change\r
19          the 'Code / Const' area of a module to a memory space in physical RAM.\r
20          Available memory areas are declared in the 'Target' tab of the \r
21          Options for Target' dialog.\r
22 \r
23     *** ICCARM Compiler ***\r
24     -----------------------\r
25     [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".\r
26 \r
27     *** GNU Compiler ***\r
28     --------------------\r
29     [..] RAM functions are defined using a specific toolchain attribute\r
30          "__attribute__((section(".data")))".\r
31 \r
32     *** TASKING Compiler ***\r
33     ------------------------\r
34     [..] RAM functions are defined using a specific toolchain pragma. This \r
35          pragma is defined inside this file.\r
36 \r
37 @endverbatim\r
38   *\r
39   ******************************************************************************\r
40   * @attention\r
41   *\r
42   * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>\r
43   *\r
44   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");\r
45   * You may not use this file except in compliance with the License.\r
46   * You may obtain a copy of the License at:\r
47   *\r
48   *        http://www.st.com/software_license_agreement_liberty_v2\r
49   *\r
50   * Unless required by applicable law or agreed to in writing, software \r
51   * distributed under the License is distributed on an "AS IS" BASIS, \r
52   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
53   * See the License for the specific language governing permissions and\r
54   * limitations under the License.\r
55   *\r
56   ******************************************************************************\r
57   */\r
58 \r
59 /* Includes ------------------------------------------------------------------*/\r
60 #include "stm32l1xx_flash.h"\r
61 \r
62 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
63   * @{\r
64   */\r
65 \r
66 /** @defgroup FLASH \r
67   * @brief FLASH driver modules\r
68   * @{\r
69   */ \r
70 \r
71 /* Private typedef -----------------------------------------------------------*/\r
72 /* Private define ------------------------------------------------------------*/\r
73 /* Private macro -------------------------------------------------------------*/\r
74 /* Private variables ---------------------------------------------------------*/\r
75 /* Private function prototypes -----------------------------------------------*/\r
76 static __RAM_FUNC GetStatus(void);\r
77 static __RAM_FUNC WaitForLastOperation(uint32_t Timeout);\r
78 \r
79 /* Private functions ---------------------------------------------------------*/\r
80  \r
81 /** @defgroup FLASH_Private_Functions\r
82   * @{\r
83   */ \r
84 \r
85 /** @addtogroup FLASH_Group1\r
86  *\r
87 @verbatim  \r
88 @endverbatim\r
89   * @{\r
90   */  \r
91 #if defined (  __TASKING__  )\r
92 #pragma section_code_init on\r
93 #endif\r
94 \r
95 /**\r
96   * @brief  Enable or disable the power down mode during RUN mode.\r
97   * @note  This function can be used only when the user code is running from Internal SRAM.\r
98   * @param  NewState: new state of the power down mode during RUN mode.\r
99   *   This parameter can be: ENABLE or DISABLE.\r
100   * @retval None\r
101   */\r
102 __RAM_FUNC FLASH_RUNPowerDownCmd(FunctionalState NewState)\r
103 {\r
104   FLASH_Status status = FLASH_COMPLETE;\r
105  \r
106   if (NewState != DISABLE)\r
107   {\r
108      /* Unlock the RUN_PD bit */\r
109      FLASH->PDKEYR = FLASH_PDKEY1;\r
110      FLASH->PDKEYR = FLASH_PDKEY2;\r
111      \r
112      /* Set the RUN_PD bit in  FLASH_ACR register to put Flash in power down mode */\r
113      FLASH->ACR |= (uint32_t)FLASH_ACR_RUN_PD;\r
114 \r
115      if((FLASH->ACR & FLASH_ACR_RUN_PD) != FLASH_ACR_RUN_PD)\r
116      {\r
117        status = FLASH_ERROR_PROGRAM;\r
118      }\r
119   }\r
120   else\r
121   {\r
122     /* Clear the RUN_PD bit in  FLASH_ACR register to put Flash in idle  mode */\r
123     FLASH->ACR &= (uint32_t)(~(uint32_t)FLASH_ACR_RUN_PD);\r
124   }\r
125 \r
126   /* Return the Write Status */\r
127   return status;  \r
128 }\r
129 \r
130 /**\r
131   * @}\r
132   */\r
133 \r
134 /** @addtogroup FLASH_Group2\r
135  *\r
136 @verbatim  \r
137 @endverbatim\r
138   * @{\r
139   */\r
140 \r
141 /**\r
142   * @brief  Erases a specified 2 page in program memory in parallel.\r
143   * @note   This function can be used only for STM32L1XX_HD density devices.\r
144   *         To correctly run this function, the FLASH_Unlock() function\r
145   *         must be called before.\r
146   *         Call the FLASH_Lock() to disable the flash memory access \r
147   *        (recommended to protect the FLASH memory against possible unwanted operation).\r
148   * @param  Page_Address1: The page address in program memory to be erased in \r
149   *         the first Bank (BANK1). This parameter should be between 0x08000000\r
150   *         and 0x0802FF00.\r
151   * @param  Page_Address2: The page address in program memory to be erased in \r
152   *         the second Bank (BANK2). This parameter should be between 0x08030000\r
153   *         and 0x0805FF00.\r
154   * @note   A Page is erased in the Program memory only if the address to load \r
155   *         is the start address of a page (multiple of 256 bytes).\r
156   * @retval FLASH Status: The returned value can be: \r
157   *         FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.\r
158   */\r
159 FLASH_Status FLASH_EraseParallelPage(uint32_t Page_Address1, uint32_t Page_Address2)\r
160 {\r
161   FLASH_Status status = FLASH_COMPLETE;\r
162 \r
163   /* Wait for last operation to be completed */\r
164   status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
165   \r
166   if(status == FLASH_COMPLETE)\r
167   {\r
168     /* If the previous operation is completed, proceed to erase the page */\r
169 \r
170     /* Set the PARALLBANK bit */\r
171     FLASH->PECR |= FLASH_PECR_PARALLBANK;\r
172     \r
173     /* Set the ERASE bit */\r
174     FLASH->PECR |= FLASH_PECR_ERASE;\r
175 \r
176     /* Set PROG bit */\r
177     FLASH->PECR |= FLASH_PECR_PROG;\r
178   \r
179     /* Write 00000000h to the first word of the first program page to erase */\r
180     *(__IO uint32_t *)Page_Address1 = 0x00000000;\r
181     /* Write 00000000h to the first word of the second program page to erase */    \r
182     *(__IO uint32_t *)Page_Address2 = 0x00000000;    \r
183  \r
184     /* Wait for last operation to be completed */\r
185     status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
186 \r
187     /* If the erase operation is completed, disable the ERASE, PROG and PARALLBANK bits */\r
188     FLASH->PECR &= (uint32_t)(~FLASH_PECR_PROG);\r
189     FLASH->PECR &= (uint32_t)(~FLASH_PECR_ERASE);\r
190     FLASH->PECR &= (uint32_t)(~FLASH_PECR_PARALLBANK);   \r
191   }     \r
192   /* Return the Erase Status */\r
193   return status;\r
194 }\r
195 \r
196 /**\r
197   * @brief  Programs a half page in program memory.\r
198   * @param  Address: specifies the address to be written.\r
199   * @param  pBuffer: pointer to the buffer  containing the data to be  written to \r
200   *         the half page.\r
201   * @note   To correctly run this function, the FLASH_Unlock() function\r
202   *         must be called before.\r
203   *         Call the FLASH_Lock() to disable the flash memory access  \r
204   *         (recommended to protect the FLASH memory against possible unwanted operation)\r
205   * @note   Half page write is possible only from SRAM.\r
206   * @note   If there are more than 32 words to write, after 32 words another \r
207   *         Half Page programming operation starts and has to be finished.\r
208   * @note   A half page is written to the program memory only if the first \r
209   *         address to load is the start address of a half page (multiple of 128 \r
210   *         bytes) and the 31 remaining words to load are in the same half page.\r
211   * @note   During the Program memory half page write all read operations are \r
212   *         forbidden (this includes DMA read operations and debugger read \r
213   *         operations such as breakpoints, periodic updates, etc.).\r
214   * @note   If a PGAERR is set during a Program memory half page write, the \r
215   *         complete write operation is aborted. Software should then reset the \r
216   *         FPRG and PROG/DATA bits and restart the write operation from the \r
217   *         beginning.\r
218   * @retval FLASH Status: The returned value can be:  \r
219   *   FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. \r
220   */\r
221 __RAM_FUNC FLASH_ProgramHalfPage(uint32_t Address, uint32_t* pBuffer)\r
222 {\r
223   uint32_t count = 0; \r
224    \r
225   FLASH_Status status = FLASH_COMPLETE;\r
226 \r
227   /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008) \r
228      This bit prevents the interruption of multicycle instructions and therefore \r
229      will increase the interrupt latency. of Cortex-M3. */\r
230   SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;\r
231   \r
232   /* Wait for last operation to be completed */\r
233   status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
234   \r
235   if(status == FLASH_COMPLETE)\r
236   {\r
237     /* if the previous operation is completed, proceed to program the new  \r
238     half page */\r
239     FLASH->PECR |= FLASH_PECR_FPRG;\r
240     FLASH->PECR |= FLASH_PECR_PROG;\r
241     \r
242     /* Write one half page directly with 32 different words */\r
243     while(count < 32)\r
244     {\r
245       *(__IO uint32_t*) (Address + (4 * count)) = *(pBuffer++);\r
246       count ++;  \r
247     }\r
248     /* Wait for last operation to be completed */\r
249     status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
250  \r
251     /* if the write operation is completed, disable the PROG and FPRG bits */\r
252     FLASH->PECR &= (uint32_t)(~FLASH_PECR_PROG);\r
253     FLASH->PECR &= (uint32_t)(~FLASH_PECR_FPRG);\r
254   }\r
255 \r
256   SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;\r
257     \r
258   /* Return the Write Status */\r
259   return status;\r
260 }\r
261 \r
262 /**\r
263   * @brief  Programs 2 half page in program memory in parallel.\r
264   * @param  Address1: specifies the first address to be written in the first bank \r
265   *        (BANK1). This parameter should be between 0x08000000 and 0x0802FF80.\r
266   * @param  pBuffer1: pointer to the buffer  containing the data to be  written \r
267   *         to the first half page in the first bank.\r
268   * @param  Address2: specifies the second address to be written in the second bank\r
269   *        (BANK2). This parameter should be between 0x08030000 and 0x0805FF80.\r
270   * @param  pBuffer2: pointer to the buffer containing the data to be  written \r
271   *         to the second half page in the second bank.\r
272   * @note   This function can be used only for STM32L1XX_HD density devices.\r
273   * @note   To correctly run this function, the FLASH_Unlock() function\r
274   *         must be called before.\r
275   *         Call the FLASH_Lock() to disable the flash memory access  \r
276   *         (recommended to protect the FLASH memory against possible unwanted operation).\r
277   * @note   Half page write is possible only from SRAM.\r
278   * @note   If there are more than 32 words to write, after 32 words another \r
279   *         Half Page programming operation starts and has to be finished.\r
280   * @note   A half page is written to the program memory only if the first \r
281   *         address to load is the start address of a half page (multiple of 128 \r
282   *         bytes) and the 31 remaining words to load are in the same half page.\r
283   * @note   During the Program memory half page write all read operations are \r
284   *         forbidden (this includes DMA read operations and debugger read \r
285   *         operations such as breakpoints, periodic updates, etc.).\r
286   * @note   If a PGAERR is set during a Program memory half page write, the \r
287   *         complete write operation is aborted. Software should then reset the \r
288   *         FPRG and PROG/DATA bits and restart the write operation from the \r
289   *         beginning.\r
290   * @retval FLASH Status: The returned value can be:  \r
291   *         FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.\r
292   */\r
293 __RAM_FUNC FLASH_ProgramParallelHalfPage(uint32_t Address1, uint32_t* pBuffer1, uint32_t Address2, uint32_t* pBuffer2)\r
294 {\r
295   uint32_t count = 0; \r
296    \r
297   FLASH_Status status = FLASH_COMPLETE;\r
298 \r
299   /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008) \r
300      This bit prevents the interruption of multicycle instructions and therefore \r
301      will increase the interrupt latency. of Cortex-M3. */\r
302   SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;\r
303 \r
304   /* Wait for last operation to be completed */\r
305   status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
306   \r
307   if(status == FLASH_COMPLETE)\r
308   {\r
309     /* If the previous operation is completed, proceed to program the new  \r
310        half page */\r
311     FLASH->PECR |= FLASH_PECR_PARALLBANK;\r
312     FLASH->PECR |= FLASH_PECR_FPRG;\r
313     FLASH->PECR |= FLASH_PECR_PROG;\r
314     \r
315     /* Write the first half page directly with 32 different words */\r
316     while(count < 32)\r
317     {\r
318       *(__IO uint32_t*) (Address1 + (4 * count)) = *(pBuffer1++);\r
319       count ++;  \r
320     }\r
321     count = 0;\r
322     /* Write the second half page directly with 32 different words */\r
323     while(count < 32)\r
324     {\r
325       *(__IO uint32_t*) (Address2 + (4 * count)) = *(pBuffer2++);\r
326       count ++;  \r
327     }\r
328     /* Wait for last operation to be completed */\r
329     status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
330  \r
331     /* if the write operation is completed, disable the PROG, FPRG and PARALLBANK bits */\r
332     FLASH->PECR &= (uint32_t)(~FLASH_PECR_PROG);\r
333     FLASH->PECR &= (uint32_t)(~FLASH_PECR_FPRG);\r
334     FLASH->PECR &= (uint32_t)(~FLASH_PECR_PARALLBANK);\r
335   }\r
336 \r
337   SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;\r
338     \r
339   /* Return the Write Status */\r
340   return status;\r
341 }\r
342 \r
343 /**\r
344   * @}\r
345   */\r
346 \r
347 /** @addtogroup FLASH_Group3\r
348  *\r
349 @verbatim  \r
350 @endverbatim\r
351   * @{\r
352   */\r
353 \r
354 /**\r
355   * @brief  Erase a double word in data memory.\r
356   * @param  Address: specifies the address to be erased.\r
357   * @note   To correctly run this function, the DATA_EEPROM_Unlock() function\r
358   *         must be called before.\r
359   *         Call the DATA_EEPROM_Lock() to he data EEPROM access\r
360   *         and Flash program erase control register access(recommended to protect \r
361   *         the DATA_EEPROM against possible unwanted operation).\r
362   * @note   Data memory double word erase is possible only from SRAM.\r
363   * @note   A double word is erased to the data memory only if the first address \r
364   *         to load is the start address of a double word (multiple of 8 bytes).\r
365   * @note   During the Data memory double word erase, all read operations are \r
366   *         forbidden (this includes DMA read operations and debugger read \r
367   *         operations such as breakpoints, periodic updates, etc.).\r
368   * @retval FLASH Status: The returned value can be: \r
369   *   FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.\r
370   */\r
371 \r
372 __RAM_FUNC DATA_EEPROM_EraseDoubleWord(uint32_t Address)\r
373 {\r
374   FLASH_Status status = FLASH_COMPLETE;\r
375   \r
376   /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008) \r
377      This bit prevents the interruption of multicycle instructions and therefore \r
378      will increase the interrupt latency. of Cortex-M3. */\r
379   SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;\r
380     \r
381   /* Wait for last operation to be completed */\r
382   status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
383   \r
384   if(status == FLASH_COMPLETE)\r
385   {\r
386     /* If the previous operation is completed, proceed to erase the next double word */\r
387     /* Set the ERASE bit */\r
388     FLASH->PECR |= FLASH_PECR_ERASE;\r
389 \r
390     /* Set DATA bit */\r
391     FLASH->PECR |= FLASH_PECR_DATA;\r
392    \r
393     /* Write 00000000h to the 2 words to erase */\r
394     *(__IO uint32_t *)Address = 0x00000000;\r
395     Address += 4;\r
396     *(__IO uint32_t *)Address = 0x00000000;\r
397    \r
398     /* Wait for last operation to be completed */\r
399     status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
400     \r
401     /* If the erase operation is completed, disable the ERASE and DATA bits */\r
402     FLASH->PECR &= (uint32_t)(~FLASH_PECR_ERASE);\r
403     FLASH->PECR &= (uint32_t)(~FLASH_PECR_DATA);\r
404   }  \r
405   \r
406   SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;\r
407     \r
408   /* Return the erase status */\r
409   return status;\r
410 }\r
411 \r
412 /**\r
413   * @brief  Write a double word in data memory without erase.\r
414   * @param  Address: specifies the address to be written.\r
415   * @param  Data: specifies the data to be written.\r
416   * @note   To correctly run this function, the DATA_EEPROM_Unlock() function\r
417   *         must be called before.\r
418   *         Call the DATA_EEPROM_Lock() to he data EEPROM access\r
419   *         and Flash program erase control register access(recommended to protect \r
420   *         the DATA_EEPROM against possible unwanted operation).\r
421   * @note   Data memory double word write is possible only from SRAM.\r
422   * @note   A data memory double word is written to the data memory only if the \r
423   *         first address to load is the start address of a double word (multiple \r
424   *         of double word).\r
425   * @note   During the Data memory double word write, all read operations are \r
426   *         forbidden (this includes DMA read operations and debugger read \r
427   *         operations such as breakpoints, periodic updates, etc.).\r
428   * @retval FLASH Status: The returned value can be: \r
429   *   FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. \r
430   */ \r
431 __RAM_FUNC DATA_EEPROM_ProgramDoubleWord(uint32_t Address, uint64_t Data)\r
432 {\r
433   FLASH_Status status = FLASH_COMPLETE;\r
434 \r
435   /* Set the DISMCYCINT[0] bit in the Auxillary Control Register (0xE000E008) \r
436      This bit prevents the interruption of multicycle instructions and therefore \r
437      will increase the interrupt latency. of Cortex-M3. */\r
438   SCnSCB->ACTLR |= SCnSCB_ACTLR_DISMCYCINT_Msk;\r
439     \r
440   /* Wait for last operation to be completed */\r
441   status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
442   \r
443   if(status == FLASH_COMPLETE)\r
444   {\r
445     /* If the previous operation is completed, proceed to program the new data*/\r
446     FLASH->PECR |= FLASH_PECR_FPRG;\r
447     FLASH->PECR |= FLASH_PECR_DATA;\r
448     \r
449     /* Write the 2 words */  \r
450      *(__IO uint32_t *)Address = (uint32_t) Data;\r
451      Address += 4;\r
452      *(__IO uint32_t *)Address = (uint32_t) (Data >> 32);\r
453     \r
454     /* Wait for last operation to be completed */\r
455     status = WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);\r
456     \r
457     /* If the write operation is completed, disable the FPRG and DATA bits */\r
458     FLASH->PECR &= (uint32_t)(~FLASH_PECR_FPRG);\r
459     FLASH->PECR &= (uint32_t)(~FLASH_PECR_DATA);     \r
460   }\r
461   \r
462   SCnSCB->ACTLR &= ~SCnSCB_ACTLR_DISMCYCINT_Msk;\r
463     \r
464   /* Return the Write Status */\r
465   return status;\r
466 }\r
467 \r
468 /**\r
469   * @}\r
470   */\r
471 \r
472 /**\r
473   * @brief  Returns the FLASH Status.\r
474   * @param  None\r
475   * @retval FLASH Status: The returned value can be: FLASH_BUSY, \r
476   *   FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP or FLASH_COMPLETE\r
477   */\r
478 static __RAM_FUNC GetStatus(void)\r
479 {\r
480   FLASH_Status FLASHstatus = FLASH_COMPLETE;\r
481   \r
482   if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY) \r
483   {\r
484     FLASHstatus = FLASH_BUSY;\r
485   }\r
486   else \r
487   {  \r
488     if((FLASH->SR & (uint32_t)FLASH_FLAG_WRPERR)!= (uint32_t)0x00)\r
489     { \r
490       FLASHstatus = FLASH_ERROR_WRP;\r
491     }\r
492     else \r
493     {\r
494       if((FLASH->SR & (uint32_t)0x1E00) != (uint32_t)0x00)\r
495       {\r
496         FLASHstatus = FLASH_ERROR_PROGRAM; \r
497       }\r
498       else\r
499       {\r
500         FLASHstatus = FLASH_COMPLETE;\r
501       }\r
502     }\r
503   }\r
504   /* Return the FLASH Status */\r
505   return FLASHstatus;\r
506 }\r
507 \r
508 /**\r
509   * @brief  Waits for a FLASH operation to complete or a TIMEOUT to occur.\r
510   * @param  Timeout: FLASH programming Timeout\r
511   * @retval FLASH Status: The returned value can be: FLASH_BUSY, \r
512   *   FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or \r
513   *   FLASH_TIMEOUT.\r
514   */\r
515 static __RAM_FUNC  WaitForLastOperation(uint32_t Timeout)\r
516\r
517   __IO FLASH_Status status = FLASH_COMPLETE;\r
518    \r
519   /* Check for the FLASH Status */\r
520   status = GetStatus();\r
521   \r
522   /* Wait for a FLASH operation to complete or a TIMEOUT to occur */\r
523   while((status == FLASH_BUSY) && (Timeout != 0x00))\r
524   {\r
525     status = GetStatus();\r
526     Timeout--;\r
527   }\r
528   \r
529   if(Timeout == 0x00 )\r
530   {\r
531     status = FLASH_TIMEOUT;\r
532   }\r
533   /* Return the operation status */\r
534   return status;\r
535 }\r
536 \r
537 #if defined (  __TASKING__  )\r
538 #pragma section_code_init restore\r
539 #endif\r
540 \r
541 /**\r
542   * @}\r
543   */\r
544    \r
545   /**\r
546   * @}\r
547   */ \r
548 \r
549 /**\r
550   * @}\r
551   */ \r
552 \r
553 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r