The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
emilmont
Date:
Fri Feb 14 14:36:43 2014 +0000
Revision:
77:869cf507173a
Parent:
76:824293ae5e43
Release 77 of the mbed library

Main changes:
* Add target NUCLEO_F030R8
* Add target NUCLEO_F401RE
* Add target NUCLEO_F103RB
* Add target NUCLEO_L152RE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 73:1efda918f0ba 1 /**
bogdanm 73:1efda918f0ba 2 ******************************************************************************
bogdanm 73:1efda918f0ba 3 * @file stm32f10x_flash.h
bogdanm 73:1efda918f0ba 4 * @author MCD Application Team
emilmont 77:869cf507173a 5 * @version V3.6.1
emilmont 77:869cf507173a 6 * @date 05-March-2012
bogdanm 73:1efda918f0ba 7 * @brief This file contains all the functions prototypes for the FLASH
bogdanm 73:1efda918f0ba 8 * firmware library.
bogdanm 76:824293ae5e43 9 *******************************************************************************
bogdanm 76:824293ae5e43 10 * Copyright (c) 2014, STMicroelectronics
bogdanm 76:824293ae5e43 11 * All rights reserved.
bogdanm 76:824293ae5e43 12 *
bogdanm 76:824293ae5e43 13 * Redistribution and use in source and binary forms, with or without
bogdanm 76:824293ae5e43 14 * modification, are permitted provided that the following conditions are met:
bogdanm 76:824293ae5e43 15 *
bogdanm 76:824293ae5e43 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 76:824293ae5e43 17 * this list of conditions and the following disclaimer.
bogdanm 76:824293ae5e43 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 76:824293ae5e43 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 76:824293ae5e43 20 * and/or other materials provided with the distribution.
bogdanm 76:824293ae5e43 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 76:824293ae5e43 22 * may be used to endorse or promote products derived from this software
bogdanm 76:824293ae5e43 23 * without specific prior written permission.
bogdanm 76:824293ae5e43 24 *
bogdanm 76:824293ae5e43 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 76:824293ae5e43 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 76:824293ae5e43 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 76:824293ae5e43 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 76:824293ae5e43 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 76:824293ae5e43 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 76:824293ae5e43 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 76:824293ae5e43 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 76:824293ae5e43 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 76:824293ae5e43 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 76:824293ae5e43 35 *******************************************************************************
bogdanm 76:824293ae5e43 36 */
bogdanm 73:1efda918f0ba 37
bogdanm 73:1efda918f0ba 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 73:1efda918f0ba 39 #ifndef __STM32F10x_FLASH_H
bogdanm 73:1efda918f0ba 40 #define __STM32F10x_FLASH_H
bogdanm 73:1efda918f0ba 41
bogdanm 73:1efda918f0ba 42 #ifdef __cplusplus
bogdanm 73:1efda918f0ba 43 extern "C" {
bogdanm 73:1efda918f0ba 44 #endif
bogdanm 73:1efda918f0ba 45
bogdanm 73:1efda918f0ba 46 /* Includes ------------------------------------------------------------------*/
bogdanm 73:1efda918f0ba 47 #include "stm32f10x.h"
bogdanm 73:1efda918f0ba 48
bogdanm 73:1efda918f0ba 49 /** @addtogroup STM32F10x_StdPeriph_Driver
bogdanm 73:1efda918f0ba 50 * @{
bogdanm 73:1efda918f0ba 51 */
bogdanm 73:1efda918f0ba 52
bogdanm 73:1efda918f0ba 53 /** @addtogroup FLASH
bogdanm 73:1efda918f0ba 54 * @{
bogdanm 73:1efda918f0ba 55 */
bogdanm 73:1efda918f0ba 56
bogdanm 73:1efda918f0ba 57 /** @defgroup FLASH_Exported_Types
bogdanm 73:1efda918f0ba 58 * @{
bogdanm 73:1efda918f0ba 59 */
bogdanm 73:1efda918f0ba 60
bogdanm 73:1efda918f0ba 61 /**
bogdanm 73:1efda918f0ba 62 * @brief FLASH Status
bogdanm 73:1efda918f0ba 63 */
bogdanm 73:1efda918f0ba 64
bogdanm 73:1efda918f0ba 65 typedef enum
bogdanm 73:1efda918f0ba 66 {
bogdanm 73:1efda918f0ba 67 FLASH_BUSY = 1,
bogdanm 73:1efda918f0ba 68 FLASH_ERROR_PG,
bogdanm 73:1efda918f0ba 69 FLASH_ERROR_WRP,
bogdanm 73:1efda918f0ba 70 FLASH_COMPLETE,
bogdanm 73:1efda918f0ba 71 FLASH_TIMEOUT
bogdanm 73:1efda918f0ba 72 }FLASH_Status;
bogdanm 73:1efda918f0ba 73
bogdanm 73:1efda918f0ba 74 /**
bogdanm 73:1efda918f0ba 75 * @}
bogdanm 73:1efda918f0ba 76 */
bogdanm 73:1efda918f0ba 77
bogdanm 73:1efda918f0ba 78 /** @defgroup FLASH_Exported_Constants
bogdanm 73:1efda918f0ba 79 * @{
bogdanm 73:1efda918f0ba 80 */
bogdanm 73:1efda918f0ba 81
bogdanm 73:1efda918f0ba 82 /** @defgroup Flash_Latency
bogdanm 73:1efda918f0ba 83 * @{
bogdanm 73:1efda918f0ba 84 */
bogdanm 73:1efda918f0ba 85
bogdanm 73:1efda918f0ba 86 #define FLASH_Latency_0 ((uint32_t)0x00000000) /*!< FLASH Zero Latency cycle */
bogdanm 73:1efda918f0ba 87 #define FLASH_Latency_1 ((uint32_t)0x00000001) /*!< FLASH One Latency cycle */
bogdanm 73:1efda918f0ba 88 #define FLASH_Latency_2 ((uint32_t)0x00000002) /*!< FLASH Two Latency cycles */
bogdanm 73:1efda918f0ba 89 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
bogdanm 73:1efda918f0ba 90 ((LATENCY) == FLASH_Latency_1) || \
bogdanm 73:1efda918f0ba 91 ((LATENCY) == FLASH_Latency_2))
bogdanm 73:1efda918f0ba 92 /**
bogdanm 73:1efda918f0ba 93 * @}
bogdanm 73:1efda918f0ba 94 */
bogdanm 73:1efda918f0ba 95
bogdanm 73:1efda918f0ba 96 /** @defgroup Half_Cycle_Enable_Disable
bogdanm 73:1efda918f0ba 97 * @{
bogdanm 73:1efda918f0ba 98 */
bogdanm 73:1efda918f0ba 99
bogdanm 73:1efda918f0ba 100 #define FLASH_HalfCycleAccess_Enable ((uint32_t)0x00000008) /*!< FLASH Half Cycle Enable */
bogdanm 73:1efda918f0ba 101 #define FLASH_HalfCycleAccess_Disable ((uint32_t)0x00000000) /*!< FLASH Half Cycle Disable */
bogdanm 73:1efda918f0ba 102 #define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \
bogdanm 73:1efda918f0ba 103 ((STATE) == FLASH_HalfCycleAccess_Disable))
bogdanm 73:1efda918f0ba 104 /**
bogdanm 73:1efda918f0ba 105 * @}
bogdanm 73:1efda918f0ba 106 */
bogdanm 73:1efda918f0ba 107
bogdanm 73:1efda918f0ba 108 /** @defgroup Prefetch_Buffer_Enable_Disable
bogdanm 73:1efda918f0ba 109 * @{
bogdanm 73:1efda918f0ba 110 */
bogdanm 73:1efda918f0ba 111
bogdanm 73:1efda918f0ba 112 #define FLASH_PrefetchBuffer_Enable ((uint32_t)0x00000010) /*!< FLASH Prefetch Buffer Enable */
bogdanm 73:1efda918f0ba 113 #define FLASH_PrefetchBuffer_Disable ((uint32_t)0x00000000) /*!< FLASH Prefetch Buffer Disable */
bogdanm 73:1efda918f0ba 114 #define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \
bogdanm 73:1efda918f0ba 115 ((STATE) == FLASH_PrefetchBuffer_Disable))
bogdanm 73:1efda918f0ba 116 /**
bogdanm 73:1efda918f0ba 117 * @}
bogdanm 73:1efda918f0ba 118 */
bogdanm 73:1efda918f0ba 119
bogdanm 73:1efda918f0ba 120 /** @defgroup Option_Bytes_Write_Protection
bogdanm 73:1efda918f0ba 121 * @{
bogdanm 73:1efda918f0ba 122 */
bogdanm 73:1efda918f0ba 123
bogdanm 73:1efda918f0ba 124 /* Values to be used with STM32 Low and Medium density devices */
bogdanm 73:1efda918f0ba 125 #define FLASH_WRProt_Pages0to3 ((uint32_t)0x00000001) /*!< STM32 Low and Medium density devices: Write protection of page 0 to 3 */
bogdanm 73:1efda918f0ba 126 #define FLASH_WRProt_Pages4to7 ((uint32_t)0x00000002) /*!< STM32 Low and Medium density devices: Write protection of page 4 to 7 */
bogdanm 73:1efda918f0ba 127 #define FLASH_WRProt_Pages8to11 ((uint32_t)0x00000004) /*!< STM32 Low and Medium density devices: Write protection of page 8 to 11 */
bogdanm 73:1efda918f0ba 128 #define FLASH_WRProt_Pages12to15 ((uint32_t)0x00000008) /*!< STM32 Low and Medium density devices: Write protection of page 12 to 15 */
bogdanm 73:1efda918f0ba 129 #define FLASH_WRProt_Pages16to19 ((uint32_t)0x00000010) /*!< STM32 Low and Medium density devices: Write protection of page 16 to 19 */
bogdanm 73:1efda918f0ba 130 #define FLASH_WRProt_Pages20to23 ((uint32_t)0x00000020) /*!< STM32 Low and Medium density devices: Write protection of page 20 to 23 */
bogdanm 73:1efda918f0ba 131 #define FLASH_WRProt_Pages24to27 ((uint32_t)0x00000040) /*!< STM32 Low and Medium density devices: Write protection of page 24 to 27 */
bogdanm 73:1efda918f0ba 132 #define FLASH_WRProt_Pages28to31 ((uint32_t)0x00000080) /*!< STM32 Low and Medium density devices: Write protection of page 28 to 31 */
bogdanm 73:1efda918f0ba 133
bogdanm 73:1efda918f0ba 134 /* Values to be used with STM32 Medium-density devices */
bogdanm 73:1efda918f0ba 135 #define FLASH_WRProt_Pages32to35 ((uint32_t)0x00000100) /*!< STM32 Medium-density devices: Write protection of page 32 to 35 */
bogdanm 73:1efda918f0ba 136 #define FLASH_WRProt_Pages36to39 ((uint32_t)0x00000200) /*!< STM32 Medium-density devices: Write protection of page 36 to 39 */
bogdanm 73:1efda918f0ba 137 #define FLASH_WRProt_Pages40to43 ((uint32_t)0x00000400) /*!< STM32 Medium-density devices: Write protection of page 40 to 43 */
bogdanm 73:1efda918f0ba 138 #define FLASH_WRProt_Pages44to47 ((uint32_t)0x00000800) /*!< STM32 Medium-density devices: Write protection of page 44 to 47 */
bogdanm 73:1efda918f0ba 139 #define FLASH_WRProt_Pages48to51 ((uint32_t)0x00001000) /*!< STM32 Medium-density devices: Write protection of page 48 to 51 */
bogdanm 73:1efda918f0ba 140 #define FLASH_WRProt_Pages52to55 ((uint32_t)0x00002000) /*!< STM32 Medium-density devices: Write protection of page 52 to 55 */
bogdanm 73:1efda918f0ba 141 #define FLASH_WRProt_Pages56to59 ((uint32_t)0x00004000) /*!< STM32 Medium-density devices: Write protection of page 56 to 59 */
bogdanm 73:1efda918f0ba 142 #define FLASH_WRProt_Pages60to63 ((uint32_t)0x00008000) /*!< STM32 Medium-density devices: Write protection of page 60 to 63 */
bogdanm 73:1efda918f0ba 143 #define FLASH_WRProt_Pages64to67 ((uint32_t)0x00010000) /*!< STM32 Medium-density devices: Write protection of page 64 to 67 */
bogdanm 73:1efda918f0ba 144 #define FLASH_WRProt_Pages68to71 ((uint32_t)0x00020000) /*!< STM32 Medium-density devices: Write protection of page 68 to 71 */
bogdanm 73:1efda918f0ba 145 #define FLASH_WRProt_Pages72to75 ((uint32_t)0x00040000) /*!< STM32 Medium-density devices: Write protection of page 72 to 75 */
bogdanm 73:1efda918f0ba 146 #define FLASH_WRProt_Pages76to79 ((uint32_t)0x00080000) /*!< STM32 Medium-density devices: Write protection of page 76 to 79 */
bogdanm 73:1efda918f0ba 147 #define FLASH_WRProt_Pages80to83 ((uint32_t)0x00100000) /*!< STM32 Medium-density devices: Write protection of page 80 to 83 */
bogdanm 73:1efda918f0ba 148 #define FLASH_WRProt_Pages84to87 ((uint32_t)0x00200000) /*!< STM32 Medium-density devices: Write protection of page 84 to 87 */
bogdanm 73:1efda918f0ba 149 #define FLASH_WRProt_Pages88to91 ((uint32_t)0x00400000) /*!< STM32 Medium-density devices: Write protection of page 88 to 91 */
bogdanm 73:1efda918f0ba 150 #define FLASH_WRProt_Pages92to95 ((uint32_t)0x00800000) /*!< STM32 Medium-density devices: Write protection of page 92 to 95 */
bogdanm 73:1efda918f0ba 151 #define FLASH_WRProt_Pages96to99 ((uint32_t)0x01000000) /*!< STM32 Medium-density devices: Write protection of page 96 to 99 */
bogdanm 73:1efda918f0ba 152 #define FLASH_WRProt_Pages100to103 ((uint32_t)0x02000000) /*!< STM32 Medium-density devices: Write protection of page 100 to 103 */
bogdanm 73:1efda918f0ba 153 #define FLASH_WRProt_Pages104to107 ((uint32_t)0x04000000) /*!< STM32 Medium-density devices: Write protection of page 104 to 107 */
bogdanm 73:1efda918f0ba 154 #define FLASH_WRProt_Pages108to111 ((uint32_t)0x08000000) /*!< STM32 Medium-density devices: Write protection of page 108 to 111 */
bogdanm 73:1efda918f0ba 155 #define FLASH_WRProt_Pages112to115 ((uint32_t)0x10000000) /*!< STM32 Medium-density devices: Write protection of page 112 to 115 */
bogdanm 73:1efda918f0ba 156 #define FLASH_WRProt_Pages116to119 ((uint32_t)0x20000000) /*!< STM32 Medium-density devices: Write protection of page 115 to 119 */
bogdanm 73:1efda918f0ba 157 #define FLASH_WRProt_Pages120to123 ((uint32_t)0x40000000) /*!< STM32 Medium-density devices: Write protection of page 120 to 123 */
bogdanm 73:1efda918f0ba 158 #define FLASH_WRProt_Pages124to127 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 124 to 127 */
bogdanm 73:1efda918f0ba 159
bogdanm 73:1efda918f0ba 160 /* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */
bogdanm 73:1efda918f0ba 161 #define FLASH_WRProt_Pages0to1 ((uint32_t)0x00000001) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 162 Write protection of page 0 to 1 */
bogdanm 73:1efda918f0ba 163 #define FLASH_WRProt_Pages2to3 ((uint32_t)0x00000002) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 164 Write protection of page 2 to 3 */
bogdanm 73:1efda918f0ba 165 #define FLASH_WRProt_Pages4to5 ((uint32_t)0x00000004) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 166 Write protection of page 4 to 5 */
bogdanm 73:1efda918f0ba 167 #define FLASH_WRProt_Pages6to7 ((uint32_t)0x00000008) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 168 Write protection of page 6 to 7 */
bogdanm 73:1efda918f0ba 169 #define FLASH_WRProt_Pages8to9 ((uint32_t)0x00000010) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 170 Write protection of page 8 to 9 */
bogdanm 73:1efda918f0ba 171 #define FLASH_WRProt_Pages10to11 ((uint32_t)0x00000020) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 172 Write protection of page 10 to 11 */
bogdanm 73:1efda918f0ba 173 #define FLASH_WRProt_Pages12to13 ((uint32_t)0x00000040) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 174 Write protection of page 12 to 13 */
bogdanm 73:1efda918f0ba 175 #define FLASH_WRProt_Pages14to15 ((uint32_t)0x00000080) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 176 Write protection of page 14 to 15 */
bogdanm 73:1efda918f0ba 177 #define FLASH_WRProt_Pages16to17 ((uint32_t)0x00000100) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 178 Write protection of page 16 to 17 */
bogdanm 73:1efda918f0ba 179 #define FLASH_WRProt_Pages18to19 ((uint32_t)0x00000200) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 180 Write protection of page 18 to 19 */
bogdanm 73:1efda918f0ba 181 #define FLASH_WRProt_Pages20to21 ((uint32_t)0x00000400) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 182 Write protection of page 20 to 21 */
bogdanm 73:1efda918f0ba 183 #define FLASH_WRProt_Pages22to23 ((uint32_t)0x00000800) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 184 Write protection of page 22 to 23 */
bogdanm 73:1efda918f0ba 185 #define FLASH_WRProt_Pages24to25 ((uint32_t)0x00001000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 186 Write protection of page 24 to 25 */
bogdanm 73:1efda918f0ba 187 #define FLASH_WRProt_Pages26to27 ((uint32_t)0x00002000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 188 Write protection of page 26 to 27 */
bogdanm 73:1efda918f0ba 189 #define FLASH_WRProt_Pages28to29 ((uint32_t)0x00004000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 190 Write protection of page 28 to 29 */
bogdanm 73:1efda918f0ba 191 #define FLASH_WRProt_Pages30to31 ((uint32_t)0x00008000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 192 Write protection of page 30 to 31 */
bogdanm 73:1efda918f0ba 193 #define FLASH_WRProt_Pages32to33 ((uint32_t)0x00010000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 194 Write protection of page 32 to 33 */
bogdanm 73:1efda918f0ba 195 #define FLASH_WRProt_Pages34to35 ((uint32_t)0x00020000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 196 Write protection of page 34 to 35 */
bogdanm 73:1efda918f0ba 197 #define FLASH_WRProt_Pages36to37 ((uint32_t)0x00040000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 198 Write protection of page 36 to 37 */
bogdanm 73:1efda918f0ba 199 #define FLASH_WRProt_Pages38to39 ((uint32_t)0x00080000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 200 Write protection of page 38 to 39 */
bogdanm 73:1efda918f0ba 201 #define FLASH_WRProt_Pages40to41 ((uint32_t)0x00100000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 202 Write protection of page 40 to 41 */
bogdanm 73:1efda918f0ba 203 #define FLASH_WRProt_Pages42to43 ((uint32_t)0x00200000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 204 Write protection of page 42 to 43 */
bogdanm 73:1efda918f0ba 205 #define FLASH_WRProt_Pages44to45 ((uint32_t)0x00400000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 206 Write protection of page 44 to 45 */
bogdanm 73:1efda918f0ba 207 #define FLASH_WRProt_Pages46to47 ((uint32_t)0x00800000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 208 Write protection of page 46 to 47 */
bogdanm 73:1efda918f0ba 209 #define FLASH_WRProt_Pages48to49 ((uint32_t)0x01000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 210 Write protection of page 48 to 49 */
bogdanm 73:1efda918f0ba 211 #define FLASH_WRProt_Pages50to51 ((uint32_t)0x02000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 212 Write protection of page 50 to 51 */
bogdanm 73:1efda918f0ba 213 #define FLASH_WRProt_Pages52to53 ((uint32_t)0x04000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 214 Write protection of page 52 to 53 */
bogdanm 73:1efda918f0ba 215 #define FLASH_WRProt_Pages54to55 ((uint32_t)0x08000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 216 Write protection of page 54 to 55 */
bogdanm 73:1efda918f0ba 217 #define FLASH_WRProt_Pages56to57 ((uint32_t)0x10000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 218 Write protection of page 56 to 57 */
bogdanm 73:1efda918f0ba 219 #define FLASH_WRProt_Pages58to59 ((uint32_t)0x20000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 220 Write protection of page 58 to 59 */
bogdanm 73:1efda918f0ba 221 #define FLASH_WRProt_Pages60to61 ((uint32_t)0x40000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
bogdanm 73:1efda918f0ba 222 Write protection of page 60 to 61 */
bogdanm 73:1efda918f0ba 223 #define FLASH_WRProt_Pages62to127 ((uint32_t)0x80000000) /*!< STM32 Connectivity line devices: Write protection of page 62 to 127 */
bogdanm 73:1efda918f0ba 224 #define FLASH_WRProt_Pages62to255 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 62 to 255 */
bogdanm 73:1efda918f0ba 225 #define FLASH_WRProt_Pages62to511 ((uint32_t)0x80000000) /*!< STM32 XL-density devices: Write protection of page 62 to 511 */
bogdanm 73:1efda918f0ba 226
bogdanm 73:1efda918f0ba 227 #define FLASH_WRProt_AllPages ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Pages */
bogdanm 73:1efda918f0ba 228
bogdanm 73:1efda918f0ba 229 #define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))
bogdanm 73:1efda918f0ba 230
bogdanm 73:1efda918f0ba 231 #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF))
bogdanm 73:1efda918f0ba 232
bogdanm 73:1efda918f0ba 233 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
bogdanm 73:1efda918f0ba 234
bogdanm 73:1efda918f0ba 235 /**
bogdanm 73:1efda918f0ba 236 * @}
bogdanm 73:1efda918f0ba 237 */
bogdanm 73:1efda918f0ba 238
bogdanm 73:1efda918f0ba 239 /** @defgroup Option_Bytes_IWatchdog
bogdanm 73:1efda918f0ba 240 * @{
bogdanm 73:1efda918f0ba 241 */
bogdanm 73:1efda918f0ba 242
bogdanm 73:1efda918f0ba 243 #define OB_IWDG_SW ((uint16_t)0x0001) /*!< Software IWDG selected */
bogdanm 73:1efda918f0ba 244 #define OB_IWDG_HW ((uint16_t)0x0000) /*!< Hardware IWDG selected */
bogdanm 73:1efda918f0ba 245 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
bogdanm 73:1efda918f0ba 246
bogdanm 73:1efda918f0ba 247 /**
bogdanm 73:1efda918f0ba 248 * @}
bogdanm 73:1efda918f0ba 249 */
bogdanm 73:1efda918f0ba 250
bogdanm 73:1efda918f0ba 251 /** @defgroup Option_Bytes_nRST_STOP
bogdanm 73:1efda918f0ba 252 * @{
bogdanm 73:1efda918f0ba 253 */
bogdanm 73:1efda918f0ba 254
bogdanm 73:1efda918f0ba 255 #define OB_STOP_NoRST ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */
bogdanm 73:1efda918f0ba 256 #define OB_STOP_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */
bogdanm 73:1efda918f0ba 257 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
bogdanm 73:1efda918f0ba 258
bogdanm 73:1efda918f0ba 259 /**
bogdanm 73:1efda918f0ba 260 * @}
bogdanm 73:1efda918f0ba 261 */
bogdanm 73:1efda918f0ba 262
bogdanm 73:1efda918f0ba 263 /** @defgroup Option_Bytes_nRST_STDBY
bogdanm 73:1efda918f0ba 264 * @{
bogdanm 73:1efda918f0ba 265 */
bogdanm 73:1efda918f0ba 266
bogdanm 73:1efda918f0ba 267 #define OB_STDBY_NoRST ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */
bogdanm 73:1efda918f0ba 268 #define OB_STDBY_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */
bogdanm 73:1efda918f0ba 269 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
bogdanm 73:1efda918f0ba 270
bogdanm 73:1efda918f0ba 271 #ifdef STM32F10X_XL
bogdanm 73:1efda918f0ba 272 /**
bogdanm 73:1efda918f0ba 273 * @}
bogdanm 73:1efda918f0ba 274 */
bogdanm 73:1efda918f0ba 275 /** @defgroup FLASH_Boot
bogdanm 73:1efda918f0ba 276 * @{
bogdanm 73:1efda918f0ba 277 */
bogdanm 73:1efda918f0ba 278 #define FLASH_BOOT_Bank1 ((uint16_t)0x0000) /*!< At startup, if boot pins are set in boot from user Flash position
bogdanm 73:1efda918f0ba 279 and this parameter is selected the device will boot from Bank1(Default) */
bogdanm 73:1efda918f0ba 280 #define FLASH_BOOT_Bank2 ((uint16_t)0x0001) /*!< At startup, if boot pins are set in boot from user Flash position
bogdanm 73:1efda918f0ba 281 and this parameter is selected the device will boot from Bank 2 or Bank 1,
bogdanm 73:1efda918f0ba 282 depending on the activation of the bank */
bogdanm 73:1efda918f0ba 283 #define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2))
bogdanm 73:1efda918f0ba 284 #endif
bogdanm 73:1efda918f0ba 285 /**
bogdanm 73:1efda918f0ba 286 * @}
bogdanm 73:1efda918f0ba 287 */
bogdanm 73:1efda918f0ba 288 /** @defgroup FLASH_Interrupts
bogdanm 73:1efda918f0ba 289 * @{
bogdanm 73:1efda918f0ba 290 */
bogdanm 73:1efda918f0ba 291 #ifdef STM32F10X_XL
bogdanm 73:1efda918f0ba 292 #define FLASH_IT_BANK2_ERROR ((uint32_t)0x80000400) /*!< FPEC BANK2 error interrupt source */
bogdanm 73:1efda918f0ba 293 #define FLASH_IT_BANK2_EOP ((uint32_t)0x80001000) /*!< End of FLASH BANK2 Operation Interrupt source */
bogdanm 73:1efda918f0ba 294
bogdanm 73:1efda918f0ba 295 #define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */
bogdanm 73:1efda918f0ba 296 #define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */
bogdanm 73:1efda918f0ba 297
bogdanm 73:1efda918f0ba 298 #define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC BANK1 error interrupt source */
bogdanm 73:1efda918f0ba 299 #define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH BANK1 Operation Interrupt source */
bogdanm 73:1efda918f0ba 300 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
bogdanm 73:1efda918f0ba 301 #else
bogdanm 73:1efda918f0ba 302 #define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC error interrupt source */
bogdanm 73:1efda918f0ba 303 #define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH Operation Interrupt source */
bogdanm 73:1efda918f0ba 304 #define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */
bogdanm 73:1efda918f0ba 305 #define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */
bogdanm 73:1efda918f0ba 306
bogdanm 73:1efda918f0ba 307 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
bogdanm 73:1efda918f0ba 308 #endif
bogdanm 73:1efda918f0ba 309
bogdanm 73:1efda918f0ba 310 /**
bogdanm 73:1efda918f0ba 311 * @}
bogdanm 73:1efda918f0ba 312 */
bogdanm 73:1efda918f0ba 313
bogdanm 73:1efda918f0ba 314 /** @defgroup FLASH_Flags
bogdanm 73:1efda918f0ba 315 * @{
bogdanm 73:1efda918f0ba 316 */
bogdanm 73:1efda918f0ba 317 #ifdef STM32F10X_XL
bogdanm 73:1efda918f0ba 318 #define FLASH_FLAG_BANK2_BSY ((uint32_t)0x80000001) /*!< FLASH BANK2 Busy flag */
bogdanm 73:1efda918f0ba 319 #define FLASH_FLAG_BANK2_EOP ((uint32_t)0x80000020) /*!< FLASH BANK2 End of Operation flag */
bogdanm 73:1efda918f0ba 320 #define FLASH_FLAG_BANK2_PGERR ((uint32_t)0x80000004) /*!< FLASH BANK2 Program error flag */
bogdanm 73:1efda918f0ba 321 #define FLASH_FLAG_BANK2_WRPRTERR ((uint32_t)0x80000010) /*!< FLASH BANK2 Write protected error flag */
bogdanm 73:1efda918f0ba 322
bogdanm 73:1efda918f0ba 323 #define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/
bogdanm 73:1efda918f0ba 324 #define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */
bogdanm 73:1efda918f0ba 325 #define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */
bogdanm 73:1efda918f0ba 326 #define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */
bogdanm 73:1efda918f0ba 327
bogdanm 73:1efda918f0ba 328 #define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */
bogdanm 73:1efda918f0ba 329 #define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */
bogdanm 73:1efda918f0ba 330 #define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */
bogdanm 73:1efda918f0ba 331 #define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */
bogdanm 73:1efda918f0ba 332 #define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */
bogdanm 73:1efda918f0ba 333
bogdanm 73:1efda918f0ba 334 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
bogdanm 73:1efda918f0ba 335 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
bogdanm 73:1efda918f0ba 336 ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
bogdanm 73:1efda918f0ba 337 ((FLAG) == FLASH_FLAG_OPTERR)|| \
bogdanm 73:1efda918f0ba 338 ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
bogdanm 73:1efda918f0ba 339 ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
bogdanm 73:1efda918f0ba 340 ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \
bogdanm 73:1efda918f0ba 341 ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR))
bogdanm 73:1efda918f0ba 342 #else
bogdanm 73:1efda918f0ba 343 #define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */
bogdanm 73:1efda918f0ba 344 #define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */
bogdanm 73:1efda918f0ba 345 #define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */
bogdanm 73:1efda918f0ba 346 #define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */
bogdanm 73:1efda918f0ba 347 #define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */
bogdanm 73:1efda918f0ba 348
bogdanm 73:1efda918f0ba 349 #define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/
bogdanm 73:1efda918f0ba 350 #define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */
bogdanm 73:1efda918f0ba 351 #define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */
bogdanm 73:1efda918f0ba 352 #define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */
bogdanm 73:1efda918f0ba 353
bogdanm 73:1efda918f0ba 354 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
bogdanm 73:1efda918f0ba 355 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
bogdanm 73:1efda918f0ba 356 ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
bogdanm 73:1efda918f0ba 357 ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
bogdanm 73:1efda918f0ba 358 ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
bogdanm 73:1efda918f0ba 359 ((FLAG) == FLASH_FLAG_OPTERR))
bogdanm 73:1efda918f0ba 360 #endif
bogdanm 73:1efda918f0ba 361
bogdanm 73:1efda918f0ba 362 /**
bogdanm 73:1efda918f0ba 363 * @}
bogdanm 73:1efda918f0ba 364 */
bogdanm 73:1efda918f0ba 365
bogdanm 73:1efda918f0ba 366 /**
bogdanm 73:1efda918f0ba 367 * @}
bogdanm 73:1efda918f0ba 368 */
bogdanm 73:1efda918f0ba 369
bogdanm 73:1efda918f0ba 370 /** @defgroup FLASH_Exported_Macros
bogdanm 73:1efda918f0ba 371 * @{
bogdanm 73:1efda918f0ba 372 */
bogdanm 73:1efda918f0ba 373
bogdanm 73:1efda918f0ba 374 /**
bogdanm 73:1efda918f0ba 375 * @}
bogdanm 73:1efda918f0ba 376 */
bogdanm 73:1efda918f0ba 377
bogdanm 73:1efda918f0ba 378 /** @defgroup FLASH_Exported_Functions
bogdanm 73:1efda918f0ba 379 * @{
bogdanm 73:1efda918f0ba 380 */
bogdanm 73:1efda918f0ba 381
bogdanm 73:1efda918f0ba 382 /*------------ Functions used for all STM32F10x devices -----*/
bogdanm 73:1efda918f0ba 383 void FLASH_SetLatency(uint32_t FLASH_Latency);
bogdanm 73:1efda918f0ba 384 void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess);
bogdanm 73:1efda918f0ba 385 void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer);
bogdanm 73:1efda918f0ba 386 void FLASH_Unlock(void);
bogdanm 73:1efda918f0ba 387 void FLASH_Lock(void);
bogdanm 73:1efda918f0ba 388 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
bogdanm 73:1efda918f0ba 389 FLASH_Status FLASH_EraseAllPages(void);
bogdanm 73:1efda918f0ba 390 FLASH_Status FLASH_EraseOptionBytes(void);
bogdanm 73:1efda918f0ba 391 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
bogdanm 73:1efda918f0ba 392 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
bogdanm 73:1efda918f0ba 393 FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);
bogdanm 73:1efda918f0ba 394 FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages);
bogdanm 73:1efda918f0ba 395 FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
bogdanm 73:1efda918f0ba 396 FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY);
bogdanm 73:1efda918f0ba 397 uint32_t FLASH_GetUserOptionByte(void);
bogdanm 73:1efda918f0ba 398 uint32_t FLASH_GetWriteProtectionOptionByte(void);
bogdanm 73:1efda918f0ba 399 FlagStatus FLASH_GetReadOutProtectionStatus(void);
bogdanm 73:1efda918f0ba 400 FlagStatus FLASH_GetPrefetchBufferStatus(void);
bogdanm 73:1efda918f0ba 401 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
bogdanm 73:1efda918f0ba 402 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
bogdanm 73:1efda918f0ba 403 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
bogdanm 73:1efda918f0ba 404 FLASH_Status FLASH_GetStatus(void);
bogdanm 73:1efda918f0ba 405 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
bogdanm 73:1efda918f0ba 406
bogdanm 73:1efda918f0ba 407 /*------------ New function used for all STM32F10x devices -----*/
bogdanm 73:1efda918f0ba 408 void FLASH_UnlockBank1(void);
bogdanm 73:1efda918f0ba 409 void FLASH_LockBank1(void);
bogdanm 73:1efda918f0ba 410 FLASH_Status FLASH_EraseAllBank1Pages(void);
bogdanm 73:1efda918f0ba 411 FLASH_Status FLASH_GetBank1Status(void);
bogdanm 73:1efda918f0ba 412 FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout);
bogdanm 73:1efda918f0ba 413
bogdanm 73:1efda918f0ba 414 #ifdef STM32F10X_XL
bogdanm 73:1efda918f0ba 415 /*---- New Functions used only with STM32F10x_XL density devices -----*/
bogdanm 73:1efda918f0ba 416 void FLASH_UnlockBank2(void);
bogdanm 73:1efda918f0ba 417 void FLASH_LockBank2(void);
bogdanm 73:1efda918f0ba 418 FLASH_Status FLASH_EraseAllBank2Pages(void);
bogdanm 73:1efda918f0ba 419 FLASH_Status FLASH_GetBank2Status(void);
bogdanm 73:1efda918f0ba 420 FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout);
bogdanm 73:1efda918f0ba 421 FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT);
bogdanm 73:1efda918f0ba 422 #endif
bogdanm 73:1efda918f0ba 423
bogdanm 73:1efda918f0ba 424 #ifdef __cplusplus
bogdanm 73:1efda918f0ba 425 }
bogdanm 73:1efda918f0ba 426 #endif
bogdanm 73:1efda918f0ba 427
bogdanm 73:1efda918f0ba 428 #endif /* __STM32F10x_FLASH_H */
bogdanm 73:1efda918f0ba 429 /**
bogdanm 73:1efda918f0ba 430 * @}
bogdanm 73:1efda918f0ba 431 */
bogdanm 73:1efda918f0ba 432
bogdanm 73:1efda918f0ba 433 /**
bogdanm 73:1efda918f0ba 434 * @}
bogdanm 73:1efda918f0ba 435 */
bogdanm 73:1efda918f0ba 436
bogdanm 73:1efda918f0ba 437 /**
bogdanm 73:1efda918f0ba 438 * @}
bogdanm 73:1efda918f0ba 439 */
bogdanm 73:1efda918f0ba 440
emilmont 77:869cf507173a 441 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/