Rev 49 | Rev 61 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 49 | Rev 50 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file stm32l1xx_hal_flash.h |
3 | * @file stm32l1xx_hal_flash.h |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @version V1.2.0 |
- | |
| 6 | * @date 01-July-2016 |
- | |
| 7 | * @brief Header file of Flash HAL module. |
5 | * @brief Header file of Flash HAL module. |
| 8 | ****************************************************************************** |
6 | ****************************************************************************** |
| 9 | * @attention |
7 | * @attention |
| 10 | * |
8 | * |
| 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
| - | 10 | * All rights reserved.</center></h2> |
|
| 12 | * |
11 | * |
| 13 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
| 14 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
| 15 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
| 16 | * this list of conditions and the following disclaimer. |
- | |
| 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
| 18 | * this list of conditions and the following disclaimer in the documentation |
- | |
| 19 | * and/or other materials provided with the distribution. |
14 | * License. You may obtain a copy of the License at: |
| 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
| 21 | * may be used to endorse or promote products derived from this software |
15 | * opensource.org/licenses/BSD-3-Clause |
| 22 | * without specific prior written permission. |
- | |
| 23 | * |
16 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
| 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
| 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
| 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
| 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
| 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
| 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
| 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
| 34 | * |
- | |
| 35 | ****************************************************************************** |
17 | ****************************************************************************** |
| 36 | */ |
18 | */ |
| 37 | 19 | ||
| 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| 39 | #ifndef __STM32L1xx_HAL_FLASH_H |
21 | #ifndef __STM32L1xx_HAL_FLASH_H |
| 40 | #define __STM32L1xx_HAL_FLASH_H |
22 | #define __STM32L1xx_HAL_FLASH_H |
| Line 55... | Line 37... | ||
| 55 | */ |
37 | */ |
| 56 | 38 | ||
| 57 | /** @addtogroup FLASH_Private_Constants |
39 | /** @addtogroup FLASH_Private_Constants |
| 58 | * @{ |
40 | * @{ |
| 59 | */ |
41 | */ |
| 60 | #define FLASH_TIMEOUT_VALUE ((uint32_t)50000U) /* 50 s */ |
42 | #define FLASH_TIMEOUT_VALUE (50000U) /* 50 s */ |
| 61 | /** |
43 | /** |
| 62 | * @} |
44 | * @} |
| 63 | */ |
45 | */ |
| 64 | 46 | ||
| 65 | /** @addtogroup FLASH_Private_Macros |
47 | /** @addtogroup FLASH_Private_Macros |
| 66 | * @{ |
48 | * @{ |
| 67 | */ |
49 | */ |
| 68 | 50 | ||
| 69 | #define IS_FLASH_TYPEPROGRAM(_VALUE_) (((_VALUE_) == FLASH_TYPEPROGRAM_WORD)) |
51 | #define IS_FLASH_TYPEPROGRAM(_VALUE_) ((_VALUE_) == FLASH_TYPEPROGRAM_WORD) |
| 70 | 52 | ||
| 71 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \ |
53 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \ |
| 72 | ((__LATENCY__) == FLASH_LATENCY_1)) |
54 | ((__LATENCY__) == FLASH_LATENCY_1)) |
| 73 | 55 | ||
| 74 | /** |
56 | /** |
| Line 83... | Line 65... | ||
| 83 | /** |
65 | /** |
| 84 | * @brief FLASH Procedure structure definition |
66 | * @brief FLASH Procedure structure definition |
| 85 | */ |
67 | */ |
| 86 | typedef enum |
68 | typedef enum |
| 87 | { |
69 | { |
| 88 | FLASH_PROC_NONE = 0, |
70 | FLASH_PROC_NONE = 0U, |
| 89 | FLASH_PROC_PAGEERASE = 1, |
71 | FLASH_PROC_PAGEERASE = 1U, |
| 90 | FLASH_PROC_PROGRAM = 2, |
72 | FLASH_PROC_PROGRAM = 2U, |
| 91 | } FLASH_ProcedureTypeDef; |
73 | } FLASH_ProcedureTypeDef; |
| 92 | 74 | ||
| 93 | /** |
75 | /** |
| 94 | * @brief FLASH handle Structure definition |
76 | * @brief FLASH handle Structure definition |
| 95 | */ |
77 | */ |
| Line 137... | Line 119... | ||
| 137 | 119 | ||
| 138 | /** @defgroup FLASH_Page_Size FLASH size information |
120 | /** @defgroup FLASH_Page_Size FLASH size information |
| 139 | * @{ |
121 | * @{ |
| 140 | */ |
122 | */ |
| 141 | 123 | ||
| 142 | #define FLASH_SIZE (uint32_t)(*((uint16_t *)FLASHSIZE_BASE) * 1024U) |
124 | #define FLASH_SIZE (uint32_t)((*((uint32_t *)FLASHSIZE_BASE)&0xFFFFU) * 1024U) |
| 143 | #define FLASH_PAGE_SIZE ((uint32_t)256U) /*!< FLASH Page Size in bytes */ |
125 | #define FLASH_PAGE_SIZE (256U) /*!< FLASH Page Size in bytes */ |
| 144 | 126 | ||
| 145 | /** |
127 | /** |
| 146 | * @} |
128 | * @} |
| 147 | */ |
129 | */ |
| 148 | 130 | ||
| 149 | /** @defgroup FLASH_Type_Program FLASH Type Program |
131 | /** @defgroup FLASH_Type_Program FLASH Type Program |
| 150 | * @{ |
132 | * @{ |
| 151 | */ |
133 | */ |
| 152 | #define FLASH_TYPEPROGRAM_WORD ((uint32_t)0x02U) /*!<Program a word (32-bit) at a specified address.*/ |
134 | #define FLASH_TYPEPROGRAM_WORD (0x02U) /*!<Program a word (32-bit) at a specified address.*/ |
| 153 | 135 | ||
| 154 | /** |
136 | /** |
| 155 | * @} |
137 | * @} |
| 156 | */ |
138 | */ |
| 157 | 139 | ||
| 158 | /** @defgroup FLASH_Latency FLASH Latency |
140 | /** @defgroup FLASH_Latency FLASH Latency |
| 159 | * @{ |
141 | * @{ |
| 160 | */ |
142 | */ |
| 161 | #define FLASH_LATENCY_0 ((uint32_t)0x00000000U) /*!< FLASH Zero Latency cycle */ |
143 | #define FLASH_LATENCY_0 (0x00000000U) /*!< FLASH Zero Latency cycle */ |
| 162 | #define FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One Latency cycle */ |
144 | #define FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One Latency cycle */ |
| 163 | 145 | ||
| 164 | /** |
146 | /** |
| 165 | * @} |
147 | * @} |
| 166 | */ |
148 | */ |
| 167 | 149 | ||
| 168 | /** @defgroup FLASH_Interrupts FLASH Interrupts |
150 | /** @defgroup FLASH_Interrupts FLASH Interrupts |
| 169 | * @{ |
151 | * @{ |
| 170 | */ |
152 | */ |
| 171 | 153 | ||
| 172 | #define FLASH_IT_EOP FLASH_PECR_EOPIE /*!< End of programming interrupt source */ |
154 | #define FLASH_IT_EOP FLASH_PECR_EOPIE /*!< End of programming interrupt source */ |
| 173 | #define FLASH_IT_ERR FLASH_PECR_ERRIE /*!< Error interrupt source */ |
155 | #define FLASH_IT_ERR FLASH_PECR_ERRIE /*!< Error interrupt source */ |
| 174 | /** |
156 | /** |
| 175 | * @} |
157 | * @} |
| 176 | */ |
158 | */ |
| Line 202... | Line 184... | ||
| 202 | 184 | ||
| 203 | /** @defgroup FLASH_Keys FLASH Keys |
185 | /** @defgroup FLASH_Keys FLASH Keys |
| 204 | * @{ |
186 | * @{ |
| 205 | */ |
187 | */ |
| 206 | 188 | ||
| 207 | #define FLASH_PDKEY1 ((uint32_t)0x04152637U) /*!< Flash power down key1 */ |
189 | #define FLASH_PDKEY1 (0x04152637U) /*!< Flash power down key1 */ |
| 208 | #define FLASH_PDKEY2 ((uint32_t)0xFAFBFCFDU) /*!< Flash power down key2: used with FLASH_PDKEY1 |
190 | #define FLASH_PDKEY2 (0xFAFBFCFDU) /*!< Flash power down key2: used with FLASH_PDKEY1 |
| 209 | to unlock the RUN_PD bit in FLASH_ACR */ |
191 | to unlock the RUN_PD bit in FLASH_ACR */ |
| 210 | 192 | ||
| 211 | #define FLASH_PEKEY1 ((uint32_t)0x89ABCDEFU) /*!< Flash program erase key1 */ |
193 | #define FLASH_PEKEY1 (0x89ABCDEFU) /*!< Flash program erase key1 */ |
| 212 | #define FLASH_PEKEY2 ((uint32_t)0x02030405U) /*!< Flash program erase key: used with FLASH_PEKEY2 |
194 | #define FLASH_PEKEY2 (0x02030405U) /*!< Flash program erase key: used with FLASH_PEKEY2 |
| 213 | to unlock the write access to the FLASH_PECR register and |
195 | to unlock the write access to the FLASH_PECR register and |
| 214 | data EEPROM */ |
196 | data EEPROM */ |
| 215 | 197 | ||
| 216 | #define FLASH_PRGKEY1 ((uint32_t)0x8C9DAEBFU) /*!< Flash program memory key1 */ |
198 | #define FLASH_PRGKEY1 (0x8C9DAEBFU) /*!< Flash program memory key1 */ |
| 217 | #define FLASH_PRGKEY2 ((uint32_t)0x13141516U) /*!< Flash program memory key2: used with FLASH_PRGKEY2 |
199 | #define FLASH_PRGKEY2 (0x13141516U) /*!< Flash program memory key2: used with FLASH_PRGKEY2 |
| 218 | to unlock the program memory */ |
200 | to unlock the program memory */ |
| 219 | 201 | ||
| 220 | #define FLASH_OPTKEY1 ((uint32_t)0xFBEAD9C8U) /*!< Flash option key1 */ |
202 | #define FLASH_OPTKEY1 (0xFBEAD9C8U) /*!< Flash option key1 */ |
| 221 | #define FLASH_OPTKEY2 ((uint32_t)0x24252627U) /*!< Flash option key2: used with FLASH_OPTKEY1 to |
203 | #define FLASH_OPTKEY2 (0x24252627U) /*!< Flash option key2: used with FLASH_OPTKEY1 to |
| 222 | unlock the write access to the option byte block */ |
204 | unlock the write access to the option byte block */ |
| 223 | /** |
205 | /** |
| 224 | * @} |
206 | * @} |
| 225 | */ |
207 | */ |
| 226 | /** |
208 | /** |
| Line 303... | Line 285... | ||
| 303 | /** |
285 | /** |
| 304 | * @brief Clear the specified FLASH flag. |
286 | * @brief Clear the specified FLASH flag. |
| 305 | * @param __FLAG__ specifies the FLASH flags to clear. |
287 | * @param __FLAG__ specifies the FLASH flags to clear. |
| 306 | * This parameter can be any combination of the following values: |
288 | * This parameter can be any combination of the following values: |
| 307 | * @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag |
289 | * @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag |
| 308 | * @arg @ref FLASH_FLAG_ENDHV FLASH End of High Voltage flag |
- | |
| 309 | * @arg @ref FLASH_FLAG_READY FLASH Ready flag after low power mode |
- | |
| 310 | * @arg @ref FLASH_FLAG_PGAERR FLASH Programming Alignment error flag |
290 | * @arg @ref FLASH_FLAG_PGAERR FLASH Programming Alignment error flag |
| 311 | * @arg @ref FLASH_FLAG_SIZERR FLASH Size error flag |
291 | * @arg @ref FLASH_FLAG_SIZERR FLASH Size error flag |
| 312 | * @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error error flag |
292 | * @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error error flag |
| 313 | @if STM32L100xB |
293 | @if STM32L100xB |
| 314 | @elif STM32L100xBA |
294 | @elif STM32L100xBA |