AN2594: EEPROM emulation in STM32F10x microcontrollers: eeprom.c Source File

AN2594: EEPROM

eeprom.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    EEPROM_Emulation/src/eeprom.c 
00004   * @author  MCD Application Team
00005   * @version V3.1.0
00006   * @date    07/27/2009
00007   * @brief   This file provides all the EEPROM emulation firmware functions.
00008   ******************************************************************************
00009   * @copy
00010   *
00011   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017   *
00018   * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
00019   */ 
00020 /** @addtogroup EEPROM_Emulation
00021   * @{
00022   */ 
00023 
00024 /* Includes ------------------------------------------------------------------*/
00025 #include "eeprom.h"
00026 
00027 /* Private typedef -----------------------------------------------------------*/
00028 /* Private define ------------------------------------------------------------*/
00029 /* Private macro -------------------------------------------------------------*/
00030 /* Private variables ---------------------------------------------------------*/
00031 
00032 /* Global variable used to store variable value in read sequence */
00033 uint16_t DataVar = 0;
00034 
00035 /* Virtual address defined by the user: 0xFFFF value is prohibited */
00036 extern uint16_t VirtAddVarTab[NumbOfVar];
00037 
00038 /* Private function prototypes -----------------------------------------------*/
00039 /* Private functions ---------------------------------------------------------*/
00040 static FLASH_Status EE_Format(void);
00041 static uint16_t EE_FindValidPage(uint8_t Operation);
00042 static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data);
00043 static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data);
00044 
00045 /**
00046   * @brief  Restore the pages to a known good state in case of page's status
00047   *   corruption after a power loss.
00048   * @param  None.
00049   * @retval - Flash error code: on write Flash error
00050   *         - FLASH_COMPLETE: on success
00051   */
00052 uint16_t EE_Init(void)
00053 {
00054   uint16_t PageStatus0 = 6, PageStatus1 = 6;
00055   uint16_t VarIdx = 0;
00056   uint16_t EepromStatus = 0, ReadStatus = 0;
00057   int16_t x = -1;
00058   uint16_t  FlashStatus;
00059 
00060   /* Get Page0 status */
00061   PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
00062   /* Get Page1 status */
00063   PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
00064 
00065   /* Check for invalid header states and repair if necessary */
00066   switch (PageStatus0)
00067   {
00068     case ERASED:
00069       if (PageStatus1 == VALID_PAGE) /* Page0 erased, Page1 valid */
00070       {
00071         /* Erase Page0 */
00072         FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS);
00073         /* If erase operation was failed, a Flash error code is returned */
00074         if (FlashStatus != FLASH_COMPLETE)
00075         {
00076           return FlashStatus;
00077         }
00078       }
00079       else if (PageStatus1 == RECEIVE_DATA) /* Page0 erased, Page1 receive */
00080       {
00081         /* Erase Page0 */
00082         FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS);
00083         /* If erase operation was failed, a Flash error code is returned */
00084         if (FlashStatus != FLASH_COMPLETE)
00085         {
00086           return FlashStatus;
00087         }
00088         /* Mark Page1 as valid */
00089         FlashStatus = FLASH_ProgramHalfWord(PAGE1_BASE_ADDRESS, VALID_PAGE);
00090         /* If program operation was failed, a Flash error code is returned */
00091         if (FlashStatus != FLASH_COMPLETE)
00092         {
00093           return FlashStatus;
00094         }
00095       }
00096       else /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */
00097       {
00098         /* Erase both Page0 and Page1 and set Page0 as valid page */
00099         FlashStatus = EE_Format();
00100         /* If erase/program operation was failed, a Flash error code is returned */
00101         if (FlashStatus != FLASH_COMPLETE)
00102         {
00103           return FlashStatus;
00104         }
00105       }
00106       break;
00107 
00108     case RECEIVE_DATA:
00109       if (PageStatus1 == VALID_PAGE) /* Page0 receive, Page1 valid */
00110       {
00111         /* Transfer data from Page1 to Page0 */
00112         for (VarIdx = 0; VarIdx < NumbOfVar; VarIdx++)
00113         {
00114           if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
00115           {
00116             x = VarIdx;
00117           }
00118           if (VarIdx != x)
00119           {
00120             /* Read the last variables' updates */
00121             ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
00122             /* In case variable corresponding to the virtual address was found */
00123             if (ReadStatus != 0x1)
00124             {
00125               /* Transfer the variable to the Page0 */
00126               EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
00127               /* If program operation was failed, a Flash error code is returned */
00128               if (EepromStatus != FLASH_COMPLETE)
00129               {
00130                 return EepromStatus;
00131               }
00132             }
00133           }
00134         }
00135         /* Mark Page0 as valid */
00136         FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE);
00137         /* If program operation was failed, a Flash error code is returned */
00138         if (FlashStatus != FLASH_COMPLETE)
00139         {
00140           return FlashStatus;
00141         }
00142         /* Erase Page1 */
00143         FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
00144         /* If erase operation was failed, a Flash error code is returned */
00145         if (FlashStatus != FLASH_COMPLETE)
00146         {
00147           return FlashStatus;
00148         }
00149       }
00150       else if (PageStatus1 == ERASED) /* Page0 receive, Page1 erased */
00151       {
00152         /* Erase Page1 */
00153         FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
00154         /* If erase operation was failed, a Flash error code is returned */
00155         if (FlashStatus != FLASH_COMPLETE)
00156         {
00157           return FlashStatus;
00158         }
00159         /* Mark Page0 as valid */
00160         FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE);
00161         /* If program operation was failed, a Flash error code is returned */
00162         if (FlashStatus != FLASH_COMPLETE)
00163         {
00164           return FlashStatus;
00165         }
00166       }
00167       else /* Invalid state -> format eeprom */
00168       {
00169         /* Erase both Page0 and Page1 and set Page0 as valid page */
00170         FlashStatus = EE_Format();
00171         /* If erase/program operation was failed, a Flash error code is returned */
00172         if (FlashStatus != FLASH_COMPLETE)
00173         {
00174           return FlashStatus;
00175         }
00176       }
00177       break;
00178 
00179     case VALID_PAGE:
00180       if (PageStatus1 == VALID_PAGE) /* Invalid state -> format eeprom */
00181       {
00182         /* Erase both Page0 and Page1 and set Page0 as valid page */
00183         FlashStatus = EE_Format();
00184         /* If erase/program operation was failed, a Flash error code is returned */
00185         if (FlashStatus != FLASH_COMPLETE)
00186         {
00187           return FlashStatus;
00188         }
00189       }
00190       else if (PageStatus1 == ERASED) /* Page0 valid, Page1 erased */
00191       {
00192         /* Erase Page1 */
00193         FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
00194         /* If erase operation was failed, a Flash error code is returned */
00195         if (FlashStatus != FLASH_COMPLETE)
00196         {
00197           return FlashStatus;
00198         }
00199       }
00200       else /* Page0 valid, Page1 receive */
00201       {
00202         /* Transfer data from Page0 to Page1 */
00203         for (VarIdx = 0; VarIdx < NumbOfVar; VarIdx++)
00204         {
00205           if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
00206           {
00207             x = VarIdx;
00208           }
00209           if (VarIdx != x)
00210           {
00211             /* Read the last variables' updates */
00212             ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
00213             /* In case variable corresponding to the virtual address was found */
00214             if (ReadStatus != 0x1)
00215             {
00216               /* Transfer the variable to the Page1 */
00217               EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
00218               /* If program operation was failed, a Flash error code is returned */
00219               if (EepromStatus != FLASH_COMPLETE)
00220               {
00221                 return EepromStatus;
00222               }
00223             }
00224           }
00225         }
00226         /* Mark Page1 as valid */
00227         FlashStatus = FLASH_ProgramHalfWord(PAGE1_BASE_ADDRESS, VALID_PAGE);
00228         /* If program operation was failed, a Flash error code is returned */
00229         if (FlashStatus != FLASH_COMPLETE)
00230         {
00231           return FlashStatus;
00232         }
00233         /* Erase Page0 */
00234         FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS);
00235         /* If erase operation was failed, a Flash error code is returned */
00236         if (FlashStatus != FLASH_COMPLETE)
00237         {
00238           return FlashStatus;
00239         }
00240       }
00241       break;
00242 
00243     default:  /* Any other state -> format eeprom */
00244       /* Erase both Page0 and Page1 and set Page0 as valid page */
00245       FlashStatus = EE_Format();
00246       /* If erase/program operation was failed, a Flash error code is returned */
00247       if (FlashStatus != FLASH_COMPLETE)
00248       {
00249         return FlashStatus;
00250       }
00251       break;
00252   }
00253 
00254   return FLASH_COMPLETE;
00255 }
00256 
00257 /**
00258   * @brief  Returns the last stored variable data, if found, which correspond to
00259   *   the passed virtual address
00260   * @param  VirtAddress: Variable virtual address
00261   * @param  Data: Global variable contains the read variable value
00262   * @retval Success or error status:
00263   *           - 0: if variable was found
00264   *           - 1: if the variable was not found
00265   *           - NO_VALID_PAGE: if no valid page was found.
00266   */
00267 uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data)
00268 {
00269   uint16_t ValidPage = PAGE0;
00270   uint16_t AddressValue = 0x5555, ReadStatus = 1;
00271   uint32_t Address = 0x08010000, PageStartAddress = 0x08010000;
00272 
00273   /* Get active Page for read operation */
00274   ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
00275 
00276   /* Check if there is no valid page */
00277   if (ValidPage == NO_VALID_PAGE)
00278   {
00279     return  NO_VALID_PAGE;
00280   }
00281 
00282   /* Get the valid Page start Address */
00283   PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
00284 
00285   /* Get the valid Page end Address */
00286   Address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
00287 
00288   /* Check each active page address starting from end */
00289   while (Address > (PageStartAddress + 2))
00290   {
00291     /* Get the current location content to be compared with virtual address */
00292     AddressValue = (*(__IO uint16_t*)Address);
00293 
00294     /* Compare the read address with the virtual address */
00295     if (AddressValue == VirtAddress)
00296     {
00297       /* Get content of Address-2 which is variable value */
00298       *Data = (*(__IO uint16_t*)(Address - 2));
00299 
00300       /* In case variable value is read, reset ReadStatus flag */
00301       ReadStatus = 0;
00302 
00303       break;
00304     }
00305     else
00306     {
00307       /* Next address location */
00308       Address = Address - 4;
00309     }
00310   }
00311 
00312   /* Return ReadStatus value: (0: variable exist, 1: variable doesn't exist) */
00313   return ReadStatus;
00314 }
00315 
00316 /**
00317   * @brief  Writes/upadtes variable data in EEPROM.
00318   * @param  VirtAddress: Variable virtual address
00319   * @param  Data: 16 bit data to be written
00320   * @retval Success or error status:
00321   *           - FLASH_COMPLETE: on success
00322   *           - PAGE_FULL: if valid page is full
00323   *           - NO_VALID_PAGE: if no valid page was found
00324   *           - Flash error code: on write Flash error
00325   */
00326 uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data)
00327 {
00328   uint16_t Status = 0;
00329 
00330   /* Write the variable virtual address and value in the EEPROM */
00331   Status = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
00332 
00333   /* In case the EEPROM active page is full */
00334   if (Status == PAGE_FULL)
00335   {
00336     /* Perform Page transfer */
00337     Status = EE_PageTransfer(VirtAddress, Data);
00338   }
00339 
00340   /* Return last operation status */
00341   return Status;
00342 }
00343 
00344 /**
00345   * @brief  Erases PAGE0 and PAGE1 and writes VALID_PAGE header to PAGE0
00346   * @param  None
00347   * @retval Status of the last operation (Flash write or erase) done during
00348   *         EEPROM formating
00349   */
00350 static FLASH_Status EE_Format(void)
00351 {
00352   FLASH_Status FlashStatus = FLASH_COMPLETE;
00353 
00354   /* Erase Page0 */
00355   FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS);
00356 
00357   /* If erase operation was failed, a Flash error code is returned */
00358   if (FlashStatus != FLASH_COMPLETE)
00359   {
00360     return FlashStatus;
00361   }
00362 
00363   /* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
00364   FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE);
00365 
00366   /* If program operation was failed, a Flash error code is returned */
00367   if (FlashStatus != FLASH_COMPLETE)
00368   {
00369     return FlashStatus;
00370   }
00371 
00372   /* Erase Page1 */
00373   FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
00374 
00375   /* Return Page1 erase operation status */
00376   return FlashStatus;
00377 }
00378 
00379 /**
00380   * @brief  Find valid Page for write or read operation
00381   * @param  Operation: operation to achieve on the valid page.
00382   *   This parameter can be one of the following values:
00383   *     @arg READ_FROM_VALID_PAGE: read operation from valid page
00384   *     @arg WRITE_IN_VALID_PAGE: write operation from valid page
00385   * @retval Valid page number (PAGE0 or PAGE1) or NO_VALID_PAGE in case
00386   *   of no valid page was found
00387   */
00388 static uint16_t EE_FindValidPage(uint8_t Operation)
00389 {
00390   uint16_t PageStatus0 = 6, PageStatus1 = 6;
00391 
00392   /* Get Page0 actual status */
00393   PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
00394 
00395   /* Get Page1 actual status */
00396   PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
00397 
00398   /* Write or read operation */
00399   switch (Operation)
00400   {
00401     case WRITE_IN_VALID_PAGE:   /* ---- Write operation ---- */
00402       if (PageStatus1 == VALID_PAGE)
00403       {
00404         /* Page0 receiving data */
00405         if (PageStatus0 == RECEIVE_DATA)
00406         {
00407           return PAGE0;         /* Page0 valid */
00408         }
00409         else
00410         {
00411           return PAGE1;         /* Page1 valid */
00412         }
00413       }
00414       else if (PageStatus0 == VALID_PAGE)
00415       {
00416         /* Page1 receiving data */
00417         if (PageStatus1 == RECEIVE_DATA)
00418         {
00419           return PAGE1;         /* Page1 valid */
00420         }
00421         else
00422         {
00423           return PAGE0;         /* Page0 valid */
00424         }
00425       }
00426       else
00427       {
00428         return NO_VALID_PAGE;   /* No valid Page */
00429       }
00430 
00431     case READ_FROM_VALID_PAGE:  /* ---- Read operation ---- */
00432       if (PageStatus0 == VALID_PAGE)
00433       {
00434         return PAGE0;           /* Page0 valid */
00435       }
00436       else if (PageStatus1 == VALID_PAGE)
00437       {
00438         return PAGE1;           /* Page1 valid */
00439       }
00440       else
00441       {
00442         return NO_VALID_PAGE ;  /* No valid Page */
00443       }
00444 
00445     default:
00446       return PAGE0;             /* Page0 valid */
00447   }
00448 }
00449 
00450 /**
00451   * @brief  Verify if active page is full and Writes variable in EEPROM.
00452   * @param  VirtAddress: 16 bit virtual address of the variable
00453   * @param  Data: 16 bit data to be written as variable value
00454   * @retval Success or error status:
00455   *           - FLASH_COMPLETE: on success
00456   *           - PAGE_FULL: if valid page is full
00457   *           - NO_VALID_PAGE: if no valid page was found
00458   *           - Flash error code: on write Flash error
00459   */
00460 static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data)
00461 {
00462   FLASH_Status FlashStatus = FLASH_COMPLETE;
00463   uint16_t ValidPage = PAGE0;
00464   uint32_t Address = 0x08010000, PageEndAddress = 0x080107FF;
00465 
00466   /* Get valid Page for write operation */
00467   ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
00468 
00469   /* Check if there is no valid page */
00470   if (ValidPage == NO_VALID_PAGE)
00471   {
00472     return  NO_VALID_PAGE;
00473   }
00474 
00475   /* Get the valid Page start Address */
00476   Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
00477 
00478   /* Get the valid Page end Address */
00479   PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
00480 
00481   /* Check each active page address starting from begining */
00482   while (Address < PageEndAddress)
00483   {
00484     /* Verify if Address and Address+2 contents are 0xFFFFFFFF */
00485     if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF)
00486     {
00487       /* Set variable data */
00488       FlashStatus = FLASH_ProgramHalfWord(Address, Data);
00489       /* If program operation was failed, a Flash error code is returned */
00490       if (FlashStatus != FLASH_COMPLETE)
00491       {
00492         return FlashStatus;
00493       }
00494       /* Set variable virtual address */
00495       FlashStatus = FLASH_ProgramHalfWord(Address + 2, VirtAddress);
00496       /* Return program operation status */
00497       return FlashStatus;
00498     }
00499     else
00500     {
00501       /* Next address location */
00502       Address = Address + 4;
00503     }
00504   }
00505 
00506   /* Return PAGE_FULL in case the valid page is full */
00507   return PAGE_FULL;
00508 }
00509 
00510 /**
00511   * @brief  Transfers last updated variables data from the full Page to
00512   *   an empty one.
00513   * @param  VirtAddress: 16 bit virtual address of the variable
00514   * @param  Data: 16 bit data to be written as variable value
00515   * @retval Success or error status:
00516   *           - FLASH_COMPLETE: on success
00517   *           - PAGE_FULL: if valid page is full
00518   *           - NO_VALID_PAGE: if no valid page was found
00519   *           - Flash error code: on write Flash error
00520   */
00521 static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data)
00522 {
00523   FLASH_Status FlashStatus = FLASH_COMPLETE;
00524   uint32_t NewPageAddress = 0x080103FF, OldPageAddress = 0x08010000;
00525   uint16_t ValidPage = PAGE0, VarIdx = 0;
00526   uint16_t EepromStatus = 0, ReadStatus = 0;
00527 
00528   /* Get active Page for read operation */
00529   ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
00530 
00531   if (ValidPage == PAGE1)       /* Page1 valid */
00532   {
00533     /* New page address where variable will be moved to */
00534     NewPageAddress = PAGE0_BASE_ADDRESS;
00535 
00536     /* Old page address where variable will be taken from */
00537     OldPageAddress = PAGE1_BASE_ADDRESS;
00538   }
00539   else if (ValidPage == PAGE0)  /* Page0 valid */
00540   {
00541     /* New page address where variable will be moved to */
00542     NewPageAddress = PAGE1_BASE_ADDRESS;
00543 
00544     /* Old page address where variable will be taken from */
00545     OldPageAddress = PAGE0_BASE_ADDRESS;
00546   }
00547   else
00548   {
00549     return NO_VALID_PAGE;       /* No valid Page */
00550   }
00551 
00552   /* Set the new Page status to RECEIVE_DATA status */
00553   FlashStatus = FLASH_ProgramHalfWord(NewPageAddress, RECEIVE_DATA);
00554   /* If program operation was failed, a Flash error code is returned */
00555   if (FlashStatus != FLASH_COMPLETE)
00556   {
00557     return FlashStatus;
00558   }
00559 
00560   /* Write the variable passed as parameter in the new active page */
00561   EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
00562   /* If program operation was failed, a Flash error code is returned */
00563   if (EepromStatus != FLASH_COMPLETE)
00564   {
00565     return EepromStatus;
00566   }
00567 
00568   /* Transfer process: transfer variables from old to the new active page */
00569   for (VarIdx = 0; VarIdx < NumbOfVar; VarIdx++)
00570   {
00571     if (VirtAddVarTab[VarIdx] != VirtAddress)  /* Check each variable except the one passed as parameter */
00572     {
00573       /* Read the other last variable updates */
00574       ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
00575       /* In case variable corresponding to the virtual address was found */
00576       if (ReadStatus != 0x1)
00577       {
00578         /* Transfer the variable to the new active page */
00579         EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
00580         /* If program operation was failed, a Flash error code is returned */
00581         if (EepromStatus != FLASH_COMPLETE)
00582         {
00583           return EepromStatus;
00584         }
00585       }
00586     }
00587   }
00588 
00589   /* Erase the old Page: Set old Page status to ERASED status */
00590   FlashStatus = FLASH_ErasePage(OldPageAddress);
00591   /* If erase operation was failed, a Flash error code is returned */
00592   if (FlashStatus != FLASH_COMPLETE)
00593   {
00594     return FlashStatus;
00595   }
00596 
00597   /* Set new Page status to VALID_PAGE status */
00598   FlashStatus = FLASH_ProgramHalfWord(NewPageAddress, VALID_PAGE);
00599   /* If program operation was failed, a Flash error code is returned */
00600   if (FlashStatus != FLASH_COMPLETE)
00601   {
00602     return FlashStatus;
00603   }
00604 
00605   /* Return last operation flash status */
00606   return FlashStatus;
00607 }
00608 
00609 /**
00610   * @}
00611   */ 
00612 
00613 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit www.st.com/STM32