stm32f10x_flash.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f10x_flash.h
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   This file contains all the functions prototypes for the FLASH 
00008   *          firmware library.
00009   ******************************************************************************
00010   * @copy
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00020   */ 
00021 
00022 /* Define to prevent recursive inclusion -------------------------------------*/
00023 #ifndef __STM32F10x_FLASH_H
00024 #define __STM32F10x_FLASH_H
00025 
00026 #ifdef __cplusplus
00027  extern "C" {
00028 #endif
00029 
00030 /* Includes ------------------------------------------------------------------*/
00031 #include "stm32f10x.h"
00032 
00033 /** @addtogroup STM32F10x_StdPeriph_Driver
00034   * @{
00035   */
00036 
00037 /** @addtogroup FLASH
00038   * @{
00039   */
00040 
00041 /** @defgroup FLASH_Exported_Types
00042   * @{
00043   */
00044 
00045 /** 
00046   * @brief  FLASH Status  
00047   */
00048 
00049 typedef enum
00050 { 
00051   FLASH_BUSY = 1,
00052   FLASH_ERROR_PG,
00053   FLASH_ERROR_WRP,
00054   FLASH_COMPLETE,
00055   FLASH_TIMEOUT
00056 }FLASH_Status;
00057 
00058 /**
00059   * @}
00060   */
00061 
00062 /** @defgroup FLASH_Exported_Constants
00063   * @{
00064   */
00065 
00066 /** @defgroup Flash_Latency 
00067   * @{
00068   */
00069 
00070 #define FLASH_Latency_0                ((uint32_t)0x00000000)  /*!< FLASH Zero Latency cycle */
00071 #define FLASH_Latency_1                ((uint32_t)0x00000001)  /*!< FLASH One Latency cycle */
00072 #define FLASH_Latency_2                ((uint32_t)0x00000002)  /*!< FLASH Two Latency cycles */
00073 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
00074                                    ((LATENCY) == FLASH_Latency_1) || \
00075                                    ((LATENCY) == FLASH_Latency_2))
00076 /**
00077   * @}
00078   */
00079 
00080 /** @defgroup Half_Cycle_Enable_Disable 
00081   * @{
00082   */
00083 
00084 #define FLASH_HalfCycleAccess_Enable   ((uint32_t)0x00000008)  /*!< FLASH Half Cycle Enable */
00085 #define FLASH_HalfCycleAccess_Disable  ((uint32_t)0x00000000)  /*!< FLASH Half Cycle Disable */
00086 #define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \
00087                                                ((STATE) == FLASH_HalfCycleAccess_Disable)) 
00088 /**
00089   * @}
00090   */
00091 
00092 /** @defgroup Prefetch_Buffer_Enable_Disable 
00093   * @{
00094   */
00095 
00096 #define FLASH_PrefetchBuffer_Enable    ((uint32_t)0x00000010)  /*!< FLASH Prefetch Buffer Enable */
00097 #define FLASH_PrefetchBuffer_Disable   ((uint32_t)0x00000000)  /*!< FLASH Prefetch Buffer Disable */
00098 #define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \
00099                                               ((STATE) == FLASH_PrefetchBuffer_Disable)) 
00100 /**
00101   * @}
00102   */
00103 
00104 /** @defgroup Option_Bytes_Write_Protection 
00105   * @{
00106   */
00107 
00108 /* Values to be used with STM32 Low and Medium density devices */
00109 #define FLASH_WRProt_Pages0to3         ((uint32_t)0x00000001) /*!< STM32 Low and Medium density devices: Write protection of page 0 to 3 */
00110 #define FLASH_WRProt_Pages4to7         ((uint32_t)0x00000002) /*!< STM32 Low and Medium density devices: Write protection of page 4 to 7 */
00111 #define FLASH_WRProt_Pages8to11        ((uint32_t)0x00000004) /*!< STM32 Low and Medium density devices: Write protection of page 8 to 11 */
00112 #define FLASH_WRProt_Pages12to15       ((uint32_t)0x00000008) /*!< STM32 Low and Medium density devices: Write protection of page 12 to 15 */
00113 #define FLASH_WRProt_Pages16to19       ((uint32_t)0x00000010) /*!< STM32 Low and Medium density devices: Write protection of page 16 to 19 */
00114 #define FLASH_WRProt_Pages20to23       ((uint32_t)0x00000020) /*!< STM32 Low and Medium density devices: Write protection of page 20 to 23 */
00115 #define FLASH_WRProt_Pages24to27       ((uint32_t)0x00000040) /*!< STM32 Low and Medium density devices: Write protection of page 24 to 27 */
00116 #define FLASH_WRProt_Pages28to31       ((uint32_t)0x00000080) /*!< STM32 Low and Medium density devices: Write protection of page 28 to 31 */
00117 
00118 /* Values to be used with STM32 Medium-density devices */
00119 #define FLASH_WRProt_Pages32to35       ((uint32_t)0x00000100) /*!< STM32 Medium-density devices: Write protection of page 32 to 35 */
00120 #define FLASH_WRProt_Pages36to39       ((uint32_t)0x00000200) /*!< STM32 Medium-density devices: Write protection of page 36 to 39 */
00121 #define FLASH_WRProt_Pages40to43       ((uint32_t)0x00000400) /*!< STM32 Medium-density devices: Write protection of page 40 to 43 */
00122 #define FLASH_WRProt_Pages44to47       ((uint32_t)0x00000800) /*!< STM32 Medium-density devices: Write protection of page 44 to 47 */
00123 #define FLASH_WRProt_Pages48to51       ((uint32_t)0x00001000) /*!< STM32 Medium-density devices: Write protection of page 48 to 51 */
00124 #define FLASH_WRProt_Pages52to55       ((uint32_t)0x00002000) /*!< STM32 Medium-density devices: Write protection of page 52 to 55 */
00125 #define FLASH_WRProt_Pages56to59       ((uint32_t)0x00004000) /*!< STM32 Medium-density devices: Write protection of page 56 to 59 */
00126 #define FLASH_WRProt_Pages60to63       ((uint32_t)0x00008000) /*!< STM32 Medium-density devices: Write protection of page 60 to 63 */
00127 #define FLASH_WRProt_Pages64to67       ((uint32_t)0x00010000) /*!< STM32 Medium-density devices: Write protection of page 64 to 67 */
00128 #define FLASH_WRProt_Pages68to71       ((uint32_t)0x00020000) /*!< STM32 Medium-density devices: Write protection of page 68 to 71 */
00129 #define FLASH_WRProt_Pages72to75       ((uint32_t)0x00040000) /*!< STM32 Medium-density devices: Write protection of page 72 to 75 */
00130 #define FLASH_WRProt_Pages76to79       ((uint32_t)0x00080000) /*!< STM32 Medium-density devices: Write protection of page 76 to 79 */
00131 #define FLASH_WRProt_Pages80to83       ((uint32_t)0x00100000) /*!< STM32 Medium-density devices: Write protection of page 80 to 83 */
00132 #define FLASH_WRProt_Pages84to87       ((uint32_t)0x00200000) /*!< STM32 Medium-density devices: Write protection of page 84 to 87 */
00133 #define FLASH_WRProt_Pages88to91       ((uint32_t)0x00400000) /*!< STM32 Medium-density devices: Write protection of page 88 to 91 */
00134 #define FLASH_WRProt_Pages92to95       ((uint32_t)0x00800000) /*!< STM32 Medium-density devices: Write protection of page 92 to 95 */
00135 #define FLASH_WRProt_Pages96to99       ((uint32_t)0x01000000) /*!< STM32 Medium-density devices: Write protection of page 96 to 99 */
00136 #define FLASH_WRProt_Pages100to103     ((uint32_t)0x02000000) /*!< STM32 Medium-density devices: Write protection of page 100 to 103 */
00137 #define FLASH_WRProt_Pages104to107     ((uint32_t)0x04000000) /*!< STM32 Medium-density devices: Write protection of page 104 to 107 */
00138 #define FLASH_WRProt_Pages108to111     ((uint32_t)0x08000000) /*!< STM32 Medium-density devices: Write protection of page 108 to 111 */
00139 #define FLASH_WRProt_Pages112to115     ((uint32_t)0x10000000) /*!< STM32 Medium-density devices: Write protection of page 112 to 115 */
00140 #define FLASH_WRProt_Pages116to119     ((uint32_t)0x20000000) /*!< STM32 Medium-density devices: Write protection of page 115 to 119 */
00141 #define FLASH_WRProt_Pages120to123     ((uint32_t)0x40000000) /*!< STM32 Medium-density devices: Write protection of page 120 to 123 */
00142 #define FLASH_WRProt_Pages124to127     ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 124 to 127 */
00143 
00144 /* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */
00145 #define FLASH_WRProt_Pages0to1         ((uint32_t)0x00000001) /*!< STM32 High-density, XL-density and Connectivity line devices:
00146                                                                    Write protection of page 0 to 1 */
00147 #define FLASH_WRProt_Pages2to3         ((uint32_t)0x00000002) /*!< STM32 High-density, XL-density and Connectivity line devices:
00148                                                                    Write protection of page 2 to 3 */
00149 #define FLASH_WRProt_Pages4to5         ((uint32_t)0x00000004) /*!< STM32 High-density, XL-density and Connectivity line devices:
00150                                                                    Write protection of page 4 to 5 */
00151 #define FLASH_WRProt_Pages6to7         ((uint32_t)0x00000008) /*!< STM32 High-density, XL-density and Connectivity line devices:
00152                                                                    Write protection of page 6 to 7 */
00153 #define FLASH_WRProt_Pages8to9         ((uint32_t)0x00000010) /*!< STM32 High-density, XL-density and Connectivity line devices:
00154                                                                    Write protection of page 8 to 9 */
00155 #define FLASH_WRProt_Pages10to11       ((uint32_t)0x00000020) /*!< STM32 High-density, XL-density and Connectivity line devices:
00156                                                                    Write protection of page 10 to 11 */
00157 #define FLASH_WRProt_Pages12to13       ((uint32_t)0x00000040) /*!< STM32 High-density, XL-density and Connectivity line devices:
00158                                                                    Write protection of page 12 to 13 */
00159 #define FLASH_WRProt_Pages14to15       ((uint32_t)0x00000080) /*!< STM32 High-density, XL-density and Connectivity line devices:
00160                                                                    Write protection of page 14 to 15 */
00161 #define FLASH_WRProt_Pages16to17       ((uint32_t)0x00000100) /*!< STM32 High-density, XL-density and Connectivity line devices:
00162                                                                    Write protection of page 16 to 17 */
00163 #define FLASH_WRProt_Pages18to19       ((uint32_t)0x00000200) /*!< STM32 High-density, XL-density and Connectivity line devices:
00164                                                                    Write protection of page 18 to 19 */
00165 #define FLASH_WRProt_Pages20to21       ((uint32_t)0x00000400) /*!< STM32 High-density, XL-density and Connectivity line devices:
00166                                                                    Write protection of page 20 to 21 */
00167 #define FLASH_WRProt_Pages22to23       ((uint32_t)0x00000800) /*!< STM32 High-density, XL-density and Connectivity line devices:
00168                                                                    Write protection of page 22 to 23 */
00169 #define FLASH_WRProt_Pages24to25       ((uint32_t)0x00001000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00170                                                                    Write protection of page 24 to 25 */
00171 #define FLASH_WRProt_Pages26to27       ((uint32_t)0x00002000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00172                                                                    Write protection of page 26 to 27 */
00173 #define FLASH_WRProt_Pages28to29       ((uint32_t)0x00004000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00174                                                                    Write protection of page 28 to 29 */
00175 #define FLASH_WRProt_Pages30to31       ((uint32_t)0x00008000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00176                                                                    Write protection of page 30 to 31 */
00177 #define FLASH_WRProt_Pages32to33       ((uint32_t)0x00010000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00178                                                                    Write protection of page 32 to 33 */
00179 #define FLASH_WRProt_Pages34to35       ((uint32_t)0x00020000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00180                                                                    Write protection of page 34 to 35 */
00181 #define FLASH_WRProt_Pages36to37       ((uint32_t)0x00040000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00182                                                                    Write protection of page 36 to 37 */
00183 #define FLASH_WRProt_Pages38to39       ((uint32_t)0x00080000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00184                                                                    Write protection of page 38 to 39 */
00185 #define FLASH_WRProt_Pages40to41       ((uint32_t)0x00100000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00186                                                                    Write protection of page 40 to 41 */
00187 #define FLASH_WRProt_Pages42to43       ((uint32_t)0x00200000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00188                                                                    Write protection of page 42 to 43 */
00189 #define FLASH_WRProt_Pages44to45       ((uint32_t)0x00400000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00190                                                                    Write protection of page 44 to 45 */
00191 #define FLASH_WRProt_Pages46to47       ((uint32_t)0x00800000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00192                                                                    Write protection of page 46 to 47 */
00193 #define FLASH_WRProt_Pages48to49       ((uint32_t)0x01000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00194                                                                    Write protection of page 48 to 49 */
00195 #define FLASH_WRProt_Pages50to51       ((uint32_t)0x02000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00196                                                                    Write protection of page 50 to 51 */
00197 #define FLASH_WRProt_Pages52to53       ((uint32_t)0x04000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00198                                                                    Write protection of page 52 to 53 */
00199 #define FLASH_WRProt_Pages54to55       ((uint32_t)0x08000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00200                                                                    Write protection of page 54 to 55 */
00201 #define FLASH_WRProt_Pages56to57       ((uint32_t)0x10000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00202                                                                    Write protection of page 56 to 57 */
00203 #define FLASH_WRProt_Pages58to59       ((uint32_t)0x20000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00204                                                                    Write protection of page 58 to 59 */
00205 #define FLASH_WRProt_Pages60to61       ((uint32_t)0x40000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
00206                                                                    Write protection of page 60 to 61 */
00207 #define FLASH_WRProt_Pages62to127      ((uint32_t)0x80000000) /*!< STM32 Connectivity line devices: Write protection of page 62 to 127 */
00208 #define FLASH_WRProt_Pages62to255      ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 62 to 255 */
00209 #define FLASH_WRProt_Pages62to511      ((uint32_t)0x80000000) /*!< STM32 XL-density devices: Write protection of page 62 to 511 */
00210 
00211 #define FLASH_WRProt_AllPages          ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Pages */
00212 
00213 #define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))
00214 
00215 #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF))
00216 
00217 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
00218 
00219 /**
00220   * @}
00221   */
00222 
00223 /** @defgroup Option_Bytes_IWatchdog 
00224   * @{
00225   */
00226 
00227 #define OB_IWDG_SW                     ((uint16_t)0x0001)  /*!< Software IWDG selected */
00228 #define OB_IWDG_HW                     ((uint16_t)0x0000)  /*!< Hardware IWDG selected */
00229 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
00230 
00231 /**
00232   * @}
00233   */
00234 
00235 /** @defgroup Option_Bytes_nRST_STOP 
00236   * @{
00237   */
00238 
00239 #define OB_STOP_NoRST                  ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */
00240 #define OB_STOP_RST                    ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */
00241 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
00242 
00243 /**
00244   * @}
00245   */
00246 
00247 /** @defgroup Option_Bytes_nRST_STDBY 
00248   * @{
00249   */
00250 
00251 #define OB_STDBY_NoRST                 ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */
00252 #define OB_STDBY_RST                   ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */
00253 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
00254 
00255 #ifdef STM32F10X_XL
00256 /**
00257   * @}
00258   */
00259 /** @defgroup FLASH_Boot
00260   * @{
00261   */
00262 #define FLASH_BOOT_Bank1  ((uint16_t)0x0000) /*!< At startup, if boot pins are set in boot from user Flash position
00263                                                   and this parameter is selected the device will boot from Bank1(Default) */
00264 #define FLASH_BOOT_Bank2  ((uint16_t)0x0001) /*!< At startup, if boot pins are set in boot from user Flash position
00265                                                   and this parameter is selected the device will boot from Bank 2 or Bank 1,
00266                                                   depending on the activation of the bank */
00267 #define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2))
00268 #endif
00269 /**
00270   * @}
00271   */
00272 /** @defgroup FLASH_Interrupts 
00273   * @{
00274   */
00275 #ifdef STM32F10X_XL
00276 #define FLASH_IT_BANK2_ERROR                 ((uint32_t)0x80000400)  /*!< FPEC BANK2 error interrupt source */
00277 #define FLASH_IT_BANK2_EOP                   ((uint32_t)0x80001000)  /*!< End of FLASH BANK2 Operation Interrupt source */
00278 
00279 #define FLASH_IT_BANK1_ERROR                 FLASH_IT_ERROR          /*!< FPEC BANK1 error interrupt source */
00280 #define FLASH_IT_BANK1_EOP                   FLASH_IT_EOP            /*!< End of FLASH BANK1 Operation Interrupt source */
00281 
00282 #define FLASH_IT_ERROR                 ((uint32_t)0x00000400)  /*!< FPEC BANK1 error interrupt source */
00283 #define FLASH_IT_EOP                   ((uint32_t)0x00001000)  /*!< End of FLASH BANK1 Operation Interrupt source */
00284 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
00285 #else
00286 #define FLASH_IT_ERROR                 ((uint32_t)0x00000400)  /*!< FPEC error interrupt source */
00287 #define FLASH_IT_EOP                   ((uint32_t)0x00001000)  /*!< End of FLASH Operation Interrupt source */
00288 #define FLASH_IT_BANK1_ERROR           FLASH_IT_ERROR          /*!< FPEC BANK1 error interrupt source */
00289 #define FLASH_IT_BANK1_EOP             FLASH_IT_EOP            /*!< End of FLASH BANK1 Operation Interrupt source */
00290 
00291 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
00292 #endif
00293 
00294 /**
00295   * @}
00296   */
00297 
00298 /** @defgroup FLASH_Flags 
00299   * @{
00300   */
00301 #ifdef STM32F10X_XL
00302 #define FLASH_FLAG_BANK2_BSY                 ((uint32_t)0x80000001)  /*!< FLASH BANK2 Busy flag */
00303 #define FLASH_FLAG_BANK2_EOP                 ((uint32_t)0x80000020)  /*!< FLASH BANK2 End of Operation flag */
00304 #define FLASH_FLAG_BANK2_PGERR               ((uint32_t)0x80000004)  /*!< FLASH BANK2 Program error flag */
00305 #define FLASH_FLAG_BANK2_WRPRTERR            ((uint32_t)0x80000010)  /*!< FLASH BANK2 Write protected error flag */
00306 
00307 #define FLASH_FLAG_BANK1_BSY                 FLASH_FLAG_BSY       /*!< FLASH BANK1 Busy flag*/
00308 #define FLASH_FLAG_BANK1_EOP                 FLASH_FLAG_EOP       /*!< FLASH BANK1 End of Operation flag */
00309 #define FLASH_FLAG_BANK1_PGERR               FLASH_FLAG_PGERR     /*!< FLASH BANK1 Program error flag */
00310 #define FLASH_FLAG_BANK1_WRPRTERR            FLASH_FLAG_WRPRTERR  /*!< FLASH BANK1 Write protected error flag */
00311 
00312 #define FLASH_FLAG_BSY                 ((uint32_t)0x00000001)  /*!< FLASH Busy flag */
00313 #define FLASH_FLAG_EOP                 ((uint32_t)0x00000020)  /*!< FLASH End of Operation flag */
00314 #define FLASH_FLAG_PGERR               ((uint32_t)0x00000004)  /*!< FLASH Program error flag */
00315 #define FLASH_FLAG_WRPRTERR            ((uint32_t)0x00000010)  /*!< FLASH Write protected error flag */
00316 #define FLASH_FLAG_OPTERR              ((uint32_t)0x00000001)  /*!< FLASH Option Byte error flag */
00317  
00318 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
00319 #define IS_FLASH_GET_FLAG(FLAG)  (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
00320                                   ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
00321                                   ((FLAG) == FLASH_FLAG_OPTERR)|| \
00322                                   ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
00323                                   ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
00324                                   ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \
00325                                   ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR))
00326 #else
00327 #define FLASH_FLAG_BSY                 ((uint32_t)0x00000001)  /*!< FLASH Busy flag */
00328 #define FLASH_FLAG_EOP                 ((uint32_t)0x00000020)  /*!< FLASH End of Operation flag */
00329 #define FLASH_FLAG_PGERR               ((uint32_t)0x00000004)  /*!< FLASH Program error flag */
00330 #define FLASH_FLAG_WRPRTERR            ((uint32_t)0x00000010)  /*!< FLASH Write protected error flag */
00331 #define FLASH_FLAG_OPTERR              ((uint32_t)0x00000001)  /*!< FLASH Option Byte error flag */
00332 
00333 #define FLASH_FLAG_BANK1_BSY                 FLASH_FLAG_BSY       /*!< FLASH BANK1 Busy flag*/
00334 #define FLASH_FLAG_BANK1_EOP                 FLASH_FLAG_EOP       /*!< FLASH BANK1 End of Operation flag */
00335 #define FLASH_FLAG_BANK1_PGERR               FLASH_FLAG_PGERR     /*!< FLASH BANK1 Program error flag */
00336 #define FLASH_FLAG_BANK1_WRPRTERR            FLASH_FLAG_WRPRTERR  /*!< FLASH BANK1 Write protected error flag */
00337  
00338 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
00339 #define IS_FLASH_GET_FLAG(FLAG)  (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
00340                                   ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
00341                                                                   ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
00342                                   ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
00343                                   ((FLAG) == FLASH_FLAG_OPTERR))
00344 #endif
00345 
00346 /**
00347   * @}
00348   */
00349 
00350 /**
00351   * @}
00352   */
00353 
00354 /** @defgroup FLASH_Exported_Macros
00355   * @{
00356   */
00357 
00358 /**
00359   * @}
00360   */
00361 
00362 /** @defgroup FLASH_Exported_Functions
00363   * @{
00364   */
00365 
00366 /*------------ Functions used for all STM32F10x devices -----*/
00367 void FLASH_SetLatency(uint32_t FLASH_Latency);
00368 void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess);
00369 void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer);
00370 void FLASH_Unlock(void);
00371 void FLASH_Lock(void);
00372 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
00373 FLASH_Status FLASH_EraseAllPages(void);
00374 FLASH_Status FLASH_EraseOptionBytes(void);
00375 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
00376 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
00377 FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);
00378 FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages);
00379 FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
00380 FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY);
00381 uint32_t FLASH_GetUserOptionByte(void);
00382 uint32_t FLASH_GetWriteProtectionOptionByte(void);
00383 FlagStatus FLASH_GetReadOutProtectionStatus(void);
00384 FlagStatus FLASH_GetPrefetchBufferStatus(void);
00385 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
00386 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
00387 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
00388 FLASH_Status FLASH_GetStatus(void);
00389 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
00390 
00391 /*------------ New function used for all STM32F10x devices -----*/
00392 void FLASH_UnlockBank1(void);
00393 void FLASH_LockBank1(void);
00394 FLASH_Status FLASH_EraseAllBank1Pages(void);
00395 FLASH_Status FLASH_GetBank1Status(void);
00396 FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout);
00397 
00398 #ifdef STM32F10X_XL
00399 /*---- New Functions used only with STM32F10x_XL density devices -----*/
00400 void FLASH_UnlockBank2(void);
00401 void FLASH_LockBank2(void);
00402 FLASH_Status FLASH_EraseAllBank2Pages(void);
00403 FLASH_Status FLASH_GetBank2Status(void);
00404 FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout);
00405 FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT);
00406 #endif
00407 
00408 #ifdef __cplusplus
00409 }
00410 #endif
00411 
00412 #endif /* __STM32F10x_FLASH_H */
00413 /**
00414   * @}
00415   */
00416 
00417 /**
00418   * @}
00419   */
00420 
00421 /**
00422   * @}
00423   */
00424 
00425 /******************* (C) COPYRIGHT 2010 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