Modified Motor Driver Firmware to include Flash + Thermal

Dependencies:   FastPWM3 mbed-dev-STM-lean

Committer:
benkatz
Date:
Wed Apr 05 20:54:16 2017 +0000
Revision:
23:2adf23ee0305
Added bayley's flash writer

Who changed what in which revision?

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