1

Dependencies:   mbed

Committer:
shaorui
Date:
Mon Jan 25 08:36:48 2021 +0000
Revision:
0:571a1835428e
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shaorui 0:571a1835428e 1 /**
shaorui 0:571a1835428e 2 ******************************************************************************
shaorui 0:571a1835428e 3 * @file stm32f4xx_flash.h
shaorui 0:571a1835428e 4 * @author MCD Application Team
shaorui 0:571a1835428e 5 * @version V1.7.1
shaorui 0:571a1835428e 6 * @date 20-May-2016
shaorui 0:571a1835428e 7 * @brief This file contains all the functions prototypes for the FLASH
shaorui 0:571a1835428e 8 * firmware library.
shaorui 0:571a1835428e 9 ******************************************************************************
shaorui 0:571a1835428e 10 * @attention
shaorui 0:571a1835428e 11 *
shaorui 0:571a1835428e 12 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
shaorui 0:571a1835428e 13 *
shaorui 0:571a1835428e 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
shaorui 0:571a1835428e 15 * You may not use this file except in compliance with the License.
shaorui 0:571a1835428e 16 * You may obtain a copy of the License at:
shaorui 0:571a1835428e 17 *
shaorui 0:571a1835428e 18 * http://www.st.com/software_license_agreement_liberty_v2
shaorui 0:571a1835428e 19 *
shaorui 0:571a1835428e 20 * Unless required by applicable law or agreed to in writing, software
shaorui 0:571a1835428e 21 * distributed under the License is distributed on an "AS IS" BASIS,
shaorui 0:571a1835428e 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
shaorui 0:571a1835428e 23 * See the License for the specific language governing permissions and
shaorui 0:571a1835428e 24 * limitations under the License.
shaorui 0:571a1835428e 25 *
shaorui 0:571a1835428e 26 ******************************************************************************
shaorui 0:571a1835428e 27 */
shaorui 0:571a1835428e 28
shaorui 0:571a1835428e 29 /* Define to prevent recursive inclusion -------------------------------------*/
shaorui 0:571a1835428e 30 #ifndef __STM32F4xx_FLASH_H
shaorui 0:571a1835428e 31 #define __STM32F4xx_FLASH_H
shaorui 0:571a1835428e 32
shaorui 0:571a1835428e 33 #ifdef __cplusplus
shaorui 0:571a1835428e 34 extern "C" {
shaorui 0:571a1835428e 35 #endif
shaorui 0:571a1835428e 36
shaorui 0:571a1835428e 37 /* Includes ------------------------------------------------------------------*/
shaorui 0:571a1835428e 38 #include "stm32f4xx.h"
shaorui 0:571a1835428e 39
shaorui 0:571a1835428e 40 /** @addtogroup STM32F4xx_StdPeriph_Driver
shaorui 0:571a1835428e 41 * @{
shaorui 0:571a1835428e 42 */
shaorui 0:571a1835428e 43
shaorui 0:571a1835428e 44 /** @addtogroup FLASH
shaorui 0:571a1835428e 45 * @{
shaorui 0:571a1835428e 46 */
shaorui 0:571a1835428e 47
shaorui 0:571a1835428e 48 /* Exported types ------------------------------------------------------------*/
shaorui 0:571a1835428e 49 /**
shaorui 0:571a1835428e 50 * @brief FLASH Status
shaorui 0:571a1835428e 51 */
shaorui 0:571a1835428e 52 typedef enum
shaorui 0:571a1835428e 53 {
shaorui 0:571a1835428e 54 FLASH_BUSY2 = 1,
shaorui 0:571a1835428e 55 FLASH_ERROR_RD2,
shaorui 0:571a1835428e 56 FLASH_ERROR_PGS2,
shaorui 0:571a1835428e 57 FLASH_ERROR_PGP2,
shaorui 0:571a1835428e 58 FLASH_ERROR_PGA2,
shaorui 0:571a1835428e 59 FLASH_ERROR_WRP2,
shaorui 0:571a1835428e 60 FLASH_ERROR_PROGRAM2,
shaorui 0:571a1835428e 61 FLASH_ERROR_OPERATION2,
shaorui 0:571a1835428e 62 FLASH_COMPLETE2
shaorui 0:571a1835428e 63 }FLASH_Status;
shaorui 0:571a1835428e 64
shaorui 0:571a1835428e 65 /* Exported constants --------------------------------------------------------*/
shaorui 0:571a1835428e 66
shaorui 0:571a1835428e 67 /** @defgroup FLASH_Exported_Constants
shaorui 0:571a1835428e 68 * @{
shaorui 0:571a1835428e 69 */
shaorui 0:571a1835428e 70
shaorui 0:571a1835428e 71 /** @defgroup Flash_Latency
shaorui 0:571a1835428e 72 * @{
shaorui 0:571a1835428e 73 */
shaorui 0:571a1835428e 74 #define FLASH_Latency_0 ((uint8_t)0x0000) /*!< FLASH Zero Latency cycle */
shaorui 0:571a1835428e 75 #define FLASH_Latency_1 ((uint8_t)0x0001) /*!< FLASH One Latency cycle */
shaorui 0:571a1835428e 76 #define FLASH_Latency_2 ((uint8_t)0x0002) /*!< FLASH Two Latency cycles */
shaorui 0:571a1835428e 77 #define FLASH_Latency_3 ((uint8_t)0x0003) /*!< FLASH Three Latency cycles */
shaorui 0:571a1835428e 78 #define FLASH_Latency_4 ((uint8_t)0x0004) /*!< FLASH Four Latency cycles */
shaorui 0:571a1835428e 79 #define FLASH_Latency_5 ((uint8_t)0x0005) /*!< FLASH Five Latency cycles */
shaorui 0:571a1835428e 80 #define FLASH_Latency_6 ((uint8_t)0x0006) /*!< FLASH Six Latency cycles */
shaorui 0:571a1835428e 81 #define FLASH_Latency_7 ((uint8_t)0x0007) /*!< FLASH Seven Latency cycles */
shaorui 0:571a1835428e 82 #define FLASH_Latency_8 ((uint8_t)0x0008) /*!< FLASH Eight Latency cycles */
shaorui 0:571a1835428e 83 #define FLASH_Latency_9 ((uint8_t)0x0009) /*!< FLASH Nine Latency cycles */
shaorui 0:571a1835428e 84 #define FLASH_Latency_10 ((uint8_t)0x000A) /*!< FLASH Ten Latency cycles */
shaorui 0:571a1835428e 85 #define FLASH_Latency_11 ((uint8_t)0x000B) /*!< FLASH Eleven Latency cycles */
shaorui 0:571a1835428e 86 #define FLASH_Latency_12 ((uint8_t)0x000C) /*!< FLASH Twelve Latency cycles */
shaorui 0:571a1835428e 87 #define FLASH_Latency_13 ((uint8_t)0x000D) /*!< FLASH Thirteen Latency cycles */
shaorui 0:571a1835428e 88 #define FLASH_Latency_14 ((uint8_t)0x000E) /*!< FLASH Fourteen Latency cycles */
shaorui 0:571a1835428e 89 #define FLASH_Latency_15 ((uint8_t)0x000F) /*!< FLASH Fifteen Latency cycles */
shaorui 0:571a1835428e 90
shaorui 0:571a1835428e 91 /**
shaorui 0:571a1835428e 92 * @}
shaorui 0:571a1835428e 93 */
shaorui 0:571a1835428e 94
shaorui 0:571a1835428e 95 /** @defgroup FLASH_Voltage_Range
shaorui 0:571a1835428e 96 * @{
shaorui 0:571a1835428e 97 */
shaorui 0:571a1835428e 98 #define VoltageRange_1 ((uint8_t)0x00) /*!< Device operating range: 1.8V to 2.1V */
shaorui 0:571a1835428e 99 #define VoltageRange_2 ((uint8_t)0x01) /*!<Device operating range: 2.1V to 2.7V */
shaorui 0:571a1835428e 100 #define VoltageRange_3 ((uint8_t)0x02) /*!<Device operating range: 2.7V to 3.6V */
shaorui 0:571a1835428e 101 #define VoltageRange_4 ((uint8_t)0x03) /*!<Device operating range: 2.7V to 3.6V + External Vpp */
shaorui 0:571a1835428e 102
shaorui 0:571a1835428e 103 /*
shaorui 0:571a1835428e 104 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == VoltageRange_1) || \
shaorui 0:571a1835428e 105 ((RANGE) == VoltageRange_2) || \
shaorui 0:571a1835428e 106 ((RANGE) == VoltageRange_3) || \
shaorui 0:571a1835428e 107 ((RANGE) == VoltageRange_4))
shaorui 0:571a1835428e 108 */
shaorui 0:571a1835428e 109
shaorui 0:571a1835428e 110 /**
shaorui 0:571a1835428e 111 * @}
shaorui 0:571a1835428e 112 */
shaorui 0:571a1835428e 113
shaorui 0:571a1835428e 114 /** @defgroup FLASH_Sectors
shaorui 0:571a1835428e 115 * @{
shaorui 0:571a1835428e 116 */
shaorui 0:571a1835428e 117 #define FLASH_Sector_0 ((uint16_t)0x0000) /*!< Sector Number 0 */
shaorui 0:571a1835428e 118 #define FLASH_Sector_1 ((uint16_t)0x0008) /*!< Sector Number 1 */
shaorui 0:571a1835428e 119 #define FLASH_Sector_2 ((uint16_t)0x0010) /*!< Sector Number 2 */
shaorui 0:571a1835428e 120 #define FLASH_Sector_3 ((uint16_t)0x0018) /*!< Sector Number 3 */
shaorui 0:571a1835428e 121 #define FLASH_Sector_4 ((uint16_t)0x0020) /*!< Sector Number 4 */
shaorui 0:571a1835428e 122 #define FLASH_Sector_5 ((uint16_t)0x0028) /*!< Sector Number 5 */
shaorui 0:571a1835428e 123 #define FLASH_Sector_6 ((uint16_t)0x0030) /*!< Sector Number 6 */
shaorui 0:571a1835428e 124 #define FLASH_Sector_7 ((uint16_t)0x0038) /*!< Sector Number 7 */
shaorui 0:571a1835428e 125 #define FLASH_Sector_8 ((uint16_t)0x0040) /*!< Sector Number 8 */
shaorui 0:571a1835428e 126 #define FLASH_Sector_9 ((uint16_t)0x0048) /*!< Sector Number 9 */
shaorui 0:571a1835428e 127 #define FLASH_Sector_10 ((uint16_t)0x0050) /*!< Sector Number 10 */
shaorui 0:571a1835428e 128 #define FLASH_Sector_11 ((uint16_t)0x0058) /*!< Sector Number 11 */
shaorui 0:571a1835428e 129 #define FLASH_Sector_12 ((uint16_t)0x0080) /*!< Sector Number 12 */
shaorui 0:571a1835428e 130 #define FLASH_Sector_13 ((uint16_t)0x0088) /*!< Sector Number 13 */
shaorui 0:571a1835428e 131 #define FLASH_Sector_14 ((uint16_t)0x0090) /*!< Sector Number 14 */
shaorui 0:571a1835428e 132 #define FLASH_Sector_15 ((uint16_t)0x0098) /*!< Sector Number 15 */
shaorui 0:571a1835428e 133 #define FLASH_Sector_16 ((uint16_t)0x00A0) /*!< Sector Number 16 */
shaorui 0:571a1835428e 134 #define FLASH_Sector_17 ((uint16_t)0x00A8) /*!< Sector Number 17 */
shaorui 0:571a1835428e 135 #define FLASH_Sector_18 ((uint16_t)0x00B0) /*!< Sector Number 18 */
shaorui 0:571a1835428e 136 #define FLASH_Sector_19 ((uint16_t)0x00B8) /*!< Sector Number 19 */
shaorui 0:571a1835428e 137 #define FLASH_Sector_20 ((uint16_t)0x00C0) /*!< Sector Number 20 */
shaorui 0:571a1835428e 138 #define FLASH_Sector_21 ((uint16_t)0x00C8) /*!< Sector Number 21 */
shaorui 0:571a1835428e 139 #define FLASH_Sector_22 ((uint16_t)0x00D0) /*!< Sector Number 22 */
shaorui 0:571a1835428e 140 #define FLASH_Sector_23 ((uint16_t)0x00D8) /*!< Sector Number 23 */
shaorui 0:571a1835428e 141
shaorui 0:571a1835428e 142 #if defined (STM32F427_437xx) || defined (STM32F429_439xx) || defined (STM32F469_479xx)
shaorui 0:571a1835428e 143 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x081FFFFF)) ||\
shaorui 0:571a1835428e 144 (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) <= 0x1FFF7A0F)))
shaorui 0:571a1835428e 145 #endif /* STM32F427_437xx || STM32F429_439xx || STM32F469_479xx */
shaorui 0:571a1835428e 146
shaorui 0:571a1835428e 147 #if defined (STM32F40_41xxx) || defined(STM32F412xG)
shaorui 0:571a1835428e 148 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x080FFFFF)) ||\
shaorui 0:571a1835428e 149 (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) <= 0x1FFF7A0F)))
shaorui 0:571a1835428e 150 #endif /* STM32F40_41xxx || STM32F412xG */
shaorui 0:571a1835428e 151
shaorui 0:571a1835428e 152 #if defined (STM32F401xx)
shaorui 0:571a1835428e 153 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0803FFFF)) ||\
shaorui 0:571a1835428e 154 (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) <= 0x1FFF7A0F)))
shaorui 0:571a1835428e 155 #endif /* STM32F401xx */
shaorui 0:571a1835428e 156
shaorui 0:571a1835428e 157 #if defined (STM32F411xE) || defined (STM32F446xx)
shaorui 0:571a1835428e 158 //#define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0807FFFF)) ||\
shaorui 0:571a1835428e 159 // (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) <= 0x1FFF7A0F)))
shaorui 0:571a1835428e 160 #endif /* STM32F411xE || STM32F446xx */
shaorui 0:571a1835428e 161
shaorui 0:571a1835428e 162 #if defined (STM32F410xx)
shaorui 0:571a1835428e 163 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0801FFFF)) ||\
shaorui 0:571a1835428e 164 (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) <= 0x1FFF7A0F)))
shaorui 0:571a1835428e 165 #endif /* STM32F410xx */
shaorui 0:571a1835428e 166
shaorui 0:571a1835428e 167 /**
shaorui 0:571a1835428e 168 * @}
shaorui 0:571a1835428e 169 */
shaorui 0:571a1835428e 170
shaorui 0:571a1835428e 171 /** @defgroup Option_Bytes_Write_Protection
shaorui 0:571a1835428e 172 * @{
shaorui 0:571a1835428e 173 */
shaorui 0:571a1835428e 174 #define OB_WRP_Sector_0 ((uint32_t)0x00000001) /*!< Write protection of Sector0 */
shaorui 0:571a1835428e 175 #define OB_WRP_Sector_1 ((uint32_t)0x00000002) /*!< Write protection of Sector1 */
shaorui 0:571a1835428e 176 #define OB_WRP_Sector_2 ((uint32_t)0x00000004) /*!< Write protection of Sector2 */
shaorui 0:571a1835428e 177 #define OB_WRP_Sector_3 ((uint32_t)0x00000008) /*!< Write protection of Sector3 */
shaorui 0:571a1835428e 178 #define OB_WRP_Sector_4 ((uint32_t)0x00000010) /*!< Write protection of Sector4 */
shaorui 0:571a1835428e 179 #define OB_WRP_Sector_5 ((uint32_t)0x00000020) /*!< Write protection of Sector5 */
shaorui 0:571a1835428e 180 #define OB_WRP_Sector_6 ((uint32_t)0x00000040) /*!< Write protection of Sector6 */
shaorui 0:571a1835428e 181 #define OB_WRP_Sector_7 ((uint32_t)0x00000080) /*!< Write protection of Sector7 */
shaorui 0:571a1835428e 182 #define OB_WRP_Sector_8 ((uint32_t)0x00000100) /*!< Write protection of Sector8 */
shaorui 0:571a1835428e 183 #define OB_WRP_Sector_9 ((uint32_t)0x00000200) /*!< Write protection of Sector9 */
shaorui 0:571a1835428e 184 #define OB_WRP_Sector_10 ((uint32_t)0x00000400) /*!< Write protection of Sector10 */
shaorui 0:571a1835428e 185 #define OB_WRP_Sector_11 ((uint32_t)0x00000800) /*!< Write protection of Sector11 */
shaorui 0:571a1835428e 186 #define OB_WRP_Sector_12 ((uint32_t)0x00000001) /*!< Write protection of Sector12 */
shaorui 0:571a1835428e 187 #define OB_WRP_Sector_13 ((uint32_t)0x00000002) /*!< Write protection of Sector13 */
shaorui 0:571a1835428e 188 #define OB_WRP_Sector_14 ((uint32_t)0x00000004) /*!< Write protection of Sector14 */
shaorui 0:571a1835428e 189 #define OB_WRP_Sector_15 ((uint32_t)0x00000008) /*!< Write protection of Sector15 */
shaorui 0:571a1835428e 190 #define OB_WRP_Sector_16 ((uint32_t)0x00000010) /*!< Write protection of Sector16 */
shaorui 0:571a1835428e 191 #define OB_WRP_Sector_17 ((uint32_t)0x00000020) /*!< Write protection of Sector17 */
shaorui 0:571a1835428e 192 #define OB_WRP_Sector_18 ((uint32_t)0x00000040) /*!< Write protection of Sector18 */
shaorui 0:571a1835428e 193 #define OB_WRP_Sector_19 ((uint32_t)0x00000080) /*!< Write protection of Sector19 */
shaorui 0:571a1835428e 194 #define OB_WRP_Sector_20 ((uint32_t)0x00000100) /*!< Write protection of Sector20 */
shaorui 0:571a1835428e 195 #define OB_WRP_Sector_21 ((uint32_t)0x00000200) /*!< Write protection of Sector21 */
shaorui 0:571a1835428e 196 #define OB_WRP_Sector_22 ((uint32_t)0x00000400) /*!< Write protection of Sector22 */
shaorui 0:571a1835428e 197 #define OB_WRP_Sector_23 ((uint32_t)0x00000800) /*!< Write protection of Sector23 */
shaorui 0:571a1835428e 198 #define OB_WRP_Sector_All ((uint32_t)0x00000FFF) /*!< Write protection of all Sectors */
shaorui 0:571a1835428e 199
shaorui 0:571a1835428e 200 #define IS_OB_WRP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
shaorui 0:571a1835428e 201 /**
shaorui 0:571a1835428e 202 * @}
shaorui 0:571a1835428e 203 */
shaorui 0:571a1835428e 204
shaorui 0:571a1835428e 205 /** @defgroup Selection_Protection_Mode
shaorui 0:571a1835428e 206 * @{
shaorui 0:571a1835428e 207 */
shaorui 0:571a1835428e 208 #define OB_PcROP_Disable ((uint8_t)0x00) /*!< Disabled PcROP, nWPRi bits used for Write Protection on sector i */
shaorui 0:571a1835428e 209 #define OB_PcROP_Enable ((uint8_t)0x80) /*!< Enable PcROP, nWPRi bits used for PCRoP Protection on sector i */
shaorui 0:571a1835428e 210
shaorui 0:571a1835428e 211 /**
shaorui 0:571a1835428e 212 * @}
shaorui 0:571a1835428e 213 */
shaorui 0:571a1835428e 214
shaorui 0:571a1835428e 215 /** @defgroup Option_Bytes_PC_ReadWrite_Protection
shaorui 0:571a1835428e 216 * @{
shaorui 0:571a1835428e 217 */
shaorui 0:571a1835428e 218 #define OB_PCROP_Sector_0 ((uint32_t)0x00000001) /*!< PC Read/Write protection of Sector0 */
shaorui 0:571a1835428e 219 #define OB_PCROP_Sector_1 ((uint32_t)0x00000002) /*!< PC Read/Write protection of Sector1 */
shaorui 0:571a1835428e 220 #define OB_PCROP_Sector_2 ((uint32_t)0x00000004) /*!< PC Read/Write protection of Sector2 */
shaorui 0:571a1835428e 221 #define OB_PCROP_Sector_3 ((uint32_t)0x00000008) /*!< PC Read/Write protection of Sector3 */
shaorui 0:571a1835428e 222 #define OB_PCROP_Sector_4 ((uint32_t)0x00000010) /*!< PC Read/Write protection of Sector4 */
shaorui 0:571a1835428e 223 #define OB_PCROP_Sector_5 ((uint32_t)0x00000020) /*!< PC Read/Write protection of Sector5 */
shaorui 0:571a1835428e 224 #define OB_PCROP_Sector_6 ((uint32_t)0x00000040) /*!< PC Read/Write protection of Sector6 */
shaorui 0:571a1835428e 225 #define OB_PCROP_Sector_7 ((uint32_t)0x00000080) /*!< PC Read/Write protection of Sector7 */
shaorui 0:571a1835428e 226 #define OB_PCROP_Sector_8 ((uint32_t)0x00000100) /*!< PC Read/Write protection of Sector8 */
shaorui 0:571a1835428e 227 #define OB_PCROP_Sector_9 ((uint32_t)0x00000200) /*!< PC Read/Write protection of Sector9 */
shaorui 0:571a1835428e 228 #define OB_PCROP_Sector_10 ((uint32_t)0x00000400) /*!< PC Read/Write protection of Sector10 */
shaorui 0:571a1835428e 229 #define OB_PCROP_Sector_11 ((uint32_t)0x00000800) /*!< PC Read/Write protection of Sector11 */
shaorui 0:571a1835428e 230 #define OB_PCROP_Sector_12 ((uint32_t)0x00000001) /*!< PC Read/Write protection of Sector12 */
shaorui 0:571a1835428e 231 #define OB_PCROP_Sector_13 ((uint32_t)0x00000002) /*!< PC Read/Write protection of Sector13 */
shaorui 0:571a1835428e 232 #define OB_PCROP_Sector_14 ((uint32_t)0x00000004) /*!< PC Read/Write protection of Sector14 */
shaorui 0:571a1835428e 233 #define OB_PCROP_Sector_15 ((uint32_t)0x00000008) /*!< PC Read/Write protection of Sector15 */
shaorui 0:571a1835428e 234 #define OB_PCROP_Sector_16 ((uint32_t)0x00000010) /*!< PC Read/Write protection of Sector16 */
shaorui 0:571a1835428e 235 #define OB_PCROP_Sector_17 ((uint32_t)0x00000020) /*!< PC Read/Write protection of Sector17 */
shaorui 0:571a1835428e 236 #define OB_PCROP_Sector_18 ((uint32_t)0x00000040) /*!< PC Read/Write protection of Sector18 */
shaorui 0:571a1835428e 237 #define OB_PCROP_Sector_19 ((uint32_t)0x00000080) /*!< PC Read/Write protection of Sector19 */
shaorui 0:571a1835428e 238 #define OB_PCROP_Sector_20 ((uint32_t)0x00000100) /*!< PC Read/Write protection of Sector20 */
shaorui 0:571a1835428e 239 #define OB_PCROP_Sector_21 ((uint32_t)0x00000200) /*!< PC Read/Write protection of Sector21 */
shaorui 0:571a1835428e 240 #define OB_PCROP_Sector_22 ((uint32_t)0x00000400) /*!< PC Read/Write protection of Sector22 */
shaorui 0:571a1835428e 241 #define OB_PCROP_Sector_23 ((uint32_t)0x00000800) /*!< PC Read/Write protection of Sector23 */
shaorui 0:571a1835428e 242 #define OB_PCROP_Sector_All ((uint32_t)0x00000FFF) /*!< PC Read/Write protection of all Sectors */
shaorui 0:571a1835428e 243
shaorui 0:571a1835428e 244 /**
shaorui 0:571a1835428e 245 * @}
shaorui 0:571a1835428e 246 */
shaorui 0:571a1835428e 247
shaorui 0:571a1835428e 248 /** @defgroup FLASH_Option_Bytes_Read_Protection
shaorui 0:571a1835428e 249 * @{
shaorui 0:571a1835428e 250 */
shaorui 0:571a1835428e 251 #define OB_RDP_Level_0 ((uint8_t)0xAA)
shaorui 0:571a1835428e 252 #define OB_RDP_Level_1 ((uint8_t)0x55)
shaorui 0:571a1835428e 253 /*#define OB_RDP_Level_2 ((uint8_t)0xCC)*/ /*!< Warning: When enabling read protection level 2
shaorui 0:571a1835428e 254 it's no more possible to go back to level 1 or 0 */
shaorui 0:571a1835428e 255 #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\
shaorui 0:571a1835428e 256 ((LEVEL) == OB_RDP_Level_1))/*||\
shaorui 0:571a1835428e 257 ((LEVEL) == OB_RDP_Level_2))*/
shaorui 0:571a1835428e 258 /**
shaorui 0:571a1835428e 259 * @}
shaorui 0:571a1835428e 260 */
shaorui 0:571a1835428e 261
shaorui 0:571a1835428e 262 /** @defgroup FLASH_Option_Bytes_IWatchdog
shaorui 0:571a1835428e 263 * @{
shaorui 0:571a1835428e 264 */
shaorui 0:571a1835428e 265
shaorui 0:571a1835428e 266 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
shaorui 0:571a1835428e 267 /**
shaorui 0:571a1835428e 268 * @}
shaorui 0:571a1835428e 269 */
shaorui 0:571a1835428e 270
shaorui 0:571a1835428e 271 /** @defgroup FLASH_Option_Bytes_nRST_STOP
shaorui 0:571a1835428e 272 * @{
shaorui 0:571a1835428e 273 */
shaorui 0:571a1835428e 274 #define OB_STOP_NoRST ((uint8_t)0x40) /*!< No reset generated when entering in STOP */
shaorui 0:571a1835428e 275
shaorui 0:571a1835428e 276 /**
shaorui 0:571a1835428e 277 * @}
shaorui 0:571a1835428e 278 */
shaorui 0:571a1835428e 279
shaorui 0:571a1835428e 280
shaorui 0:571a1835428e 281 /** @defgroup FLASH_Option_Bytes_nRST_STDBY
shaorui 0:571a1835428e 282 * @{
shaorui 0:571a1835428e 283 */
shaorui 0:571a1835428e 284 #define OB_STDBY_NoRST ((uint8_t)0x80) /*!< No reset generated when entering in STANDBY */
shaorui 0:571a1835428e 285 //#define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
shaorui 0:571a1835428e 286 //#define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
shaorui 0:571a1835428e 287 /**
shaorui 0:571a1835428e 288 * @}
shaorui 0:571a1835428e 289 */
shaorui 0:571a1835428e 290
shaorui 0:571a1835428e 291 /** @defgroup FLASH_BOR_Reset_Level
shaorui 0:571a1835428e 292 * @{
shaorui 0:571a1835428e 293 */
shaorui 0:571a1835428e 294
shaorui 0:571a1835428e 295 #define IS_OB_BOR(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
shaorui 0:571a1835428e 296 ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
shaorui 0:571a1835428e 297 /**
shaorui 0:571a1835428e 298 * @}
shaorui 0:571a1835428e 299 */
shaorui 0:571a1835428e 300
shaorui 0:571a1835428e 301 /** @defgroup FLASH_Dual_Boot
shaorui 0:571a1835428e 302 * @{
shaorui 0:571a1835428e 303 */
shaorui 0:571a1835428e 304 #define OB_Dual_BootEnabled ((uint8_t)0x10) /*!< Dual Bank Boot Enable */
shaorui 0:571a1835428e 305 #define OB_Dual_BootDisabled ((uint8_t)0x00) /*!< Dual Bank Boot Disable, always boot on User Flash */
shaorui 0:571a1835428e 306 #define IS_OB_BOOT(BOOT) (((BOOT) == OB_Dual_BootEnabled) || ((BOOT) == OB_Dual_BootDisabled))
shaorui 0:571a1835428e 307 /**
shaorui 0:571a1835428e 308 * @}
shaorui 0:571a1835428e 309 */
shaorui 0:571a1835428e 310
shaorui 0:571a1835428e 311 /** @defgroup FLASH_Interrupts
shaorui 0:571a1835428e 312 * @{
shaorui 0:571a1835428e 313 */
shaorui 0:571a1835428e 314
shaorui 0:571a1835428e 315 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFCFFFFFF) == 0x00000000) && ((IT) != 0x00000000))
shaorui 0:571a1835428e 316 /**
shaorui 0:571a1835428e 317 * @}
shaorui 0:571a1835428e 318 */
shaorui 0:571a1835428e 319
shaorui 0:571a1835428e 320 /** @defgroup FLASH_Flags
shaorui 0:571a1835428e 321 * @{
shaorui 0:571a1835428e 322 */
shaorui 0:571a1835428e 323
shaorui 0:571a1835428e 324 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFE0C) == 0x00000000) && ((FLAG) != 0x00000000))
shaorui 0:571a1835428e 325 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_EOP) || ((FLAG) == FLASH_FLAG_OPERR) || \
shaorui 0:571a1835428e 326 ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_PGAERR) || \
shaorui 0:571a1835428e 327 ((FLAG) == FLASH_FLAG_PGPERR) || ((FLAG) == FLASH_FLAG_PGSERR) || \
shaorui 0:571a1835428e 328 ((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_RDERR))
shaorui 0:571a1835428e 329
shaorui 0:571a1835428e 330 /**
shaorui 0:571a1835428e 331 * @brief ACR register byte 0 (Bits[7:0]) base address
shaorui 0:571a1835428e 332 */
shaorui 0:571a1835428e 333 //#define ACR_BYTE0_ADDRESS ((uint32_t)0x40023C00)
shaorui 0:571a1835428e 334 /**
shaorui 0:571a1835428e 335 * @brief OPTCR register byte 0 (Bits[7:0]) base address
shaorui 0:571a1835428e 336 */
shaorui 0:571a1835428e 337 //#define OPTCR_BYTE0_ADDRESS ((uint32_t)0x40023C14)
shaorui 0:571a1835428e 338 /**
shaorui 0:571a1835428e 339 * @brief OPTCR register byte 1 (Bits[15:8]) base address
shaorui 0:571a1835428e 340 */
shaorui 0:571a1835428e 341 //#define OPTCR_BYTE1_ADDRESS ((uint32_t)0x40023C15)
shaorui 0:571a1835428e 342 /**
shaorui 0:571a1835428e 343 * @brief OPTCR register byte 2 (Bits[23:16]) base address
shaorui 0:571a1835428e 344 */
shaorui 0:571a1835428e 345 //#define OPTCR_BYTE2_ADDRESS ((uint32_t)0x40023C16)
shaorui 0:571a1835428e 346 /**
shaorui 0:571a1835428e 347 * @brief OPTCR register byte 3 (Bits[31:24]) base address
shaorui 0:571a1835428e 348 */
shaorui 0:571a1835428e 349 //#define OPTCR_BYTE3_ADDRESS ((uint32_t)0x40023C17)
shaorui 0:571a1835428e 350
shaorui 0:571a1835428e 351 /**
shaorui 0:571a1835428e 352 * @brief OPTCR1 register byte 0 (Bits[7:0]) base address
shaorui 0:571a1835428e 353 */
shaorui 0:571a1835428e 354 #define OPTCR1_BYTE2_ADDRESS ((uint32_t)0x40023C1A)
shaorui 0:571a1835428e 355
shaorui 0:571a1835428e 356 /**
shaorui 0:571a1835428e 357 * @}
shaorui 0:571a1835428e 358 */
shaorui 0:571a1835428e 359
shaorui 0:571a1835428e 360 /* Exported macro ------------------------------------------------------------*/
shaorui 0:571a1835428e 361 /* Exported functions --------------------------------------------------------*/
shaorui 0:571a1835428e 362
shaorui 0:571a1835428e 363 /* FLASH Interface configuration functions ************************************/
shaorui 0:571a1835428e 364 void FLASH_SetLatency(uint32_t FLASH_Latency);
shaorui 0:571a1835428e 365 void FLASH_PrefetchBufferCmd(FunctionalState NewState);
shaorui 0:571a1835428e 366 void FLASH_InstructionCacheCmd(FunctionalState NewState);
shaorui 0:571a1835428e 367 void FLASH_DataCacheCmd(FunctionalState NewState);
shaorui 0:571a1835428e 368 void FLASH_InstructionCacheReset(void);
shaorui 0:571a1835428e 369 void FLASH_DataCacheReset(void);
shaorui 0:571a1835428e 370
shaorui 0:571a1835428e 371 /* FLASH Memory Programming functions *****************************************/
shaorui 0:571a1835428e 372 void FLASH_Unlock(void);
shaorui 0:571a1835428e 373 void FLASH_Lock(void);
shaorui 0:571a1835428e 374 FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange);
shaorui 0:571a1835428e 375 FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange);
shaorui 0:571a1835428e 376 FLASH_Status FLASH_EraseAllBank1Sectors(uint8_t VoltageRange);
shaorui 0:571a1835428e 377 FLASH_Status FLASH_EraseAllBank2Sectors(uint8_t VoltageRange);
shaorui 0:571a1835428e 378 FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data);
shaorui 0:571a1835428e 379 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
shaorui 0:571a1835428e 380 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
shaorui 0:571a1835428e 381 FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data);
shaorui 0:571a1835428e 382
shaorui 0:571a1835428e 383 /* Option Bytes Programming functions *****************************************/
shaorui 0:571a1835428e 384 void FLASH_OB_Unlock(void);
shaorui 0:571a1835428e 385 void FLASH_OB_Lock(void);
shaorui 0:571a1835428e 386 void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState);
shaorui 0:571a1835428e 387 void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState);
shaorui 0:571a1835428e 388 void FLASH_OB_PCROPSelectionConfig(uint8_t OB_PcROP);
shaorui 0:571a1835428e 389 void FLASH_OB_PCROPConfig(uint32_t OB_PCROP, FunctionalState NewState);
shaorui 0:571a1835428e 390 void FLASH_OB_PCROP1Config(uint32_t OB_PCROP, FunctionalState NewState);
shaorui 0:571a1835428e 391 void FLASH_OB_RDPConfig(uint8_t OB_RDP);
shaorui 0:571a1835428e 392 void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY);
shaorui 0:571a1835428e 393 void FLASH_OB_BORConfig(uint8_t OB_BOR);
shaorui 0:571a1835428e 394 void FLASH_OB_BootConfig(uint8_t OB_BOOT);
shaorui 0:571a1835428e 395 FLASH_Status FLASH_OB_Launch(void);
shaorui 0:571a1835428e 396 uint8_t FLASH_OB_GetUser(void);
shaorui 0:571a1835428e 397 uint16_t FLASH_OB_GetWRP(void);
shaorui 0:571a1835428e 398 uint16_t FLASH_OB_GetWRP1(void);
shaorui 0:571a1835428e 399 uint16_t FLASH_OB_GetPCROP(void);
shaorui 0:571a1835428e 400 uint16_t FLASH_OB_GetPCROP1(void);
shaorui 0:571a1835428e 401 FlagStatus FLASH_OB_GetRDP(void);
shaorui 0:571a1835428e 402 uint8_t FLASH_OB_GetBOR(void);
shaorui 0:571a1835428e 403
shaorui 0:571a1835428e 404 /* Interrupts and flags management functions **********************************/
shaorui 0:571a1835428e 405 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
shaorui 0:571a1835428e 406 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
shaorui 0:571a1835428e 407 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
shaorui 0:571a1835428e 408 FLASH_Status FLASH_GetStatus(void);
shaorui 0:571a1835428e 409 FLASH_Status FLASH_WaitForLastOperation2(void);
shaorui 0:571a1835428e 410
shaorui 0:571a1835428e 411 #ifdef __cplusplus
shaorui 0:571a1835428e 412 }
shaorui 0:571a1835428e 413 #endif
shaorui 0:571a1835428e 414
shaorui 0:571a1835428e 415 #endif /* __STM32F4xx_FLASH_H */
shaorui 0:571a1835428e 416
shaorui 0:571a1835428e 417 /**
shaorui 0:571a1835428e 418 * @}
shaorui 0:571a1835428e 419 */
shaorui 0:571a1835428e 420
shaorui 0:571a1835428e 421 /**
shaorui 0:571a1835428e 422 * @}
shaorui 0:571a1835428e 423 */
shaorui 0:571a1835428e 424
shaorui 0:571a1835428e 425 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/