mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
107:4f6c30876dfa
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /**
Kojto 107:4f6c30876dfa 2 ******************************************************************************
Kojto 107:4f6c30876dfa 3 * @file stm32l4xx_hal_flash.h
Kojto 107:4f6c30876dfa 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.1
Kojto 122:f9eeca106725 6 * @date 31-May-2016
Kojto 107:4f6c30876dfa 7 * @brief Header file of FLASH HAL module.
Kojto 107:4f6c30876dfa 8 ******************************************************************************
Kojto 107:4f6c30876dfa 9 * @attention
Kojto 107:4f6c30876dfa 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 107:4f6c30876dfa 12 *
Kojto 107:4f6c30876dfa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 107:4f6c30876dfa 14 * are permitted provided that the following conditions are met:
Kojto 107:4f6c30876dfa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 107:4f6c30876dfa 16 * this list of conditions and the following disclaimer.
Kojto 107:4f6c30876dfa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 107:4f6c30876dfa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 107:4f6c30876dfa 19 * and/or other materials provided with the distribution.
Kojto 107:4f6c30876dfa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 107:4f6c30876dfa 21 * may be used to endorse or promote products derived from this software
Kojto 107:4f6c30876dfa 22 * without specific prior written permission.
Kojto 107:4f6c30876dfa 23 *
Kojto 107:4f6c30876dfa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 107:4f6c30876dfa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 107:4f6c30876dfa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 107:4f6c30876dfa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 107:4f6c30876dfa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 107:4f6c30876dfa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 107:4f6c30876dfa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 107:4f6c30876dfa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 107:4f6c30876dfa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 107:4f6c30876dfa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 107:4f6c30876dfa 34 *
Kojto 107:4f6c30876dfa 35 ******************************************************************************
Kojto 107:4f6c30876dfa 36 */
Kojto 107:4f6c30876dfa 37
Kojto 107:4f6c30876dfa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 107:4f6c30876dfa 39 #ifndef __STM32L4xx_HAL_FLASH_H
Kojto 107:4f6c30876dfa 40 #define __STM32L4xx_HAL_FLASH_H
Kojto 107:4f6c30876dfa 41
Kojto 107:4f6c30876dfa 42 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 43 extern "C" {
Kojto 107:4f6c30876dfa 44 #endif
Kojto 107:4f6c30876dfa 45
Kojto 107:4f6c30876dfa 46 /* Includes ------------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 47 #include "stm32l4xx_hal_def.h"
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 107:4f6c30876dfa 50 * @{
Kojto 107:4f6c30876dfa 51 */
Kojto 107:4f6c30876dfa 52
Kojto 107:4f6c30876dfa 53 /** @addtogroup FLASH
Kojto 107:4f6c30876dfa 54 * @{
Kojto 107:4f6c30876dfa 55 */
Kojto 107:4f6c30876dfa 56
Kojto 107:4f6c30876dfa 57 /* Exported types ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 58 /** @defgroup FLASH_Exported_Types FLASH Exported Types
Kojto 107:4f6c30876dfa 59 * @{
Kojto 107:4f6c30876dfa 60 */
Kojto 107:4f6c30876dfa 61
Kojto 107:4f6c30876dfa 62 /**
Kojto 107:4f6c30876dfa 63 * @brief FLASH Erase structure definition
Kojto 107:4f6c30876dfa 64 */
Kojto 107:4f6c30876dfa 65 typedef struct
Kojto 107:4f6c30876dfa 66 {
Kojto 107:4f6c30876dfa 67 uint32_t TypeErase; /*!< Mass erase or page erase.
Kojto 107:4f6c30876dfa 68 This parameter can be a value of @ref FLASH_Type_Erase */
Kojto 107:4f6c30876dfa 69 uint32_t Banks; /*!< Select bank to erase.
Kojto 107:4f6c30876dfa 70 This parameter must be a value of @ref FLASH_Banks
Kojto 107:4f6c30876dfa 71 (FLASH_BANK_BOTH should be used only for mass erase) */
Kojto 107:4f6c30876dfa 72 uint32_t Page; /*!< Initial Flash page to erase when page erase is disabled
Kojto 107:4f6c30876dfa 73 This parameter must be a value between 0 and (max number of pages in the bank - 1)
Kojto 107:4f6c30876dfa 74 (eg : 255 for 1MB dual bank) */
Kojto 107:4f6c30876dfa 75 uint32_t NbPages; /*!< Number of pages to be erased.
Kojto 107:4f6c30876dfa 76 This parameter must be a value between 1 and (max number of pages in the bank - value of initial page)*/
Kojto 107:4f6c30876dfa 77 } FLASH_EraseInitTypeDef;
Kojto 107:4f6c30876dfa 78
Kojto 107:4f6c30876dfa 79 /**
Kojto 107:4f6c30876dfa 80 * @brief FLASH Option Bytes Program structure definition
Kojto 107:4f6c30876dfa 81 */
Kojto 107:4f6c30876dfa 82 typedef struct
Kojto 107:4f6c30876dfa 83 {
Kojto 107:4f6c30876dfa 84 uint32_t OptionType; /*!< Option byte to be configured.
Kojto 107:4f6c30876dfa 85 This parameter can be a combination of the values of @ref FLASH_OB_Type */
Kojto 107:4f6c30876dfa 86 uint32_t WRPArea; /*!< Write protection area to be programmed (used for OPTIONBYTE_WRP).
Kojto 107:4f6c30876dfa 87 Only one WRP area could be programmed at the same time.
Kojto 107:4f6c30876dfa 88 This parameter can be value of @ref FLASH_OB_WRP_Area */
Kojto 107:4f6c30876dfa 89 uint32_t WRPStartOffset; /*!< Write protection start offset (used for OPTIONBYTE_WRP).
Kojto 107:4f6c30876dfa 90 This parameter must be a value between 0 and (max number of pages in the bank - 1)
Kojto 107:4f6c30876dfa 91 (eg : 25 for 1MB dual bank) */
Kojto 107:4f6c30876dfa 92 uint32_t WRPEndOffset; /*!< Write protection end offset (used for OPTIONBYTE_WRP).
Kojto 107:4f6c30876dfa 93 This parameter must be a value between WRPStartOffset and (max number of pages in the bank - 1) */
Kojto 107:4f6c30876dfa 94 uint32_t RDPLevel; /*!< Set the read protection level.. (used for OPTIONBYTE_RDP).
Kojto 107:4f6c30876dfa 95 This parameter can be a value of @ref FLASH_OB_Read_Protection */
Kojto 107:4f6c30876dfa 96 uint32_t USERType; /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).
Kojto 107:4f6c30876dfa 97 This parameter can be a combination of @ref FLASH_OB_USER_Type */
Kojto 107:4f6c30876dfa 98 uint32_t USERConfig; /*!< Value of the user option byte (used for OPTIONBYTE_USER).
Kojto 107:4f6c30876dfa 99 This parameter can be a combination of @ref FLASH_OB_USER_BOR_LEVEL,
Kojto 107:4f6c30876dfa 100 @ref FLASH_OB_USER_nRST_STOP, @ref FLASH_OB_USER_nRST_STANDBY,
Kojto 122:f9eeca106725 101 @ref FLASH_OB_USER_nRST_SHUTDOWN, @ref FLASH_OB_USER_IWDG_SW,
Kojto 122:f9eeca106725 102 @ref FLASH_OB_USER_IWDG_STOP, @ref FLASH_OB_USER_IWDG_STANDBY,
Kojto 122:f9eeca106725 103 @ref FLASH_OB_USER_WWDG_SW, @ref FLASH_OB_USER_BFB2,
Kojto 122:f9eeca106725 104 @ref FLASH_OB_USER_DUALBANK, @ref FLASH_OB_USER_nBOOT1,
Kojto 122:f9eeca106725 105 @ref FLASH_OB_USER_SRAM2_PE and @ref FLASH_OB_USER_SRAM2_RST */
Kojto 107:4f6c30876dfa 106 uint32_t PCROPConfig; /*!< Configuration of the PCROP (used for OPTIONBYTE_PCROP).
Kojto 107:4f6c30876dfa 107 This parameter must be a combination of @ref FLASH_Banks (except FLASH_BANK_BOTH)
Kojto 107:4f6c30876dfa 108 and @ref FLASH_OB_PCROP_RDP */
Kojto 107:4f6c30876dfa 109 uint32_t PCROPStartAddr; /*!< PCROP Start address (used for OPTIONBYTE_PCROP).
Kojto 107:4f6c30876dfa 110 This parameter must be a value between begin and end of bank
Kojto 107:4f6c30876dfa 111 => Be careful of the bank swapping for the address */
Kojto 107:4f6c30876dfa 112 uint32_t PCROPEndAddr; /*!< PCROP End address (used for OPTIONBYTE_PCROP).
Kojto 107:4f6c30876dfa 113 This parameter must be a value between PCROP Start address and end of bank */
Kojto 107:4f6c30876dfa 114 } FLASH_OBProgramInitTypeDef;
Kojto 107:4f6c30876dfa 115
Kojto 107:4f6c30876dfa 116 /**
Kojto 107:4f6c30876dfa 117 * @brief FLASH Procedure structure definition
Kojto 107:4f6c30876dfa 118 */
Kojto 107:4f6c30876dfa 119 typedef enum
Kojto 107:4f6c30876dfa 120 {
Kojto 107:4f6c30876dfa 121 FLASH_PROC_NONE = 0,
Kojto 107:4f6c30876dfa 122 FLASH_PROC_PAGE_ERASE,
Kojto 107:4f6c30876dfa 123 FLASH_PROC_MASS_ERASE,
Kojto 107:4f6c30876dfa 124 FLASH_PROC_PROGRAM,
Kojto 107:4f6c30876dfa 125 FLASH_PROC_PROGRAM_LAST
Kojto 107:4f6c30876dfa 126 } FLASH_ProcedureTypeDef;
Kojto 107:4f6c30876dfa 127
Kojto 107:4f6c30876dfa 128 /**
Kojto 107:4f6c30876dfa 129 * @brief FLASH handle Structure definition
Kojto 107:4f6c30876dfa 130 */
Kojto 107:4f6c30876dfa 131 typedef struct
Kojto 107:4f6c30876dfa 132 {
Kojto 107:4f6c30876dfa 133 HAL_LockTypeDef Lock; /* FLASH locking object */
Kojto 107:4f6c30876dfa 134 __IO uint32_t ErrorCode; /* FLASH error code */
Kojto 107:4f6c30876dfa 135 __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */
Kojto 107:4f6c30876dfa 136 __IO uint32_t Address; /* Internal variable to save address selected for program in IT context */
Kojto 107:4f6c30876dfa 137 __IO uint32_t Bank; /* Internal variable to save current bank selected during erase in IT context */
Kojto 107:4f6c30876dfa 138 __IO uint32_t Page; /* Internal variable to define the current page which is erasing in IT context */
Kojto 107:4f6c30876dfa 139 __IO uint32_t NbPagesToErase; /* Internal variable to save the remaining pages to erase in IT context */
Kojto 107:4f6c30876dfa 140 }FLASH_ProcessTypeDef;
Kojto 107:4f6c30876dfa 141
Kojto 107:4f6c30876dfa 142 /**
Kojto 107:4f6c30876dfa 143 * @}
Kojto 107:4f6c30876dfa 144 */
Kojto 107:4f6c30876dfa 145
Kojto 107:4f6c30876dfa 146 /* Exported constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 147 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
Kojto 107:4f6c30876dfa 148 * @{
Kojto 107:4f6c30876dfa 149 */
Kojto 107:4f6c30876dfa 150
Kojto 107:4f6c30876dfa 151 /** @defgroup FLASH_Error FLASH Error
Kojto 107:4f6c30876dfa 152 * @{
Kojto 107:4f6c30876dfa 153 */
Kojto 107:4f6c30876dfa 154 #define HAL_FLASH_ERROR_NONE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 155 #define HAL_FLASH_ERROR_OP ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 156 #define HAL_FLASH_ERROR_PROG ((uint32_t)0x00000002)
Kojto 107:4f6c30876dfa 157 #define HAL_FLASH_ERROR_WRP ((uint32_t)0x00000004)
Kojto 107:4f6c30876dfa 158 #define HAL_FLASH_ERROR_PGA ((uint32_t)0x00000008)
Kojto 107:4f6c30876dfa 159 #define HAL_FLASH_ERROR_SIZ ((uint32_t)0x00000010)
Kojto 107:4f6c30876dfa 160 #define HAL_FLASH_ERROR_PGS ((uint32_t)0x00000020)
Kojto 107:4f6c30876dfa 161 #define HAL_FLASH_ERROR_MIS ((uint32_t)0x00000040)
Kojto 107:4f6c30876dfa 162 #define HAL_FLASH_ERROR_FAST ((uint32_t)0x00000080)
Kojto 107:4f6c30876dfa 163 #define HAL_FLASH_ERROR_RD ((uint32_t)0x00000100)
Kojto 107:4f6c30876dfa 164 #define HAL_FLASH_ERROR_OPTV ((uint32_t)0x00000200)
Kojto 107:4f6c30876dfa 165 #define HAL_FLASH_ERROR_ECCD ((uint32_t)0x00000400)
Kojto 122:f9eeca106725 166 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 167 #define HAL_FLASH_ERROR_PEMPTY ((uint32_t)0x00000800)
Kojto 122:f9eeca106725 168 #endif
Kojto 107:4f6c30876dfa 169 /**
Kojto 107:4f6c30876dfa 170 * @}
Kojto 107:4f6c30876dfa 171 */
Kojto 107:4f6c30876dfa 172
Kojto 107:4f6c30876dfa 173 /** @defgroup FLASH_Type_Erase FLASH Erase Type
Kojto 107:4f6c30876dfa 174 * @{
Kojto 107:4f6c30876dfa 175 */
Kojto 107:4f6c30876dfa 176 #define FLASH_TYPEERASE_PAGES ((uint32_t)0x00) /*!<Pages erase only*/
Kojto 107:4f6c30876dfa 177 #define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01) /*!<Flash mass erase activation*/
Kojto 107:4f6c30876dfa 178 /**
Kojto 107:4f6c30876dfa 179 * @}
Kojto 107:4f6c30876dfa 180 */
Kojto 107:4f6c30876dfa 181
Kojto 107:4f6c30876dfa 182 /** @defgroup FLASH_Banks FLASH Banks
Kojto 107:4f6c30876dfa 183 * @{
Kojto 107:4f6c30876dfa 184 */
Kojto 107:4f6c30876dfa 185 #define FLASH_BANK_1 ((uint32_t)0x01) /*!< Bank 1 */
Kojto 122:f9eeca106725 186 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 107:4f6c30876dfa 187 #define FLASH_BANK_2 ((uint32_t)0x02) /*!< Bank 2 */
Kojto 107:4f6c30876dfa 188 #define FLASH_BANK_BOTH ((uint32_t)(FLASH_BANK_1 | FLASH_BANK_2)) /*!< Bank1 and Bank2 */
Kojto 122:f9eeca106725 189 #else
Kojto 122:f9eeca106725 190 #define FLASH_BANK_BOTH ((uint32_t)(FLASH_BANK_1)) /*!< Bank 1 */
Kojto 122:f9eeca106725 191 #endif
Kojto 107:4f6c30876dfa 192 /**
Kojto 107:4f6c30876dfa 193 * @}
Kojto 107:4f6c30876dfa 194 */
Kojto 107:4f6c30876dfa 195
Kojto 107:4f6c30876dfa 196
Kojto 107:4f6c30876dfa 197 /** @defgroup FLASH_Type_Program FLASH Program Type
Kojto 107:4f6c30876dfa 198 * @{
Kojto 107:4f6c30876dfa 199 */
Kojto 107:4f6c30876dfa 200 #define FLASH_TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x00) /*!<Program a double-word (64-bit) at a specified address.*/
Kojto 107:4f6c30876dfa 201 #define FLASH_TYPEPROGRAM_FAST ((uint32_t)0x01) /*!<Fast program a 32 row double-word (64-bit) at a specified address.
Kojto 107:4f6c30876dfa 202 And another 32 row double-word (64-bit) will be programmed */
Kojto 107:4f6c30876dfa 203 #define FLASH_TYPEPROGRAM_FAST_AND_LAST ((uint32_t)0x02) /*!<Fast program a 32 row double-word (64-bit) at a specified address.
Kojto 107:4f6c30876dfa 204 And this is the last 32 row double-word (64-bit) programmed */
Kojto 107:4f6c30876dfa 205 /**
Kojto 107:4f6c30876dfa 206 * @}
Kojto 107:4f6c30876dfa 207 */
Kojto 107:4f6c30876dfa 208
Kojto 107:4f6c30876dfa 209 /** @defgroup FLASH_OB_Type FLASH Option Bytes Type
Kojto 107:4f6c30876dfa 210 * @{
Kojto 107:4f6c30876dfa 211 */
Kojto 107:4f6c30876dfa 212 #define OPTIONBYTE_WRP ((uint32_t)0x01) /*!< WRP option byte configuration */
Kojto 107:4f6c30876dfa 213 #define OPTIONBYTE_RDP ((uint32_t)0x02) /*!< RDP option byte configuration */
Kojto 107:4f6c30876dfa 214 #define OPTIONBYTE_USER ((uint32_t)0x04) /*!< USER option byte configuration */
Kojto 107:4f6c30876dfa 215 #define OPTIONBYTE_PCROP ((uint32_t)0x08) /*!< PCROP option byte configuration */
Kojto 107:4f6c30876dfa 216 /**
Kojto 107:4f6c30876dfa 217 * @}
Kojto 107:4f6c30876dfa 218 */
Kojto 107:4f6c30876dfa 219
Kojto 107:4f6c30876dfa 220 /** @defgroup FLASH_OB_WRP_Area FLASH WRP Area
Kojto 107:4f6c30876dfa 221 * @{
Kojto 107:4f6c30876dfa 222 */
Kojto 107:4f6c30876dfa 223 #define OB_WRPAREA_BANK1_AREAA ((uint32_t)0x00) /*!< Flash Bank 1 Area A */
Kojto 107:4f6c30876dfa 224 #define OB_WRPAREA_BANK1_AREAB ((uint32_t)0x01) /*!< Flash Bank 1 Area B */
Kojto 122:f9eeca106725 225 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 107:4f6c30876dfa 226 #define OB_WRPAREA_BANK2_AREAA ((uint32_t)0x02) /*!< Flash Bank 2 Area A */
Kojto 107:4f6c30876dfa 227 #define OB_WRPAREA_BANK2_AREAB ((uint32_t)0x04) /*!< Flash Bank 2 Area B */
Kojto 122:f9eeca106725 228 #endif
Kojto 107:4f6c30876dfa 229 /**
Kojto 107:4f6c30876dfa 230 * @}
Kojto 107:4f6c30876dfa 231 */
Kojto 107:4f6c30876dfa 232
Kojto 107:4f6c30876dfa 233 /** @defgroup FLASH_OB_Read_Protection FLASH Option Bytes Read Protection
Kojto 107:4f6c30876dfa 234 * @{
Kojto 107:4f6c30876dfa 235 */
Kojto 107:4f6c30876dfa 236 #define OB_RDP_LEVEL_0 ((uint32_t)0xAA)
Kojto 107:4f6c30876dfa 237 #define OB_RDP_LEVEL_1 ((uint32_t)0xBB)
Kojto 107:4f6c30876dfa 238 #define OB_RDP_LEVEL_2 ((uint32_t)0xCC) /*!< Warning: When enabling read protection level 2
Kojto 107:4f6c30876dfa 239 it's no more possible to go back to level 1 or 0 */
Kojto 107:4f6c30876dfa 240 /**
Kojto 107:4f6c30876dfa 241 * @}
Kojto 107:4f6c30876dfa 242 */
Kojto 107:4f6c30876dfa 243
Kojto 107:4f6c30876dfa 244 /** @defgroup FLASH_OB_USER_Type FLASH Option Bytes User Type
Kojto 107:4f6c30876dfa 245 * @{
Kojto 107:4f6c30876dfa 246 */
Kojto 122:f9eeca106725 247 #define OB_USER_BOR_LEV ((uint32_t)0x0001) /*!< BOR reset Level */
Kojto 122:f9eeca106725 248 #define OB_USER_nRST_STOP ((uint32_t)0x0002) /*!< Reset generated when entering the stop mode */
Kojto 122:f9eeca106725 249 #define OB_USER_nRST_STDBY ((uint32_t)0x0004) /*!< Reset generated when entering the standby mode */
Kojto 122:f9eeca106725 250 #define OB_USER_IWDG_SW ((uint32_t)0x0008) /*!< Independent watchdog selection */
Kojto 122:f9eeca106725 251 #define OB_USER_IWDG_STOP ((uint32_t)0x0010) /*!< Independent watchdog counter freeze in stop mode */
Kojto 122:f9eeca106725 252 #define OB_USER_IWDG_STDBY ((uint32_t)0x0020) /*!< Independent watchdog counter freeze in standby mode */
Kojto 122:f9eeca106725 253 #define OB_USER_WWDG_SW ((uint32_t)0x0040) /*!< Window watchdog selection */
Kojto 122:f9eeca106725 254 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 255 #define OB_USER_BFB2 ((uint32_t)0x0080) /*!< Dual-bank boot */
Kojto 122:f9eeca106725 256 #define OB_USER_DUALBANK ((uint32_t)0x0100) /*!< Dual-Bank on 512KB or 256KB Flash memory devices */
Kojto 122:f9eeca106725 257 #endif
Kojto 122:f9eeca106725 258 #define OB_USER_nBOOT1 ((uint32_t)0x0200) /*!< Boot configuration */
Kojto 122:f9eeca106725 259 #define OB_USER_SRAM2_PE ((uint32_t)0x0400) /*!< SRAM2 parity check enable */
Kojto 122:f9eeca106725 260 #define OB_USER_SRAM2_RST ((uint32_t)0x0800) /*!< SRAM2 Erase when system reset */
Kojto 122:f9eeca106725 261 #define OB_USER_nRST_SHDW ((uint32_t)0x1000) /*!< Reset generated when entering the shutdown mode */
Kojto 122:f9eeca106725 262 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 263 #define OB_USER_nSWBOOT0 ((uint32_t)0x2000) /*!< Software BOOT0 */
Kojto 122:f9eeca106725 264 #define OB_USER_nBOOT0 ((uint32_t)0x4000) /*!< nBOOT0 option bit */
Kojto 122:f9eeca106725 265 #endif
Kojto 107:4f6c30876dfa 266 /**
Kojto 107:4f6c30876dfa 267 * @}
Kojto 107:4f6c30876dfa 268 */
Kojto 107:4f6c30876dfa 269
Kojto 107:4f6c30876dfa 270 /** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes User BOR Level
Kojto 107:4f6c30876dfa 271 * @{
Kojto 107:4f6c30876dfa 272 */
Kojto 122:f9eeca106725 273 #define OB_BOR_LEVEL_0 ((uint32_t)FLASH_OPTR_BOR_LEV_0) /*!< Reset level threshold is around 1.7V */
Kojto 122:f9eeca106725 274 #define OB_BOR_LEVEL_1 ((uint32_t)FLASH_OPTR_BOR_LEV_1) /*!< Reset level threshold is around 2.0V */
Kojto 122:f9eeca106725 275 #define OB_BOR_LEVEL_2 ((uint32_t)FLASH_OPTR_BOR_LEV_2) /*!< Reset level threshold is around 2.2V */
Kojto 122:f9eeca106725 276 #define OB_BOR_LEVEL_3 ((uint32_t)FLASH_OPTR_BOR_LEV_3) /*!< Reset level threshold is around 2.5V */
Kojto 122:f9eeca106725 277 #define OB_BOR_LEVEL_4 ((uint32_t)FLASH_OPTR_BOR_LEV_4) /*!< Reset level threshold is around 2.8V */
Kojto 107:4f6c30876dfa 278 /**
Kojto 107:4f6c30876dfa 279 * @}
Kojto 107:4f6c30876dfa 280 */
Kojto 107:4f6c30876dfa 281
Kojto 107:4f6c30876dfa 282 /** @defgroup FLASH_OB_USER_nRST_STOP FLASH Option Bytes User Reset On Stop
Kojto 107:4f6c30876dfa 283 * @{
Kojto 107:4f6c30876dfa 284 */
Kojto 122:f9eeca106725 285 #define OB_STOP_RST ((uint32_t)0x0000) /*!< Reset generated when entering the stop mode */
Kojto 122:f9eeca106725 286 #define OB_STOP_NORST ((uint32_t)FLASH_OPTR_nRST_STOP) /*!< No reset generated when entering the stop mode */
Kojto 107:4f6c30876dfa 287 /**
Kojto 107:4f6c30876dfa 288 * @}
Kojto 107:4f6c30876dfa 289 */
Kojto 107:4f6c30876dfa 290
Kojto 107:4f6c30876dfa 291 /** @defgroup FLASH_OB_USER_nRST_STANDBY FLASH Option Bytes User Reset On Standby
Kojto 107:4f6c30876dfa 292 * @{
Kojto 107:4f6c30876dfa 293 */
Kojto 122:f9eeca106725 294 #define OB_STANDBY_RST ((uint32_t)0x0000) /*!< Reset generated when entering the standby mode */
Kojto 122:f9eeca106725 295 #define OB_STANDBY_NORST ((uint32_t)FLASH_OPTR_nRST_STDBY) /*!< No reset generated when entering the standby mode */
Kojto 122:f9eeca106725 296 /**
Kojto 122:f9eeca106725 297 * @}
Kojto 122:f9eeca106725 298 */
Kojto 122:f9eeca106725 299
Kojto 122:f9eeca106725 300 /** @defgroup FLASH_OB_USER_nRST_SHUTDOWN FLASH Option Bytes User Reset On Shutdown
Kojto 122:f9eeca106725 301 * @{
Kojto 122:f9eeca106725 302 */
Kojto 122:f9eeca106725 303 #define OB_SHUTDOWN_RST ((uint32_t)0x0000) /*!< Reset generated when entering the shutdown mode */
Kojto 122:f9eeca106725 304 #define OB_SHUTDOWN_NORST ((uint32_t)FLASH_OPTR_nRST_SHDW) /*!< No reset generated when entering the shutdown mode */
Kojto 107:4f6c30876dfa 305 /**
Kojto 107:4f6c30876dfa 306 * @}
Kojto 107:4f6c30876dfa 307 */
Kojto 107:4f6c30876dfa 308
Kojto 107:4f6c30876dfa 309 /** @defgroup FLASH_OB_USER_IWDG_SW FLASH Option Bytes User IWDG Type
Kojto 107:4f6c30876dfa 310 * @{
Kojto 107:4f6c30876dfa 311 */
Kojto 122:f9eeca106725 312 #define OB_IWDG_HW ((uint32_t)0x00000) /*!< Hardware independent watchdog */
Kojto 122:f9eeca106725 313 #define OB_IWDG_SW ((uint32_t)FLASH_OPTR_IWDG_SW) /*!< Software independent watchdog */
Kojto 107:4f6c30876dfa 314 /**
Kojto 107:4f6c30876dfa 315 * @}
Kojto 107:4f6c30876dfa 316 */
Kojto 107:4f6c30876dfa 317
Kojto 107:4f6c30876dfa 318 /** @defgroup FLASH_OB_USER_IWDG_STOP FLASH Option Bytes User IWDG Mode On Stop
Kojto 107:4f6c30876dfa 319 * @{
Kojto 107:4f6c30876dfa 320 */
Kojto 122:f9eeca106725 321 #define OB_IWDG_STOP_FREEZE ((uint32_t)0x00000) /*!< Independent watchdog counter is frozen in Stop mode */
Kojto 122:f9eeca106725 322 #define OB_IWDG_STOP_RUN ((uint32_t)FLASH_OPTR_IWDG_STOP) /*!< Independent watchdog counter is running in Stop mode */
Kojto 107:4f6c30876dfa 323 /**
Kojto 107:4f6c30876dfa 324 * @}
Kojto 107:4f6c30876dfa 325 */
Kojto 107:4f6c30876dfa 326
Kojto 107:4f6c30876dfa 327 /** @defgroup FLASH_OB_USER_IWDG_STANDBY FLASH Option Bytes User IWDG Mode On Standby
Kojto 107:4f6c30876dfa 328 * @{
Kojto 107:4f6c30876dfa 329 */
Kojto 122:f9eeca106725 330 #define OB_IWDG_STDBY_FREEZE ((uint32_t)0x00000) /*!< Independent watchdog counter is frozen in Standby mode */
Kojto 122:f9eeca106725 331 #define OB_IWDG_STDBY_RUN ((uint32_t)FLASH_OPTR_IWDG_STDBY) /*!< Independent watchdog counter is running in Standby mode */
Kojto 107:4f6c30876dfa 332 /**
Kojto 107:4f6c30876dfa 333 * @}
Kojto 107:4f6c30876dfa 334 */
Kojto 107:4f6c30876dfa 335
Kojto 107:4f6c30876dfa 336 /** @defgroup FLASH_OB_USER_WWDG_SW FLASH Option Bytes User WWDG Type
Kojto 107:4f6c30876dfa 337 * @{
Kojto 107:4f6c30876dfa 338 */
Kojto 122:f9eeca106725 339 #define OB_WWDG_HW ((uint32_t)0x00000) /*!< Hardware window watchdog */
Kojto 122:f9eeca106725 340 #define OB_WWDG_SW ((uint32_t)FLASH_OPTR_WWDG_SW) /*!< Software window watchdog */
Kojto 107:4f6c30876dfa 341 /**
Kojto 107:4f6c30876dfa 342 * @}
Kojto 107:4f6c30876dfa 343 */
Kojto 107:4f6c30876dfa 344
Kojto 122:f9eeca106725 345 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 107:4f6c30876dfa 346 /** @defgroup FLASH_OB_USER_BFB2 FLASH Option Bytes User BFB2 Mode
Kojto 107:4f6c30876dfa 347 * @{
Kojto 107:4f6c30876dfa 348 */
Kojto 122:f9eeca106725 349 #define OB_BFB2_DISABLE ((uint32_t)0x000000) /*!< Dual-bank boot disable */
Kojto 122:f9eeca106725 350 #define OB_BFB2_ENABLE ((uint32_t)FLASH_OPTR_BFB2) /*!< Dual-bank boot enable */
Kojto 107:4f6c30876dfa 351 /**
Kojto 107:4f6c30876dfa 352 * @}
Kojto 107:4f6c30876dfa 353 */
Kojto 107:4f6c30876dfa 354
Kojto 107:4f6c30876dfa 355 /** @defgroup FLASH_OB_USER_DUALBANK FLASH Option Bytes User Dual-bank Type
Kojto 107:4f6c30876dfa 356 * @{
Kojto 107:4f6c30876dfa 357 */
Kojto 122:f9eeca106725 358 #define OB_DUALBANK_SINGLE ((uint32_t)0x000000) /*!< 256 KB/512 KB Single-bank Flash */
Kojto 122:f9eeca106725 359 #define OB_DUALBANK_DUAL ((uint32_t)FLASH_OPTR_DUALBANK) /*!< 256 KB/512 KB Dual-bank Flash */
Kojto 107:4f6c30876dfa 360 /**
Kojto 107:4f6c30876dfa 361 * @}
Kojto 107:4f6c30876dfa 362 */
Kojto 122:f9eeca106725 363 #endif
Kojto 107:4f6c30876dfa 364
Kojto 107:4f6c30876dfa 365 /** @defgroup FLASH_OB_USER_nBOOT1 FLASH Option Bytes User BOOT1 Type
Kojto 107:4f6c30876dfa 366 * @{
Kojto 107:4f6c30876dfa 367 */
Kojto 122:f9eeca106725 368 #define OB_BOOT1_SRAM ((uint32_t)0x000000) /*!< Embedded SRAM1 is selected as boot space (if BOOT0=1) */
Kojto 122:f9eeca106725 369 #define OB_BOOT1_SYSTEM ((uint32_t)FLASH_OPTR_nBOOT1) /*!< System memory is selected as boot space (if BOOT0=1) */
Kojto 107:4f6c30876dfa 370 /**
Kojto 107:4f6c30876dfa 371 * @}
Kojto 107:4f6c30876dfa 372 */
Kojto 107:4f6c30876dfa 373
Kojto 107:4f6c30876dfa 374 /** @defgroup FLASH_OB_USER_SRAM2_PE FLASH Option Bytes User SRAM2 Parity Check Type
Kojto 107:4f6c30876dfa 375 * @{
Kojto 107:4f6c30876dfa 376 */
Kojto 122:f9eeca106725 377 #define OB_SRAM2_PARITY_ENABLE ((uint32_t)0x0000000) /*!< SRAM2 parity check enable */
Kojto 122:f9eeca106725 378 #define OB_SRAM2_PARITY_DISABLE ((uint32_t)FLASH_OPTR_SRAM2_PE) /*!< SRAM2 parity check disable */
Kojto 107:4f6c30876dfa 379 /**
Kojto 107:4f6c30876dfa 380 * @}
Kojto 107:4f6c30876dfa 381 */
Kojto 107:4f6c30876dfa 382
Kojto 107:4f6c30876dfa 383 /** @defgroup FLASH_OB_USER_SRAM2_RST FLASH Option Bytes User SRAM2 Erase On Reset Type
Kojto 107:4f6c30876dfa 384 * @{
Kojto 107:4f6c30876dfa 385 */
Kojto 122:f9eeca106725 386 #define OB_SRAM2_RST_ERASE ((uint32_t)0x0000000) /*!< SRAM2 erased when a system reset occurs */
Kojto 122:f9eeca106725 387 #define OB_SRAM2_RST_NOT_ERASE ((uint32_t)FLASH_OPTR_SRAM2_RST) /*!< SRAM2 is not erased when a system reset occurs */
Kojto 122:f9eeca106725 388 /**
Kojto 122:f9eeca106725 389 * @}
Kojto 122:f9eeca106725 390 */
Kojto 122:f9eeca106725 391
Kojto 122:f9eeca106725 392 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 393 /** @defgroup OB_USER_nSWBOOT0 FLASH Option Bytes User Software BOOT0
Kojto 122:f9eeca106725 394 * @{
Kojto 122:f9eeca106725 395 */
Kojto 122:f9eeca106725 396 #define OB_BOOT0_FROM_OB ((uint32_t)0x0000000) /*!< BOOT0 taken from the option bit nBOOT0 */
Kojto 122:f9eeca106725 397 #define OB_BOOT0_FROM_PIN ((uint32_t)FLASH_OPTR_nSWBOOT0) /*!< BOOT0 taken from PH3/BOOT0 pin */
Kojto 107:4f6c30876dfa 398 /**
Kojto 107:4f6c30876dfa 399 * @}
Kojto 107:4f6c30876dfa 400 */
Kojto 107:4f6c30876dfa 401
Kojto 122:f9eeca106725 402 /** @defgroup OB_USER_nBOOT0 FLASH Option Bytes User nBOOT0 option bit
Kojto 122:f9eeca106725 403 * @{
Kojto 122:f9eeca106725 404 */
Kojto 122:f9eeca106725 405 #define OB_BOOT0_RESET ((uint32_t)0x0000000) /*!< nBOOT0 = 0 */
Kojto 122:f9eeca106725 406 #define OB_BOOT0_SET ((uint32_t)FLASH_OPTR_nBOOT0) /*!< nBOOT0 = 1 */
Kojto 122:f9eeca106725 407 /**
Kojto 122:f9eeca106725 408 * @}
Kojto 122:f9eeca106725 409 */
Kojto 122:f9eeca106725 410 #endif
Kojto 122:f9eeca106725 411
Kojto 107:4f6c30876dfa 412 /** @defgroup FLASH_OB_PCROP_RDP FLASH Option Bytes PCROP On RDP Level Type
Kojto 107:4f6c30876dfa 413 * @{
Kojto 107:4f6c30876dfa 414 */
Kojto 122:f9eeca106725 415 #define OB_PCROP_RDP_NOT_ERASE ((uint32_t)0x00000000) /*!< PCROP area is not erased when the RDP level
Kojto 122:f9eeca106725 416 is decreased from Level 1 to Level 0 */
Kojto 122:f9eeca106725 417 #define OB_PCROP_RDP_ERASE ((uint32_t)FLASH_PCROP1ER_PCROP_RDP) /*!< PCROP area is erased when the RDP level is
Kojto 122:f9eeca106725 418 decreased from Level 1 to Level 0 (full mass erase) */
Kojto 107:4f6c30876dfa 419 /**
Kojto 107:4f6c30876dfa 420 * @}
Kojto 107:4f6c30876dfa 421 */
Kojto 107:4f6c30876dfa 422
Kojto 107:4f6c30876dfa 423 /** @defgroup FLASH_Latency FLASH Latency
Kojto 107:4f6c30876dfa 424 * @{
Kojto 107:4f6c30876dfa 425 */
Kojto 122:f9eeca106725 426 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero wait state */
Kojto 122:f9eeca106725 427 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One wait state */
Kojto 122:f9eeca106725 428 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two wait states */
Kojto 122:f9eeca106725 429 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three wait states */
Kojto 122:f9eeca106725 430 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four wait states */
Kojto 107:4f6c30876dfa 431 /**
Kojto 107:4f6c30876dfa 432 * @}
Kojto 107:4f6c30876dfa 433 */
Kojto 107:4f6c30876dfa 434
Kojto 107:4f6c30876dfa 435 /** @defgroup FLASH_Keys FLASH Keys
Kojto 107:4f6c30876dfa 436 * @{
Kojto 107:4f6c30876dfa 437 */
Kojto 122:f9eeca106725 438 #define FLASH_KEY1 ((uint32_t)0x45670123U) /*!< Flash key1 */
Kojto 122:f9eeca106725 439 #define FLASH_KEY2 ((uint32_t)0xCDEF89ABU) /*!< Flash key2: used with FLASH_KEY1
Kojto 122:f9eeca106725 440 to unlock the FLASH registers access */
Kojto 107:4f6c30876dfa 441
Kojto 122:f9eeca106725 442 #define FLASH_PDKEY1 ((uint32_t)0x04152637U) /*!< Flash power down key1 */
Kojto 122:f9eeca106725 443 #define FLASH_PDKEY2 ((uint32_t)0xFAFBFCFDU) /*!< Flash power down key2: used with FLASH_PDKEY1
Kojto 122:f9eeca106725 444 to unlock the RUN_PD bit in FLASH_ACR */
Kojto 107:4f6c30876dfa 445
Kojto 122:f9eeca106725 446 #define FLASH_OPTKEY1 ((uint32_t)0x08192A3BU) /*!< Flash option byte key1 */
Kojto 122:f9eeca106725 447 #define FLASH_OPTKEY2 ((uint32_t)0x4C5D6E7FU) /*!< Flash option byte key2: used with FLASH_OPTKEY1
Kojto 122:f9eeca106725 448 to allow option bytes operations */
Kojto 107:4f6c30876dfa 449 /**
Kojto 107:4f6c30876dfa 450 * @}
Kojto 107:4f6c30876dfa 451 */
Kojto 107:4f6c30876dfa 452
Kojto 107:4f6c30876dfa 453 /** @defgroup FLASH_Flags FLASH Flags Definition
Kojto 107:4f6c30876dfa 454 * @{
Kojto 107:4f6c30876dfa 455 */
Kojto 122:f9eeca106725 456 #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of operation flag */
Kojto 122:f9eeca106725 457 #define FLASH_FLAG_OPERR FLASH_SR_OPERR /*!< FLASH Operation error flag */
Kojto 122:f9eeca106725 458 #define FLASH_FLAG_PROGERR FLASH_SR_PROGERR /*!< FLASH Programming error flag */
Kojto 122:f9eeca106725 459 #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protection error flag */
Kojto 122:f9eeca106725 460 #define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming alignment error flag */
Kojto 122:f9eeca106725 461 #define FLASH_FLAG_SIZERR FLASH_SR_SIZERR /*!< FLASH Size error flag */
Kojto 122:f9eeca106725 462 #define FLASH_FLAG_PGSERR FLASH_SR_PGSERR /*!< FLASH Programming sequence error flag */
Kojto 122:f9eeca106725 463 #define FLASH_FLAG_MISERR FLASH_SR_MISERR /*!< FLASH Fast programming data miss error flag */
Kojto 122:f9eeca106725 464 #define FLASH_FLAG_FASTERR FLASH_SR_FASTERR /*!< FLASH Fast programming error flag */
Kojto 122:f9eeca106725 465 #define FLASH_FLAG_RDERR FLASH_SR_RDERR /*!< FLASH PCROP read error flag */
Kojto 122:f9eeca106725 466 #define FLASH_FLAG_OPTVERR FLASH_SR_OPTVERR /*!< FLASH Option validity error flag */
Kojto 122:f9eeca106725 467 #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */
Kojto 122:f9eeca106725 468 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 469 #define FLASH_FLAG_PEMPTY FLASH_SR_PEMPTY /*!< FLASH Program empty */
Kojto 122:f9eeca106725 470 #endif
Kojto 122:f9eeca106725 471 #define FLASH_FLAG_ECCC FLASH_ECCR_ECCC /*!< FLASH ECC correction */
Kojto 122:f9eeca106725 472 #define FLASH_FLAG_ECCD FLASH_ECCR_ECCD /*!< FLASH ECC detection */
Kojto 107:4f6c30876dfa 473
Kojto 107:4f6c30876dfa 474 #define FLASH_FLAG_ALL_ERRORS (FLASH_FLAG_OPERR | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \
Kojto 107:4f6c30876dfa 475 FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_PGSERR | \
Kojto 107:4f6c30876dfa 476 FLASH_FLAG_MISERR | FLASH_FLAG_FASTERR | FLASH_FLAG_RDERR | \
Kojto 107:4f6c30876dfa 477 FLASH_FLAG_OPTVERR | FLASH_FLAG_ECCD)
Kojto 107:4f6c30876dfa 478 /**
Kojto 107:4f6c30876dfa 479 * @}
Kojto 107:4f6c30876dfa 480 */
Kojto 107:4f6c30876dfa 481
Kojto 107:4f6c30876dfa 482 /** @defgroup FLASH_Interrupt_definition FLASH Interrupts Definition
Kojto 107:4f6c30876dfa 483 * @brief FLASH Interrupt definition
Kojto 107:4f6c30876dfa 484 * @{
Kojto 107:4f6c30876dfa 485 */
Kojto 122:f9eeca106725 486 #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */
Kojto 122:f9eeca106725 487 #define FLASH_IT_OPERR FLASH_CR_ERRIE /*!< Error Interrupt source */
Kojto 122:f9eeca106725 488 #define FLASH_IT_RDERR FLASH_CR_RDERRIE /*!< PCROP Read Error Interrupt source*/
Kojto 122:f9eeca106725 489 #define FLASH_IT_ECCC (FLASH_ECCR_ECCIE >> 24) /*!< ECC Correction Interrupt source */
Kojto 107:4f6c30876dfa 490 /**
Kojto 107:4f6c30876dfa 491 * @}
Kojto 107:4f6c30876dfa 492 */
Kojto 107:4f6c30876dfa 493
Kojto 107:4f6c30876dfa 494 /**
Kojto 107:4f6c30876dfa 495 * @}
Kojto 107:4f6c30876dfa 496 */
Kojto 107:4f6c30876dfa 497
Kojto 107:4f6c30876dfa 498 /* Exported macros -----------------------------------------------------------*/
Kojto 107:4f6c30876dfa 499 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
Kojto 107:4f6c30876dfa 500 * @brief macros to control FLASH features
Kojto 107:4f6c30876dfa 501 * @{
Kojto 107:4f6c30876dfa 502 */
Kojto 107:4f6c30876dfa 503
Kojto 107:4f6c30876dfa 504 /**
Kojto 107:4f6c30876dfa 505 * @brief Set the FLASH Latency.
Kojto 107:4f6c30876dfa 506 * @param __LATENCY__: FLASH Latency
Kojto 107:4f6c30876dfa 507 * This parameter can be one of the following values :
Kojto 107:4f6c30876dfa 508 * @arg FLASH_LATENCY_0: FLASH Zero wait state
Kojto 107:4f6c30876dfa 509 * @arg FLASH_LATENCY_1: FLASH One wait state
Kojto 107:4f6c30876dfa 510 * @arg FLASH_LATENCY_2: FLASH Two wait states
Kojto 107:4f6c30876dfa 511 * @arg FLASH_LATENCY_3: FLASH Three wait states
Kojto 107:4f6c30876dfa 512 * @arg FLASH_LATENCY_4: FLASH Four wait states
Kojto 107:4f6c30876dfa 513 * @retval None
Kojto 107:4f6c30876dfa 514 */
Kojto 122:f9eeca106725 515 #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (__LATENCY__)))
Kojto 107:4f6c30876dfa 516
Kojto 107:4f6c30876dfa 517 /**
Kojto 107:4f6c30876dfa 518 * @brief Get the FLASH Latency.
Kojto 107:4f6c30876dfa 519 * @retval FLASH Latency
Kojto 107:4f6c30876dfa 520 * This parameter can be one of the following values :
Kojto 107:4f6c30876dfa 521 * @arg FLASH_LATENCY_0: FLASH Zero wait state
Kojto 107:4f6c30876dfa 522 * @arg FLASH_LATENCY_1: FLASH One wait state
Kojto 107:4f6c30876dfa 523 * @arg FLASH_LATENCY_2: FLASH Two wait states
Kojto 107:4f6c30876dfa 524 * @arg FLASH_LATENCY_3: FLASH Three wait states
Kojto 107:4f6c30876dfa 525 * @arg FLASH_LATENCY_4: FLASH Four wait states
Kojto 107:4f6c30876dfa 526 */
Kojto 107:4f6c30876dfa 527 #define __HAL_FLASH_GET_LATENCY() READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY)
Kojto 107:4f6c30876dfa 528
Kojto 107:4f6c30876dfa 529 /**
Kojto 107:4f6c30876dfa 530 * @brief Enable the FLASH prefetch buffer.
Kojto 107:4f6c30876dfa 531 * @retval None
Kojto 107:4f6c30876dfa 532 */
Kojto 107:4f6c30876dfa 533 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_PRFTEN)
Kojto 107:4f6c30876dfa 534
Kojto 107:4f6c30876dfa 535 /**
Kojto 107:4f6c30876dfa 536 * @brief Disable the FLASH prefetch buffer.
Kojto 107:4f6c30876dfa 537 * @retval None
Kojto 107:4f6c30876dfa 538 */
Kojto 107:4f6c30876dfa 539 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_PRFTEN)
Kojto 107:4f6c30876dfa 540
Kojto 107:4f6c30876dfa 541 /**
Kojto 107:4f6c30876dfa 542 * @brief Enable the FLASH instruction cache.
Kojto 107:4f6c30876dfa 543 * @retval none
Kojto 107:4f6c30876dfa 544 */
Kojto 107:4f6c30876dfa 545 #define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_ICEN)
Kojto 107:4f6c30876dfa 546
Kojto 107:4f6c30876dfa 547 /**
Kojto 107:4f6c30876dfa 548 * @brief Disable the FLASH instruction cache.
Kojto 107:4f6c30876dfa 549 * @retval none
Kojto 107:4f6c30876dfa 550 */
Kojto 107:4f6c30876dfa 551 #define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICEN)
Kojto 107:4f6c30876dfa 552
Kojto 107:4f6c30876dfa 553 /**
Kojto 107:4f6c30876dfa 554 * @brief Enable the FLASH data cache.
Kojto 107:4f6c30876dfa 555 * @retval none
Kojto 107:4f6c30876dfa 556 */
Kojto 107:4f6c30876dfa 557 #define __HAL_FLASH_DATA_CACHE_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_DCEN)
Kojto 107:4f6c30876dfa 558
Kojto 107:4f6c30876dfa 559 /**
Kojto 107:4f6c30876dfa 560 * @brief Disable the FLASH data cache.
Kojto 107:4f6c30876dfa 561 * @retval none
Kojto 107:4f6c30876dfa 562 */
Kojto 107:4f6c30876dfa 563 #define __HAL_FLASH_DATA_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCEN)
Kojto 107:4f6c30876dfa 564
Kojto 107:4f6c30876dfa 565 /**
Kojto 107:4f6c30876dfa 566 * @brief Reset the FLASH instruction Cache.
Kojto 107:4f6c30876dfa 567 * @note This function must be used only when the Instruction Cache is disabled.
Kojto 107:4f6c30876dfa 568 * @retval None
Kojto 107:4f6c30876dfa 569 */
Kojto 122:f9eeca106725 570 #define __HAL_FLASH_INSTRUCTION_CACHE_RESET() do { SET_BIT(FLASH->ACR, FLASH_ACR_ICRST); \
Kojto 122:f9eeca106725 571 CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICRST); \
Kojto 122:f9eeca106725 572 } while (0)
Kojto 107:4f6c30876dfa 573
Kojto 107:4f6c30876dfa 574 /**
Kojto 107:4f6c30876dfa 575 * @brief Reset the FLASH data Cache.
Kojto 107:4f6c30876dfa 576 * @note This function must be used only when the data Cache is disabled.
Kojto 107:4f6c30876dfa 577 * @retval None
Kojto 107:4f6c30876dfa 578 */
Kojto 122:f9eeca106725 579 #define __HAL_FLASH_DATA_CACHE_RESET() do { SET_BIT(FLASH->ACR, FLASH_ACR_DCRST); \
Kojto 122:f9eeca106725 580 CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCRST); \
Kojto 122:f9eeca106725 581 } while (0)
Kojto 107:4f6c30876dfa 582
Kojto 107:4f6c30876dfa 583 /**
Kojto 107:4f6c30876dfa 584 * @brief Enable the FLASH power down during Low-power run mode.
Kojto 107:4f6c30876dfa 585 * @note Writing this bit to 0 this bit, automatically the keys are
Kojto 107:4f6c30876dfa 586 * loss and a new unlock sequence is necessary to re-write it to 1.
Kojto 107:4f6c30876dfa 587 */
Kojto 107:4f6c30876dfa 588 #define __HAL_FLASH_POWER_DOWN_ENABLE() do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \
Kojto 107:4f6c30876dfa 589 WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \
Kojto 107:4f6c30876dfa 590 SET_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \
Kojto 107:4f6c30876dfa 591 } while (0)
Kojto 107:4f6c30876dfa 592
Kojto 107:4f6c30876dfa 593 /**
Kojto 107:4f6c30876dfa 594 * @brief Disable the FLASH power down during Low-power run mode.
Kojto 107:4f6c30876dfa 595 * @note Writing this bit to 0 this bit, automatically the keys are
Kojto 107:4f6c30876dfa 596 * loss and a new unlock sequence is necessary to re-write it to 1.
Kojto 107:4f6c30876dfa 597 */
Kojto 107:4f6c30876dfa 598 #define __HAL_FLASH_POWER_DOWN_DISABLE() do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \
Kojto 107:4f6c30876dfa 599 WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \
Kojto 107:4f6c30876dfa 600 CLEAR_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \
Kojto 107:4f6c30876dfa 601 } while (0)
Kojto 107:4f6c30876dfa 602
Kojto 107:4f6c30876dfa 603 /**
Kojto 107:4f6c30876dfa 604 * @brief Enable the FLASH power down during Low-Power sleep mode
Kojto 107:4f6c30876dfa 605 * @retval none
Kojto 107:4f6c30876dfa 606 */
Kojto 107:4f6c30876dfa 607 #define __HAL_FLASH_SLEEP_POWERDOWN_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
Kojto 107:4f6c30876dfa 608
Kojto 107:4f6c30876dfa 609 /**
Kojto 107:4f6c30876dfa 610 * @brief Disable the FLASH power down during Low-Power sleep mode
Kojto 107:4f6c30876dfa 611 * @retval none
Kojto 107:4f6c30876dfa 612 */
Kojto 107:4f6c30876dfa 613 #define __HAL_FLASH_SLEEP_POWERDOWN_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
Kojto 107:4f6c30876dfa 614
Kojto 107:4f6c30876dfa 615 /**
Kojto 107:4f6c30876dfa 616 * @}
Kojto 107:4f6c30876dfa 617 */
Kojto 107:4f6c30876dfa 618
Kojto 107:4f6c30876dfa 619 /** @defgroup FLASH_Interrupt FLASH Interrupts Macros
Kojto 107:4f6c30876dfa 620 * @brief macros to handle FLASH interrupts
Kojto 107:4f6c30876dfa 621 * @{
Kojto 107:4f6c30876dfa 622 */
Kojto 107:4f6c30876dfa 623
Kojto 107:4f6c30876dfa 624 /**
Kojto 107:4f6c30876dfa 625 * @brief Enable the specified FLASH interrupt.
Kojto 107:4f6c30876dfa 626 * @param __INTERRUPT__: FLASH interrupt
Kojto 107:4f6c30876dfa 627 * This parameter can be any combination of the following values:
Kojto 107:4f6c30876dfa 628 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
Kojto 107:4f6c30876dfa 629 * @arg FLASH_IT_OPERR: Error Interrupt
Kojto 107:4f6c30876dfa 630 * @arg FLASH_IT_RDERR: PCROP Read Error Interrupt
Kojto 107:4f6c30876dfa 631 * @arg FLASH_IT_ECCC: ECC Correction Interrupt
Kojto 107:4f6c30876dfa 632 * @retval none
Kojto 107:4f6c30876dfa 633 */
Kojto 107:4f6c30876dfa 634 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) do { if((__INTERRUPT__) & FLASH_IT_ECCC) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
Kojto 107:4f6c30876dfa 635 if((__INTERRUPT__) & (~FLASH_IT_ECCC)) { SET_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
Kojto 107:4f6c30876dfa 636 } while(0)
Kojto 107:4f6c30876dfa 637
Kojto 107:4f6c30876dfa 638 /**
Kojto 107:4f6c30876dfa 639 * @brief Disable the specified FLASH interrupt.
Kojto 107:4f6c30876dfa 640 * @param __INTERRUPT__: FLASH interrupt
Kojto 107:4f6c30876dfa 641 * This parameter can be any combination of the following values:
Kojto 107:4f6c30876dfa 642 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
Kojto 107:4f6c30876dfa 643 * @arg FLASH_IT_OPERR: Error Interrupt
Kojto 107:4f6c30876dfa 644 * @arg FLASH_IT_RDERR: PCROP Read Error Interrupt
Kojto 107:4f6c30876dfa 645 * @arg FLASH_IT_ECCC: ECC Correction Interrupt
Kojto 107:4f6c30876dfa 646 * @retval none
Kojto 107:4f6c30876dfa 647 */
Kojto 107:4f6c30876dfa 648 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) do { if((__INTERRUPT__) & FLASH_IT_ECCC) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
Kojto 107:4f6c30876dfa 649 if((__INTERRUPT__) & (~FLASH_IT_ECCC)) { CLEAR_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
Kojto 107:4f6c30876dfa 650 } while(0)
Kojto 107:4f6c30876dfa 651
Kojto 107:4f6c30876dfa 652 /**
Kojto 107:4f6c30876dfa 653 * @brief Check whether the specified FLASH flag is set or not.
Kojto 107:4f6c30876dfa 654 * @param __FLAG__: specifies the FLASH flag to check.
Kojto 107:4f6c30876dfa 655 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 656 * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
Kojto 107:4f6c30876dfa 657 * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
Kojto 107:4f6c30876dfa 658 * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
Kojto 107:4f6c30876dfa 659 * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
Kojto 107:4f6c30876dfa 660 * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
Kojto 107:4f6c30876dfa 661 * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
Kojto 107:4f6c30876dfa 662 * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
Kojto 107:4f6c30876dfa 663 * @arg FLASH_FLAG_MISERR: FLASH Fast programming data miss error flag
Kojto 107:4f6c30876dfa 664 * @arg FLASH_FLAG_FASTERR: FLASH Fast programming error flag
Kojto 107:4f6c30876dfa 665 * @arg FLASH_FLAG_RDERR: FLASH PCROP read error flag
Kojto 107:4f6c30876dfa 666 * @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag
Kojto 107:4f6c30876dfa 667 * @arg FLASH_FLAG_BSY: FLASH write/erase operations in progress flag
Kojto 122:f9eeca106725 668 * @arg FLASH_FLAG_PEMPTY : FLASH Boot from not programmed flash (apply only for STM32L43x/STM32L44x devices)
Kojto 107:4f6c30876dfa 669 * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
Kojto 107:4f6c30876dfa 670 * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
Kojto 107:4f6c30876dfa 671 * @retval The new state of FLASH_FLAG (SET or RESET).
Kojto 107:4f6c30876dfa 672 */
Kojto 107:4f6c30876dfa 673 #define __HAL_FLASH_GET_FLAG(__FLAG__) (((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) ? \
Kojto 107:4f6c30876dfa 674 (READ_BIT(FLASH->ECCR, (__FLAG__)) == (__FLAG__)) : \
Kojto 107:4f6c30876dfa 675 (READ_BIT(FLASH->SR, (__FLAG__)) == (__FLAG__)))
Kojto 107:4f6c30876dfa 676
Kojto 107:4f6c30876dfa 677 /**
Kojto 107:4f6c30876dfa 678 * @brief Clear the FLASH's pending flags.
Kojto 107:4f6c30876dfa 679 * @param __FLAG__: specifies the FLASH flags to clear.
Kojto 107:4f6c30876dfa 680 * This parameter can be any combination of the following values:
Kojto 107:4f6c30876dfa 681 * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
Kojto 107:4f6c30876dfa 682 * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
Kojto 107:4f6c30876dfa 683 * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
Kojto 107:4f6c30876dfa 684 * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
Kojto 107:4f6c30876dfa 685 * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
Kojto 107:4f6c30876dfa 686 * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
Kojto 107:4f6c30876dfa 687 * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
Kojto 107:4f6c30876dfa 688 * @arg FLASH_FLAG_MISERR: FLASH Fast programming data miss error flag
Kojto 107:4f6c30876dfa 689 * @arg FLASH_FLAG_FASTERR: FLASH Fast programming error flag
Kojto 107:4f6c30876dfa 690 * @arg FLASH_FLAG_RDERR: FLASH PCROP read error flag
Kojto 107:4f6c30876dfa 691 * @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag
Kojto 107:4f6c30876dfa 692 * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
Kojto 107:4f6c30876dfa 693 * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
Kojto 107:4f6c30876dfa 694 * @arg FLASH_FLAG_ALL_ERRORS: FLASH All errors flags
Kojto 107:4f6c30876dfa 695 * @retval None
Kojto 107:4f6c30876dfa 696 */
Kojto 107:4f6c30876dfa 697 #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) do { if((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) { SET_BIT(FLASH->ECCR, ((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\
Kojto 107:4f6c30876dfa 698 if((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) { WRITE_REG(FLASH->SR, ((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\
Kojto 107:4f6c30876dfa 699 } while(0)
Kojto 107:4f6c30876dfa 700 /**
Kojto 107:4f6c30876dfa 701 * @}
Kojto 107:4f6c30876dfa 702 */
Kojto 107:4f6c30876dfa 703
Kojto 107:4f6c30876dfa 704 /* Include FLASH HAL Extended module */
Kojto 107:4f6c30876dfa 705 #include "stm32l4xx_hal_flash_ex.h"
Kojto 107:4f6c30876dfa 706 #include "stm32l4xx_hal_flash_ramfunc.h"
Kojto 107:4f6c30876dfa 707
Kojto 107:4f6c30876dfa 708 /* Exported functions --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 709 /** @addtogroup FLASH_Exported_Functions
Kojto 107:4f6c30876dfa 710 * @{
Kojto 107:4f6c30876dfa 711 */
Kojto 107:4f6c30876dfa 712
Kojto 107:4f6c30876dfa 713 /* Program operation functions ***********************************************/
Kojto 107:4f6c30876dfa 714 /** @addtogroup FLASH_Exported_Functions_Group1
Kojto 107:4f6c30876dfa 715 * @{
Kojto 107:4f6c30876dfa 716 */
Kojto 107:4f6c30876dfa 717 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
Kojto 107:4f6c30876dfa 718 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
Kojto 107:4f6c30876dfa 719 /* FLASH IRQ handler method */
Kojto 107:4f6c30876dfa 720 void HAL_FLASH_IRQHandler(void);
Kojto 107:4f6c30876dfa 721 /* Callbacks in non blocking modes */
Kojto 107:4f6c30876dfa 722 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
Kojto 107:4f6c30876dfa 723 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
Kojto 107:4f6c30876dfa 724 /**
Kojto 107:4f6c30876dfa 725 * @}
Kojto 107:4f6c30876dfa 726 */
Kojto 107:4f6c30876dfa 727
Kojto 107:4f6c30876dfa 728 /* Peripheral Control functions **********************************************/
Kojto 107:4f6c30876dfa 729 /** @addtogroup FLASH_Exported_Functions_Group2
Kojto 107:4f6c30876dfa 730 * @{
Kojto 107:4f6c30876dfa 731 */
Kojto 107:4f6c30876dfa 732 HAL_StatusTypeDef HAL_FLASH_Unlock(void);
Kojto 107:4f6c30876dfa 733 HAL_StatusTypeDef HAL_FLASH_Lock(void);
Kojto 107:4f6c30876dfa 734 /* Option bytes control */
Kojto 107:4f6c30876dfa 735 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
Kojto 107:4f6c30876dfa 736 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
Kojto 107:4f6c30876dfa 737 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
Kojto 107:4f6c30876dfa 738 /**
Kojto 107:4f6c30876dfa 739 * @}
Kojto 107:4f6c30876dfa 740 */
Kojto 107:4f6c30876dfa 741
Kojto 107:4f6c30876dfa 742 /* Peripheral State functions ************************************************/
Kojto 107:4f6c30876dfa 743 /** @addtogroup FLASH_Exported_Functions_Group3
Kojto 107:4f6c30876dfa 744 * @{
Kojto 107:4f6c30876dfa 745 */
Kojto 107:4f6c30876dfa 746 uint32_t HAL_FLASH_GetError(void);
Kojto 107:4f6c30876dfa 747 /**
Kojto 107:4f6c30876dfa 748 * @}
Kojto 107:4f6c30876dfa 749 */
Kojto 107:4f6c30876dfa 750
Kojto 107:4f6c30876dfa 751 /**
Kojto 107:4f6c30876dfa 752 * @}
Kojto 107:4f6c30876dfa 753 */
Kojto 107:4f6c30876dfa 754
Kojto 107:4f6c30876dfa 755 /* Private constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 756 /** @defgroup FLASH_Private_Constants FLASH Private Constants
Kojto 107:4f6c30876dfa 757 * @{
Kojto 107:4f6c30876dfa 758 */
Kojto 107:4f6c30876dfa 759 #define FLASH_SIZE_DATA_REGISTER ((uint32_t)0x1FFF75E0)
Kojto 107:4f6c30876dfa 760
Kojto 107:4f6c30876dfa 761 #define FLASH_SIZE ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0xFFFF)) ? (0x400 << 10) : \
Kojto 107:4f6c30876dfa 762 (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) << 10))
Kojto 107:4f6c30876dfa 763
Kojto 122:f9eeca106725 764 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 107:4f6c30876dfa 765 #define FLASH_BANK_SIZE (FLASH_SIZE >> 1)
Kojto 122:f9eeca106725 766 #else
Kojto 122:f9eeca106725 767 #define FLASH_BANK_SIZE (FLASH_SIZE)
Kojto 122:f9eeca106725 768 #endif
Kojto 107:4f6c30876dfa 769
Kojto 107:4f6c30876dfa 770 #define FLASH_PAGE_SIZE ((uint32_t)0x800)
Kojto 107:4f6c30876dfa 771
Kojto 107:4f6c30876dfa 772 #define FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */
Kojto 107:4f6c30876dfa 773 /**
Kojto 107:4f6c30876dfa 774 * @}
Kojto 107:4f6c30876dfa 775 */
Kojto 107:4f6c30876dfa 776
Kojto 107:4f6c30876dfa 777 /* Private macros ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 778 /** @defgroup FLASH_Private_Macros FLASH Private Macros
Kojto 107:4f6c30876dfa 779 * @{
Kojto 107:4f6c30876dfa 780 */
Kojto 107:4f6c30876dfa 781
Kojto 107:4f6c30876dfa 782 #define IS_FLASH_TYPEERASE(VALUE) (((VALUE) == FLASH_TYPEERASE_PAGES) || \
Kojto 107:4f6c30876dfa 783 ((VALUE) == FLASH_TYPEERASE_MASSERASE))
Kojto 107:4f6c30876dfa 784
Kojto 122:f9eeca106725 785 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 107:4f6c30876dfa 786 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
Kojto 107:4f6c30876dfa 787 ((BANK) == FLASH_BANK_2) || \
Kojto 107:4f6c30876dfa 788 ((BANK) == FLASH_BANK_BOTH))
Kojto 107:4f6c30876dfa 789
Kojto 107:4f6c30876dfa 790 #define IS_FLASH_BANK_EXCLUSIVE(BANK) (((BANK) == FLASH_BANK_1) || \
Kojto 107:4f6c30876dfa 791 ((BANK) == FLASH_BANK_2))
Kojto 122:f9eeca106725 792 #else
Kojto 122:f9eeca106725 793 #define IS_FLASH_BANK(BANK) ((BANK) == FLASH_BANK_1)
Kojto 122:f9eeca106725 794
Kojto 122:f9eeca106725 795 #define IS_FLASH_BANK_EXCLUSIVE(BANK) ((BANK) == FLASH_BANK_1)
Kojto 122:f9eeca106725 796 #endif
Kojto 107:4f6c30876dfa 797
Kojto 107:4f6c30876dfa 798 #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD) || \
Kojto 107:4f6c30876dfa 799 ((VALUE) == FLASH_TYPEPROGRAM_FAST) || \
Kojto 107:4f6c30876dfa 800 ((VALUE) == FLASH_TYPEPROGRAM_FAST_AND_LAST))
Kojto 107:4f6c30876dfa 801
Kojto 107:4f6c30876dfa 802 #define IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x400) ? \
Kojto 107:4f6c30876dfa 803 ((ADDRESS) <= FLASH_BASE+0xFFFFF) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x200) ? \
Kojto 107:4f6c30876dfa 804 ((ADDRESS) <= FLASH_BASE+0x7FFFF) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x100) ? \
Kojto 122:f9eeca106725 805 ((ADDRESS) <= FLASH_BASE+0x3FFFF) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x80) ? \
Kojto 122:f9eeca106725 806 ((ADDRESS) <= FLASH_BASE+0x1FFFF) : ((ADDRESS) <= FLASH_BASE+0xFFFFF))))))
Kojto 107:4f6c30876dfa 807
Kojto 107:4f6c30876dfa 808 #define IS_FLASH_OTP_ADDRESS(ADDRESS) (((ADDRESS) >= 0x1FFF7000) && ((ADDRESS) <= 0x1FFF73FF))
Kojto 107:4f6c30876dfa 809
Kojto 107:4f6c30876dfa 810 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) || IS_FLASH_OTP_ADDRESS(ADDRESS))
Kojto 107:4f6c30876dfa 811
Kojto 122:f9eeca106725 812 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 107:4f6c30876dfa 813 #define IS_FLASH_PAGE(PAGE) (((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x400) ? ((PAGE) < 256) : \
Kojto 107:4f6c30876dfa 814 ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x200) ? ((PAGE) < 128) : \
Kojto 107:4f6c30876dfa 815 ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x100) ? ((PAGE) < 64) : \
Kojto 107:4f6c30876dfa 816 ((PAGE) < 256)))))
Kojto 122:f9eeca106725 817 #else
Kojto 122:f9eeca106725 818 #define IS_FLASH_PAGE(PAGE) (((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x100) ? ((PAGE) < 128) : \
Kojto 122:f9eeca106725 819 ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x80) ? ((PAGE) < 64) : \
Kojto 122:f9eeca106725 820 ((PAGE) < 128))))
Kojto 122:f9eeca106725 821 #endif
Kojto 107:4f6c30876dfa 822
Kojto 107:4f6c30876dfa 823 #define IS_OPTIONBYTE(VALUE) (((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_PCROP)))
Kojto 107:4f6c30876dfa 824
Kojto 122:f9eeca106725 825 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 107:4f6c30876dfa 826 #define IS_OB_WRPAREA(VALUE) (((VALUE) == OB_WRPAREA_BANK1_AREAA) || ((VALUE) == OB_WRPAREA_BANK1_AREAB) || \
Kojto 107:4f6c30876dfa 827 ((VALUE) == OB_WRPAREA_BANK2_AREAA) || ((VALUE) == OB_WRPAREA_BANK2_AREAB))
Kojto 122:f9eeca106725 828 #else
Kojto 122:f9eeca106725 829 #define IS_OB_WRPAREA(VALUE) (((VALUE) == OB_WRPAREA_BANK1_AREAA) || ((VALUE) == OB_WRPAREA_BANK1_AREAB))
Kojto 122:f9eeca106725 830 #endif
Kojto 107:4f6c30876dfa 831
Kojto 107:4f6c30876dfa 832 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
Kojto 107:4f6c30876dfa 833 ((LEVEL) == OB_RDP_LEVEL_1)/* ||\
Kojto 107:4f6c30876dfa 834 ((LEVEL) == OB_RDP_LEVEL_2)*/)
Kojto 107:4f6c30876dfa 835
Kojto 122:f9eeca106725 836 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 122:f9eeca106725 837 #define IS_OB_USER_TYPE(TYPE) (((TYPE) <= (uint32_t)0x1FFF) && ((TYPE) != 0))
Kojto 122:f9eeca106725 838 #else
Kojto 122:f9eeca106725 839 #define IS_OB_USER_TYPE(TYPE) (((TYPE) <= (uint32_t)0x7E7F) && ((TYPE) != 0) && (((TYPE)&0x0180) == 0))
Kojto 122:f9eeca106725 840 #endif
Kojto 107:4f6c30876dfa 841
Kojto 107:4f6c30876dfa 842 #define IS_OB_USER_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL_0) || ((LEVEL) == OB_BOR_LEVEL_1) || \
Kojto 107:4f6c30876dfa 843 ((LEVEL) == OB_BOR_LEVEL_2) || ((LEVEL) == OB_BOR_LEVEL_3) || \
Kojto 107:4f6c30876dfa 844 ((LEVEL) == OB_BOR_LEVEL_4))
Kojto 107:4f6c30876dfa 845
Kojto 107:4f6c30876dfa 846 #define IS_OB_USER_STOP(VALUE) (((VALUE) == OB_STOP_RST) || ((VALUE) == OB_STOP_NORST))
Kojto 107:4f6c30876dfa 847
Kojto 107:4f6c30876dfa 848 #define IS_OB_USER_STANDBY(VALUE) (((VALUE) == OB_STANDBY_RST) || ((VALUE) == OB_STANDBY_NORST))
Kojto 107:4f6c30876dfa 849
Kojto 122:f9eeca106725 850 #define IS_OB_USER_SHUTDOWN(VALUE) (((VALUE) == OB_SHUTDOWN_RST) || ((VALUE) == OB_SHUTDOWN_NORST))
Kojto 122:f9eeca106725 851
Kojto 107:4f6c30876dfa 852 #define IS_OB_USER_IWDG(VALUE) (((VALUE) == OB_IWDG_HW) || ((VALUE) == OB_IWDG_SW))
Kojto 107:4f6c30876dfa 853
Kojto 107:4f6c30876dfa 854 #define IS_OB_USER_IWDG_STOP(VALUE) (((VALUE) == OB_IWDG_STOP_FREEZE) || ((VALUE) == OB_IWDG_STOP_RUN))
Kojto 107:4f6c30876dfa 855
Kojto 107:4f6c30876dfa 856 #define IS_OB_USER_IWDG_STDBY(VALUE) (((VALUE) == OB_IWDG_STDBY_FREEZE) || ((VALUE) == OB_IWDG_STDBY_RUN))
Kojto 107:4f6c30876dfa 857
Kojto 107:4f6c30876dfa 858 #define IS_OB_USER_WWDG(VALUE) (((VALUE) == OB_WWDG_HW) || ((VALUE) == OB_WWDG_SW))
Kojto 107:4f6c30876dfa 859
Kojto 122:f9eeca106725 860 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 107:4f6c30876dfa 861 #define IS_OB_USER_BFB2(VALUE) (((VALUE) == OB_BFB2_DISABLE) || ((VALUE) == OB_BFB2_ENABLE))
Kojto 107:4f6c30876dfa 862
Kojto 107:4f6c30876dfa 863 #define IS_OB_USER_DUALBANK(VALUE) (((VALUE) == OB_DUALBANK_SINGLE) || ((VALUE) == OB_DUALBANK_DUAL))
Kojto 122:f9eeca106725 864 #endif
Kojto 107:4f6c30876dfa 865
Kojto 107:4f6c30876dfa 866 #define IS_OB_USER_BOOT1(VALUE) (((VALUE) == OB_BOOT1_SRAM) || ((VALUE) == OB_BOOT1_SYSTEM))
Kojto 107:4f6c30876dfa 867
Kojto 107:4f6c30876dfa 868 #define IS_OB_USER_SRAM2_PARITY(VALUE) (((VALUE) == OB_SRAM2_PARITY_ENABLE) || ((VALUE) == OB_SRAM2_PARITY_DISABLE))
Kojto 107:4f6c30876dfa 869
Kojto 107:4f6c30876dfa 870 #define IS_OB_USER_SRAM2_RST(VALUE) (((VALUE) == OB_SRAM2_RST_ERASE) || ((VALUE) == OB_SRAM2_RST_NOT_ERASE))
Kojto 107:4f6c30876dfa 871
Kojto 122:f9eeca106725 872 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 873 #define IS_OB_USER_SWBOOT0(VALUE) (((VALUE) == OB_BOOT0_FROM_OB) || ((VALUE) == OB_BOOT0_FROM_PIN))
Kojto 122:f9eeca106725 874
Kojto 122:f9eeca106725 875 #define IS_OB_USER_BOOT0(VALUE) (((VALUE) == OB_BOOT0_RESET) || ((VALUE) == OB_BOOT0_SET))
Kojto 122:f9eeca106725 876 #endif
Kojto 122:f9eeca106725 877
Kojto 107:4f6c30876dfa 878 #define IS_OB_PCROP_RDP(VALUE) (((VALUE) == OB_PCROP_RDP_NOT_ERASE) || ((VALUE) == OB_PCROP_RDP_ERASE))
Kojto 107:4f6c30876dfa 879
Kojto 107:4f6c30876dfa 880 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
Kojto 107:4f6c30876dfa 881 ((LATENCY) == FLASH_LATENCY_1) || \
Kojto 107:4f6c30876dfa 882 ((LATENCY) == FLASH_LATENCY_2) || \
Kojto 107:4f6c30876dfa 883 ((LATENCY) == FLASH_LATENCY_3) || \
Kojto 107:4f6c30876dfa 884 ((LATENCY) == FLASH_LATENCY_4))
Kojto 107:4f6c30876dfa 885 /**
Kojto 107:4f6c30876dfa 886 * @}
Kojto 107:4f6c30876dfa 887 */
Kojto 107:4f6c30876dfa 888
Kojto 107:4f6c30876dfa 889 /**
Kojto 107:4f6c30876dfa 890 * @}
Kojto 107:4f6c30876dfa 891 */
Kojto 107:4f6c30876dfa 892
Kojto 107:4f6c30876dfa 893 /**
Kojto 107:4f6c30876dfa 894 * @}
Kojto 107:4f6c30876dfa 895 */
Kojto 107:4f6c30876dfa 896
Kojto 107:4f6c30876dfa 897 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 898 }
Kojto 107:4f6c30876dfa 899 #endif
Kojto 107:4f6c30876dfa 900
Kojto 107:4f6c30876dfa 901 #endif /* __STM32L4xx_HAL_FLASH_H */
Kojto 107:4f6c30876dfa 902
Kojto 107:4f6c30876dfa 903 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/