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:
<>
Date:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_hal_flash.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.1
Kojto 122:f9eeca106725 6 * @date 31-May-2016
Kojto 122:f9eeca106725 7 * @brief Header file of FLASH HAL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_HAL_FLASH_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_HAL_FLASH_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
Kojto 122:f9eeca106725 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32l4xx_hal_def.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 122:f9eeca106725 50 * @{
Kojto 122:f9eeca106725 51 */
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 /** @addtogroup FLASH
Kojto 122:f9eeca106725 54 * @{
Kojto 122:f9eeca106725 55 */
Kojto 122:f9eeca106725 56
Kojto 122:f9eeca106725 57 /* Exported types ------------------------------------------------------------*/
Kojto 122:f9eeca106725 58 /** @defgroup FLASH_Exported_Types FLASH Exported Types
Kojto 122:f9eeca106725 59 * @{
Kojto 122:f9eeca106725 60 */
Kojto 122:f9eeca106725 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief FLASH Erase structure definition
Kojto 122:f9eeca106725 64 */
Kojto 122:f9eeca106725 65 typedef struct
Kojto 122:f9eeca106725 66 {
Kojto 122:f9eeca106725 67 uint32_t TypeErase; /*!< Mass erase or page erase.
Kojto 122:f9eeca106725 68 This parameter can be a value of @ref FLASH_Type_Erase */
Kojto 122:f9eeca106725 69 uint32_t Banks; /*!< Select bank to erase.
Kojto 122:f9eeca106725 70 This parameter must be a value of @ref FLASH_Banks
Kojto 122:f9eeca106725 71 (FLASH_BANK_BOTH should be used only for mass erase) */
Kojto 122:f9eeca106725 72 uint32_t Page; /*!< Initial Flash page to erase when page erase is disabled
Kojto 122:f9eeca106725 73 This parameter must be a value between 0 and (max number of pages in the bank - 1)
Kojto 122:f9eeca106725 74 (eg : 255 for 1MB dual bank) */
Kojto 122:f9eeca106725 75 uint32_t NbPages; /*!< Number of pages to be erased.
Kojto 122:f9eeca106725 76 This parameter must be a value between 1 and (max number of pages in the bank - value of initial page)*/
Kojto 122:f9eeca106725 77 } FLASH_EraseInitTypeDef;
Kojto 122:f9eeca106725 78
Kojto 122:f9eeca106725 79 /**
Kojto 122:f9eeca106725 80 * @brief FLASH Option Bytes Program structure definition
Kojto 122:f9eeca106725 81 */
Kojto 122:f9eeca106725 82 typedef struct
Kojto 122:f9eeca106725 83 {
Kojto 122:f9eeca106725 84 uint32_t OptionType; /*!< Option byte to be configured.
Kojto 122:f9eeca106725 85 This parameter can be a combination of the values of @ref FLASH_OB_Type */
Kojto 122:f9eeca106725 86 uint32_t WRPArea; /*!< Write protection area to be programmed (used for OPTIONBYTE_WRP).
Kojto 122:f9eeca106725 87 Only one WRP area could be programmed at the same time.
Kojto 122:f9eeca106725 88 This parameter can be value of @ref FLASH_OB_WRP_Area */
Kojto 122:f9eeca106725 89 uint32_t WRPStartOffset; /*!< Write protection start offset (used for OPTIONBYTE_WRP).
Kojto 122:f9eeca106725 90 This parameter must be a value between 0 and (max number of pages in the bank - 1)
Kojto 122:f9eeca106725 91 (eg : 25 for 1MB dual bank) */
Kojto 122:f9eeca106725 92 uint32_t WRPEndOffset; /*!< Write protection end offset (used for OPTIONBYTE_WRP).
Kojto 122:f9eeca106725 93 This parameter must be a value between WRPStartOffset and (max number of pages in the bank - 1) */
Kojto 122:f9eeca106725 94 uint32_t RDPLevel; /*!< Set the read protection level.. (used for OPTIONBYTE_RDP).
Kojto 122:f9eeca106725 95 This parameter can be a value of @ref FLASH_OB_Read_Protection */
Kojto 122:f9eeca106725 96 uint32_t USERType; /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).
Kojto 122:f9eeca106725 97 This parameter can be a combination of @ref FLASH_OB_USER_Type */
Kojto 122:f9eeca106725 98 uint32_t USERConfig; /*!< Value of the user option byte (used for OPTIONBYTE_USER).
Kojto 122:f9eeca106725 99 This parameter can be a combination of @ref FLASH_OB_USER_BOR_LEVEL,
Kojto 122:f9eeca106725 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 122:f9eeca106725 106 uint32_t PCROPConfig; /*!< Configuration of the PCROP (used for OPTIONBYTE_PCROP).
Kojto 122:f9eeca106725 107 This parameter must be a combination of @ref FLASH_Banks (except FLASH_BANK_BOTH)
Kojto 122:f9eeca106725 108 and @ref FLASH_OB_PCROP_RDP */
Kojto 122:f9eeca106725 109 uint32_t PCROPStartAddr; /*!< PCROP Start address (used for OPTIONBYTE_PCROP).
Kojto 122:f9eeca106725 110 This parameter must be a value between begin and end of bank
Kojto 122:f9eeca106725 111 => Be careful of the bank swapping for the address */
Kojto 122:f9eeca106725 112 uint32_t PCROPEndAddr; /*!< PCROP End address (used for OPTIONBYTE_PCROP).
Kojto 122:f9eeca106725 113 This parameter must be a value between PCROP Start address and end of bank */
Kojto 122:f9eeca106725 114 } FLASH_OBProgramInitTypeDef;
Kojto 122:f9eeca106725 115
Kojto 122:f9eeca106725 116 /**
Kojto 122:f9eeca106725 117 * @brief FLASH Procedure structure definition
Kojto 122:f9eeca106725 118 */
Kojto 122:f9eeca106725 119 typedef enum
Kojto 122:f9eeca106725 120 {
Kojto 122:f9eeca106725 121 FLASH_PROC_NONE = 0,
Kojto 122:f9eeca106725 122 FLASH_PROC_PAGE_ERASE,
Kojto 122:f9eeca106725 123 FLASH_PROC_MASS_ERASE,
Kojto 122:f9eeca106725 124 FLASH_PROC_PROGRAM,
Kojto 122:f9eeca106725 125 FLASH_PROC_PROGRAM_LAST
Kojto 122:f9eeca106725 126 } FLASH_ProcedureTypeDef;
Kojto 122:f9eeca106725 127
Kojto 122:f9eeca106725 128 /**
Kojto 122:f9eeca106725 129 * @brief FLASH handle Structure definition
Kojto 122:f9eeca106725 130 */
Kojto 122:f9eeca106725 131 typedef struct
Kojto 122:f9eeca106725 132 {
Kojto 122:f9eeca106725 133 HAL_LockTypeDef Lock; /* FLASH locking object */
Kojto 122:f9eeca106725 134 __IO uint32_t ErrorCode; /* FLASH error code */
Kojto 122:f9eeca106725 135 __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */
Kojto 122:f9eeca106725 136 __IO uint32_t Address; /* Internal variable to save address selected for program in IT context */
Kojto 122:f9eeca106725 137 __IO uint32_t Bank; /* Internal variable to save current bank selected during erase in IT context */
Kojto 122:f9eeca106725 138 __IO uint32_t Page; /* Internal variable to define the current page which is erasing in IT context */
Kojto 122:f9eeca106725 139 __IO uint32_t NbPagesToErase; /* Internal variable to save the remaining pages to erase in IT context */
Kojto 122:f9eeca106725 140 }FLASH_ProcessTypeDef;
Kojto 122:f9eeca106725 141
Kojto 122:f9eeca106725 142 /**
Kojto 122:f9eeca106725 143 * @}
Kojto 122:f9eeca106725 144 */
Kojto 122:f9eeca106725 145
Kojto 122:f9eeca106725 146 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 147 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
Kojto 122:f9eeca106725 148 * @{
Kojto 122:f9eeca106725 149 */
Kojto 122:f9eeca106725 150
Kojto 122:f9eeca106725 151 /** @defgroup FLASH_Error FLASH Error
Kojto 122:f9eeca106725 152 * @{
Kojto 122:f9eeca106725 153 */
Kojto 122:f9eeca106725 154 #define HAL_FLASH_ERROR_NONE ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 155 #define HAL_FLASH_ERROR_OP ((uint32_t)0x00000001)
Kojto 122:f9eeca106725 156 #define HAL_FLASH_ERROR_PROG ((uint32_t)0x00000002)
Kojto 122:f9eeca106725 157 #define HAL_FLASH_ERROR_WRP ((uint32_t)0x00000004)
Kojto 122:f9eeca106725 158 #define HAL_FLASH_ERROR_PGA ((uint32_t)0x00000008)
Kojto 122:f9eeca106725 159 #define HAL_FLASH_ERROR_SIZ ((uint32_t)0x00000010)
Kojto 122:f9eeca106725 160 #define HAL_FLASH_ERROR_PGS ((uint32_t)0x00000020)
Kojto 122:f9eeca106725 161 #define HAL_FLASH_ERROR_MIS ((uint32_t)0x00000040)
Kojto 122:f9eeca106725 162 #define HAL_FLASH_ERROR_FAST ((uint32_t)0x00000080)
Kojto 122:f9eeca106725 163 #define HAL_FLASH_ERROR_RD ((uint32_t)0x00000100)
Kojto 122:f9eeca106725 164 #define HAL_FLASH_ERROR_OPTV ((uint32_t)0x00000200)
Kojto 122:f9eeca106725 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 122:f9eeca106725 169 /**
Kojto 122:f9eeca106725 170 * @}
Kojto 122:f9eeca106725 171 */
Kojto 122:f9eeca106725 172
Kojto 122:f9eeca106725 173 /** @defgroup FLASH_Type_Erase FLASH Erase Type
Kojto 122:f9eeca106725 174 * @{
Kojto 122:f9eeca106725 175 */
Kojto 122:f9eeca106725 176 #define FLASH_TYPEERASE_PAGES ((uint32_t)0x00) /*!<Pages erase only*/
Kojto 122:f9eeca106725 177 #define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01) /*!<Flash mass erase activation*/
Kojto 122:f9eeca106725 178 /**
Kojto 122:f9eeca106725 179 * @}
Kojto 122:f9eeca106725 180 */
Kojto 122:f9eeca106725 181
Kojto 122:f9eeca106725 182 /** @defgroup FLASH_Banks FLASH Banks
Kojto 122:f9eeca106725 183 * @{
Kojto 122:f9eeca106725 184 */
Kojto 122:f9eeca106725 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 122:f9eeca106725 187 #define FLASH_BANK_2 ((uint32_t)0x02) /*!< Bank 2 */
Kojto 122:f9eeca106725 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 122:f9eeca106725 192 /**
Kojto 122:f9eeca106725 193 * @}
Kojto 122:f9eeca106725 194 */
Kojto 122:f9eeca106725 195
Kojto 122:f9eeca106725 196
Kojto 122:f9eeca106725 197 /** @defgroup FLASH_Type_Program FLASH Program Type
Kojto 122:f9eeca106725 198 * @{
Kojto 122:f9eeca106725 199 */
Kojto 122:f9eeca106725 200 #define FLASH_TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x00) /*!<Program a double-word (64-bit) at a specified address.*/
Kojto 122:f9eeca106725 201 #define FLASH_TYPEPROGRAM_FAST ((uint32_t)0x01) /*!<Fast program a 32 row double-word (64-bit) at a specified address.
Kojto 122:f9eeca106725 202 And another 32 row double-word (64-bit) will be programmed */
Kojto 122:f9eeca106725 203 #define FLASH_TYPEPROGRAM_FAST_AND_LAST ((uint32_t)0x02) /*!<Fast program a 32 row double-word (64-bit) at a specified address.
Kojto 122:f9eeca106725 204 And this is the last 32 row double-word (64-bit) programmed */
Kojto 122:f9eeca106725 205 /**
Kojto 122:f9eeca106725 206 * @}
Kojto 122:f9eeca106725 207 */
Kojto 122:f9eeca106725 208
Kojto 122:f9eeca106725 209 /** @defgroup FLASH_OB_Type FLASH Option Bytes Type
Kojto 122:f9eeca106725 210 * @{
Kojto 122:f9eeca106725 211 */
Kojto 122:f9eeca106725 212 #define OPTIONBYTE_WRP ((uint32_t)0x01) /*!< WRP option byte configuration */
Kojto 122:f9eeca106725 213 #define OPTIONBYTE_RDP ((uint32_t)0x02) /*!< RDP option byte configuration */
Kojto 122:f9eeca106725 214 #define OPTIONBYTE_USER ((uint32_t)0x04) /*!< USER option byte configuration */
Kojto 122:f9eeca106725 215 #define OPTIONBYTE_PCROP ((uint32_t)0x08) /*!< PCROP option byte configuration */
Kojto 122:f9eeca106725 216 /**
Kojto 122:f9eeca106725 217 * @}
Kojto 122:f9eeca106725 218 */
Kojto 122:f9eeca106725 219
Kojto 122:f9eeca106725 220 /** @defgroup FLASH_OB_WRP_Area FLASH WRP Area
Kojto 122:f9eeca106725 221 * @{
Kojto 122:f9eeca106725 222 */
Kojto 122:f9eeca106725 223 #define OB_WRPAREA_BANK1_AREAA ((uint32_t)0x00) /*!< Flash Bank 1 Area A */
Kojto 122:f9eeca106725 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 122:f9eeca106725 226 #define OB_WRPAREA_BANK2_AREAA ((uint32_t)0x02) /*!< Flash Bank 2 Area A */
Kojto 122:f9eeca106725 227 #define OB_WRPAREA_BANK2_AREAB ((uint32_t)0x04) /*!< Flash Bank 2 Area B */
Kojto 122:f9eeca106725 228 #endif
Kojto 122:f9eeca106725 229 /**
Kojto 122:f9eeca106725 230 * @}
Kojto 122:f9eeca106725 231 */
Kojto 122:f9eeca106725 232
Kojto 122:f9eeca106725 233 /** @defgroup FLASH_OB_Read_Protection FLASH Option Bytes Read Protection
Kojto 122:f9eeca106725 234 * @{
Kojto 122:f9eeca106725 235 */
Kojto 122:f9eeca106725 236 #define OB_RDP_LEVEL_0 ((uint32_t)0xAA)
Kojto 122:f9eeca106725 237 #define OB_RDP_LEVEL_1 ((uint32_t)0xBB)
Kojto 122:f9eeca106725 238 #define OB_RDP_LEVEL_2 ((uint32_t)0xCC) /*!< Warning: When enabling read protection level 2
Kojto 122:f9eeca106725 239 it's no more possible to go back to level 1 or 0 */
Kojto 122:f9eeca106725 240 /**
Kojto 122:f9eeca106725 241 * @}
Kojto 122:f9eeca106725 242 */
Kojto 122:f9eeca106725 243
Kojto 122:f9eeca106725 244 /** @defgroup FLASH_OB_USER_Type FLASH Option Bytes User Type
Kojto 122:f9eeca106725 245 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 266 /**
Kojto 122:f9eeca106725 267 * @}
Kojto 122:f9eeca106725 268 */
Kojto 122:f9eeca106725 269
Kojto 122:f9eeca106725 270 /** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes User BOR Level
Kojto 122:f9eeca106725 271 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 278 /**
Kojto 122:f9eeca106725 279 * @}
Kojto 122:f9eeca106725 280 */
Kojto 122:f9eeca106725 281
Kojto 122:f9eeca106725 282 /** @defgroup FLASH_OB_USER_nRST_STOP FLASH Option Bytes User Reset On Stop
Kojto 122:f9eeca106725 283 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 287 /**
Kojto 122:f9eeca106725 288 * @}
Kojto 122:f9eeca106725 289 */
Kojto 122:f9eeca106725 290
Kojto 122:f9eeca106725 291 /** @defgroup FLASH_OB_USER_nRST_STANDBY FLASH Option Bytes User Reset On Standby
Kojto 122:f9eeca106725 292 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 305 /**
Kojto 122:f9eeca106725 306 * @}
Kojto 122:f9eeca106725 307 */
Kojto 122:f9eeca106725 308
Kojto 122:f9eeca106725 309 /** @defgroup FLASH_OB_USER_IWDG_SW FLASH Option Bytes User IWDG Type
Kojto 122:f9eeca106725 310 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 314 /**
Kojto 122:f9eeca106725 315 * @}
Kojto 122:f9eeca106725 316 */
Kojto 122:f9eeca106725 317
Kojto 122:f9eeca106725 318 /** @defgroup FLASH_OB_USER_IWDG_STOP FLASH Option Bytes User IWDG Mode On Stop
Kojto 122:f9eeca106725 319 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 323 /**
Kojto 122:f9eeca106725 324 * @}
Kojto 122:f9eeca106725 325 */
Kojto 122:f9eeca106725 326
Kojto 122:f9eeca106725 327 /** @defgroup FLASH_OB_USER_IWDG_STANDBY FLASH Option Bytes User IWDG Mode On Standby
Kojto 122:f9eeca106725 328 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 332 /**
Kojto 122:f9eeca106725 333 * @}
Kojto 122:f9eeca106725 334 */
Kojto 122:f9eeca106725 335
Kojto 122:f9eeca106725 336 /** @defgroup FLASH_OB_USER_WWDG_SW FLASH Option Bytes User WWDG Type
Kojto 122:f9eeca106725 337 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 341 /**
Kojto 122:f9eeca106725 342 * @}
Kojto 122:f9eeca106725 343 */
Kojto 122:f9eeca106725 344
Kojto 122:f9eeca106725 345 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 346 /** @defgroup FLASH_OB_USER_BFB2 FLASH Option Bytes User BFB2 Mode
Kojto 122:f9eeca106725 347 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 351 /**
Kojto 122:f9eeca106725 352 * @}
Kojto 122:f9eeca106725 353 */
Kojto 122:f9eeca106725 354
Kojto 122:f9eeca106725 355 /** @defgroup FLASH_OB_USER_DUALBANK FLASH Option Bytes User Dual-bank Type
Kojto 122:f9eeca106725 356 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 360 /**
Kojto 122:f9eeca106725 361 * @}
Kojto 122:f9eeca106725 362 */
Kojto 122:f9eeca106725 363 #endif
Kojto 122:f9eeca106725 364
Kojto 122:f9eeca106725 365 /** @defgroup FLASH_OB_USER_nBOOT1 FLASH Option Bytes User BOOT1 Type
Kojto 122:f9eeca106725 366 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 370 /**
Kojto 122:f9eeca106725 371 * @}
Kojto 122:f9eeca106725 372 */
Kojto 122:f9eeca106725 373
Kojto 122:f9eeca106725 374 /** @defgroup FLASH_OB_USER_SRAM2_PE FLASH Option Bytes User SRAM2 Parity Check Type
Kojto 122:f9eeca106725 375 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 379 /**
Kojto 122:f9eeca106725 380 * @}
Kojto 122:f9eeca106725 381 */
Kojto 122:f9eeca106725 382
Kojto 122:f9eeca106725 383 /** @defgroup FLASH_OB_USER_SRAM2_RST FLASH Option Bytes User SRAM2 Erase On Reset Type
Kojto 122:f9eeca106725 384 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 398 /**
Kojto 122:f9eeca106725 399 * @}
Kojto 122:f9eeca106725 400 */
Kojto 122:f9eeca106725 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 122:f9eeca106725 412 /** @defgroup FLASH_OB_PCROP_RDP FLASH Option Bytes PCROP On RDP Level Type
Kojto 122:f9eeca106725 413 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 419 /**
Kojto 122:f9eeca106725 420 * @}
Kojto 122:f9eeca106725 421 */
Kojto 122:f9eeca106725 422
Kojto 122:f9eeca106725 423 /** @defgroup FLASH_Latency FLASH Latency
Kojto 122:f9eeca106725 424 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 431 /**
Kojto 122:f9eeca106725 432 * @}
Kojto 122:f9eeca106725 433 */
Kojto 122:f9eeca106725 434
Kojto 122:f9eeca106725 435 /** @defgroup FLASH_Keys FLASH Keys
Kojto 122:f9eeca106725 436 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 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 122:f9eeca106725 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 122:f9eeca106725 449 /**
Kojto 122:f9eeca106725 450 * @}
Kojto 122:f9eeca106725 451 */
Kojto 122:f9eeca106725 452
Kojto 122:f9eeca106725 453 /** @defgroup FLASH_Flags FLASH Flags Definition
Kojto 122:f9eeca106725 454 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 473
Kojto 122:f9eeca106725 474 #define FLASH_FLAG_ALL_ERRORS (FLASH_FLAG_OPERR | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \
Kojto 122:f9eeca106725 475 FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_PGSERR | \
Kojto 122:f9eeca106725 476 FLASH_FLAG_MISERR | FLASH_FLAG_FASTERR | FLASH_FLAG_RDERR | \
Kojto 122:f9eeca106725 477 FLASH_FLAG_OPTVERR | FLASH_FLAG_ECCD)
Kojto 122:f9eeca106725 478 /**
Kojto 122:f9eeca106725 479 * @}
Kojto 122:f9eeca106725 480 */
Kojto 122:f9eeca106725 481
Kojto 122:f9eeca106725 482 /** @defgroup FLASH_Interrupt_definition FLASH Interrupts Definition
Kojto 122:f9eeca106725 483 * @brief FLASH Interrupt definition
Kojto 122:f9eeca106725 484 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 490 /**
Kojto 122:f9eeca106725 491 * @}
Kojto 122:f9eeca106725 492 */
Kojto 122:f9eeca106725 493
Kojto 122:f9eeca106725 494 /**
Kojto 122:f9eeca106725 495 * @}
Kojto 122:f9eeca106725 496 */
Kojto 122:f9eeca106725 497
Kojto 122:f9eeca106725 498 /* Exported macros -----------------------------------------------------------*/
Kojto 122:f9eeca106725 499 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
Kojto 122:f9eeca106725 500 * @brief macros to control FLASH features
Kojto 122:f9eeca106725 501 * @{
Kojto 122:f9eeca106725 502 */
Kojto 122:f9eeca106725 503
Kojto 122:f9eeca106725 504 /**
Kojto 122:f9eeca106725 505 * @brief Set the FLASH Latency.
Kojto 122:f9eeca106725 506 * @param __LATENCY__: FLASH Latency
Kojto 122:f9eeca106725 507 * This parameter can be one of the following values :
Kojto 122:f9eeca106725 508 * @arg FLASH_LATENCY_0: FLASH Zero wait state
Kojto 122:f9eeca106725 509 * @arg FLASH_LATENCY_1: FLASH One wait state
Kojto 122:f9eeca106725 510 * @arg FLASH_LATENCY_2: FLASH Two wait states
Kojto 122:f9eeca106725 511 * @arg FLASH_LATENCY_3: FLASH Three wait states
Kojto 122:f9eeca106725 512 * @arg FLASH_LATENCY_4: FLASH Four wait states
Kojto 122:f9eeca106725 513 * @retval None
Kojto 122:f9eeca106725 514 */
Kojto 122:f9eeca106725 515 #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (__LATENCY__)))
Kojto 122:f9eeca106725 516
Kojto 122:f9eeca106725 517 /**
Kojto 122:f9eeca106725 518 * @brief Get the FLASH Latency.
Kojto 122:f9eeca106725 519 * @retval FLASH Latency
Kojto 122:f9eeca106725 520 * This parameter can be one of the following values :
Kojto 122:f9eeca106725 521 * @arg FLASH_LATENCY_0: FLASH Zero wait state
Kojto 122:f9eeca106725 522 * @arg FLASH_LATENCY_1: FLASH One wait state
Kojto 122:f9eeca106725 523 * @arg FLASH_LATENCY_2: FLASH Two wait states
Kojto 122:f9eeca106725 524 * @arg FLASH_LATENCY_3: FLASH Three wait states
Kojto 122:f9eeca106725 525 * @arg FLASH_LATENCY_4: FLASH Four wait states
Kojto 122:f9eeca106725 526 */
Kojto 122:f9eeca106725 527 #define __HAL_FLASH_GET_LATENCY() READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY)
Kojto 122:f9eeca106725 528
Kojto 122:f9eeca106725 529 /**
Kojto 122:f9eeca106725 530 * @brief Enable the FLASH prefetch buffer.
Kojto 122:f9eeca106725 531 * @retval None
Kojto 122:f9eeca106725 532 */
Kojto 122:f9eeca106725 533 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_PRFTEN)
Kojto 122:f9eeca106725 534
Kojto 122:f9eeca106725 535 /**
Kojto 122:f9eeca106725 536 * @brief Disable the FLASH prefetch buffer.
Kojto 122:f9eeca106725 537 * @retval None
Kojto 122:f9eeca106725 538 */
Kojto 122:f9eeca106725 539 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_PRFTEN)
Kojto 122:f9eeca106725 540
Kojto 122:f9eeca106725 541 /**
Kojto 122:f9eeca106725 542 * @brief Enable the FLASH instruction cache.
Kojto 122:f9eeca106725 543 * @retval none
Kojto 122:f9eeca106725 544 */
Kojto 122:f9eeca106725 545 #define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_ICEN)
Kojto 122:f9eeca106725 546
Kojto 122:f9eeca106725 547 /**
Kojto 122:f9eeca106725 548 * @brief Disable the FLASH instruction cache.
Kojto 122:f9eeca106725 549 * @retval none
Kojto 122:f9eeca106725 550 */
Kojto 122:f9eeca106725 551 #define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICEN)
Kojto 122:f9eeca106725 552
Kojto 122:f9eeca106725 553 /**
Kojto 122:f9eeca106725 554 * @brief Enable the FLASH data cache.
Kojto 122:f9eeca106725 555 * @retval none
Kojto 122:f9eeca106725 556 */
Kojto 122:f9eeca106725 557 #define __HAL_FLASH_DATA_CACHE_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_DCEN)
Kojto 122:f9eeca106725 558
Kojto 122:f9eeca106725 559 /**
Kojto 122:f9eeca106725 560 * @brief Disable the FLASH data cache.
Kojto 122:f9eeca106725 561 * @retval none
Kojto 122:f9eeca106725 562 */
Kojto 122:f9eeca106725 563 #define __HAL_FLASH_DATA_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCEN)
Kojto 122:f9eeca106725 564
Kojto 122:f9eeca106725 565 /**
Kojto 122:f9eeca106725 566 * @brief Reset the FLASH instruction Cache.
Kojto 122:f9eeca106725 567 * @note This function must be used only when the Instruction Cache is disabled.
Kojto 122:f9eeca106725 568 * @retval None
Kojto 122:f9eeca106725 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 122:f9eeca106725 573
Kojto 122:f9eeca106725 574 /**
Kojto 122:f9eeca106725 575 * @brief Reset the FLASH data Cache.
Kojto 122:f9eeca106725 576 * @note This function must be used only when the data Cache is disabled.
Kojto 122:f9eeca106725 577 * @retval None
Kojto 122:f9eeca106725 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 122:f9eeca106725 582
Kojto 122:f9eeca106725 583 /**
Kojto 122:f9eeca106725 584 * @brief Enable the FLASH power down during Low-power run mode.
Kojto 122:f9eeca106725 585 * @note Writing this bit to 0 this bit, automatically the keys are
Kojto 122:f9eeca106725 586 * loss and a new unlock sequence is necessary to re-write it to 1.
Kojto 122:f9eeca106725 587 */
Kojto 122:f9eeca106725 588 #define __HAL_FLASH_POWER_DOWN_ENABLE() do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \
Kojto 122:f9eeca106725 589 WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \
Kojto 122:f9eeca106725 590 SET_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \
Kojto 122:f9eeca106725 591 } while (0)
Kojto 122:f9eeca106725 592
Kojto 122:f9eeca106725 593 /**
Kojto 122:f9eeca106725 594 * @brief Disable the FLASH power down during Low-power run mode.
Kojto 122:f9eeca106725 595 * @note Writing this bit to 0 this bit, automatically the keys are
Kojto 122:f9eeca106725 596 * loss and a new unlock sequence is necessary to re-write it to 1.
Kojto 122:f9eeca106725 597 */
Kojto 122:f9eeca106725 598 #define __HAL_FLASH_POWER_DOWN_DISABLE() do { WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY1); \
Kojto 122:f9eeca106725 599 WRITE_REG(FLASH->PDKEYR, FLASH_PDKEY2); \
Kojto 122:f9eeca106725 600 CLEAR_BIT(FLASH->ACR, FLASH_ACR_RUN_PD); \
Kojto 122:f9eeca106725 601 } while (0)
Kojto 122:f9eeca106725 602
Kojto 122:f9eeca106725 603 /**
Kojto 122:f9eeca106725 604 * @brief Enable the FLASH power down during Low-Power sleep mode
Kojto 122:f9eeca106725 605 * @retval none
Kojto 122:f9eeca106725 606 */
Kojto 122:f9eeca106725 607 #define __HAL_FLASH_SLEEP_POWERDOWN_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
Kojto 122:f9eeca106725 608
Kojto 122:f9eeca106725 609 /**
Kojto 122:f9eeca106725 610 * @brief Disable the FLASH power down during Low-Power sleep mode
Kojto 122:f9eeca106725 611 * @retval none
Kojto 122:f9eeca106725 612 */
Kojto 122:f9eeca106725 613 #define __HAL_FLASH_SLEEP_POWERDOWN_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
Kojto 122:f9eeca106725 614
Kojto 122:f9eeca106725 615 /**
Kojto 122:f9eeca106725 616 * @}
Kojto 122:f9eeca106725 617 */
Kojto 122:f9eeca106725 618
Kojto 122:f9eeca106725 619 /** @defgroup FLASH_Interrupt FLASH Interrupts Macros
Kojto 122:f9eeca106725 620 * @brief macros to handle FLASH interrupts
Kojto 122:f9eeca106725 621 * @{
Kojto 122:f9eeca106725 622 */
Kojto 122:f9eeca106725 623
Kojto 122:f9eeca106725 624 /**
Kojto 122:f9eeca106725 625 * @brief Enable the specified FLASH interrupt.
Kojto 122:f9eeca106725 626 * @param __INTERRUPT__: FLASH interrupt
Kojto 122:f9eeca106725 627 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 628 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
Kojto 122:f9eeca106725 629 * @arg FLASH_IT_OPERR: Error Interrupt
Kojto 122:f9eeca106725 630 * @arg FLASH_IT_RDERR: PCROP Read Error Interrupt
Kojto 122:f9eeca106725 631 * @arg FLASH_IT_ECCC: ECC Correction Interrupt
Kojto 122:f9eeca106725 632 * @retval none
Kojto 122:f9eeca106725 633 */
Kojto 122:f9eeca106725 634 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) do { if((__INTERRUPT__) & FLASH_IT_ECCC) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
Kojto 122:f9eeca106725 635 if((__INTERRUPT__) & (~FLASH_IT_ECCC)) { SET_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
Kojto 122:f9eeca106725 636 } while(0)
Kojto 122:f9eeca106725 637
Kojto 122:f9eeca106725 638 /**
Kojto 122:f9eeca106725 639 * @brief Disable the specified FLASH interrupt.
Kojto 122:f9eeca106725 640 * @param __INTERRUPT__: FLASH interrupt
Kojto 122:f9eeca106725 641 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 642 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
Kojto 122:f9eeca106725 643 * @arg FLASH_IT_OPERR: Error Interrupt
Kojto 122:f9eeca106725 644 * @arg FLASH_IT_RDERR: PCROP Read Error Interrupt
Kojto 122:f9eeca106725 645 * @arg FLASH_IT_ECCC: ECC Correction Interrupt
Kojto 122:f9eeca106725 646 * @retval none
Kojto 122:f9eeca106725 647 */
Kojto 122:f9eeca106725 648 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) do { if((__INTERRUPT__) & FLASH_IT_ECCC) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCIE); }\
Kojto 122:f9eeca106725 649 if((__INTERRUPT__) & (~FLASH_IT_ECCC)) { CLEAR_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\
Kojto 122:f9eeca106725 650 } while(0)
Kojto 122:f9eeca106725 651
Kojto 122:f9eeca106725 652 /**
Kojto 122:f9eeca106725 653 * @brief Check whether the specified FLASH flag is set or not.
Kojto 122:f9eeca106725 654 * @param __FLAG__: specifies the FLASH flag to check.
Kojto 122:f9eeca106725 655 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 656 * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
Kojto 122:f9eeca106725 657 * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
Kojto 122:f9eeca106725 658 * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
Kojto 122:f9eeca106725 659 * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
Kojto 122:f9eeca106725 660 * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
Kojto 122:f9eeca106725 661 * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
Kojto 122:f9eeca106725 662 * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
Kojto 122:f9eeca106725 663 * @arg FLASH_FLAG_MISERR: FLASH Fast programming data miss error flag
Kojto 122:f9eeca106725 664 * @arg FLASH_FLAG_FASTERR: FLASH Fast programming error flag
Kojto 122:f9eeca106725 665 * @arg FLASH_FLAG_RDERR: FLASH PCROP read error flag
Kojto 122:f9eeca106725 666 * @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag
Kojto 122:f9eeca106725 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 122:f9eeca106725 669 * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
Kojto 122:f9eeca106725 670 * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
Kojto 122:f9eeca106725 671 * @retval The new state of FLASH_FLAG (SET or RESET).
Kojto 122:f9eeca106725 672 */
Kojto 122:f9eeca106725 673 #define __HAL_FLASH_GET_FLAG(__FLAG__) (((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) ? \
Kojto 122:f9eeca106725 674 (READ_BIT(FLASH->ECCR, (__FLAG__)) == (__FLAG__)) : \
Kojto 122:f9eeca106725 675 (READ_BIT(FLASH->SR, (__FLAG__)) == (__FLAG__)))
Kojto 122:f9eeca106725 676
Kojto 122:f9eeca106725 677 /**
Kojto 122:f9eeca106725 678 * @brief Clear the FLASH's pending flags.
Kojto 122:f9eeca106725 679 * @param __FLAG__: specifies the FLASH flags to clear.
Kojto 122:f9eeca106725 680 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 681 * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
Kojto 122:f9eeca106725 682 * @arg FLASH_FLAG_OPERR: FLASH Operation error flag
Kojto 122:f9eeca106725 683 * @arg FLASH_FLAG_PROGERR: FLASH Programming error flag
Kojto 122:f9eeca106725 684 * @arg FLASH_FLAG_WRPERR: FLASH Write protection error flag
Kojto 122:f9eeca106725 685 * @arg FLASH_FLAG_PGAERR: FLASH Programming alignment error flag
Kojto 122:f9eeca106725 686 * @arg FLASH_FLAG_SIZERR: FLASH Size error flag
Kojto 122:f9eeca106725 687 * @arg FLASH_FLAG_PGSERR: FLASH Programming sequence error flag
Kojto 122:f9eeca106725 688 * @arg FLASH_FLAG_MISERR: FLASH Fast programming data miss error flag
Kojto 122:f9eeca106725 689 * @arg FLASH_FLAG_FASTERR: FLASH Fast programming error flag
Kojto 122:f9eeca106725 690 * @arg FLASH_FLAG_RDERR: FLASH PCROP read error flag
Kojto 122:f9eeca106725 691 * @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag
Kojto 122:f9eeca106725 692 * @arg FLASH_FLAG_ECCC: FLASH one ECC error has been detected and corrected
Kojto 122:f9eeca106725 693 * @arg FLASH_FLAG_ECCD: FLASH two ECC errors have been detected
Kojto 122:f9eeca106725 694 * @arg FLASH_FLAG_ALL_ERRORS: FLASH All errors flags
Kojto 122:f9eeca106725 695 * @retval None
Kojto 122:f9eeca106725 696 */
Kojto 122:f9eeca106725 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 122:f9eeca106725 698 if((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) { WRITE_REG(FLASH->SR, ((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\
Kojto 122:f9eeca106725 699 } while(0)
Kojto 122:f9eeca106725 700 /**
Kojto 122:f9eeca106725 701 * @}
Kojto 122:f9eeca106725 702 */
Kojto 122:f9eeca106725 703
Kojto 122:f9eeca106725 704 /* Include FLASH HAL Extended module */
Kojto 122:f9eeca106725 705 #include "stm32l4xx_hal_flash_ex.h"
Kojto 122:f9eeca106725 706 #include "stm32l4xx_hal_flash_ramfunc.h"
Kojto 122:f9eeca106725 707
Kojto 122:f9eeca106725 708 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 709 /** @addtogroup FLASH_Exported_Functions
Kojto 122:f9eeca106725 710 * @{
Kojto 122:f9eeca106725 711 */
Kojto 122:f9eeca106725 712
Kojto 122:f9eeca106725 713 /* Program operation functions ***********************************************/
Kojto 122:f9eeca106725 714 /** @addtogroup FLASH_Exported_Functions_Group1
Kojto 122:f9eeca106725 715 * @{
Kojto 122:f9eeca106725 716 */
Kojto 122:f9eeca106725 717 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
Kojto 122:f9eeca106725 718 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
Kojto 122:f9eeca106725 719 /* FLASH IRQ handler method */
Kojto 122:f9eeca106725 720 void HAL_FLASH_IRQHandler(void);
Kojto 122:f9eeca106725 721 /* Callbacks in non blocking modes */
Kojto 122:f9eeca106725 722 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
Kojto 122:f9eeca106725 723 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
Kojto 122:f9eeca106725 724 /**
Kojto 122:f9eeca106725 725 * @}
Kojto 122:f9eeca106725 726 */
Kojto 122:f9eeca106725 727
Kojto 122:f9eeca106725 728 /* Peripheral Control functions **********************************************/
Kojto 122:f9eeca106725 729 /** @addtogroup FLASH_Exported_Functions_Group2
Kojto 122:f9eeca106725 730 * @{
Kojto 122:f9eeca106725 731 */
Kojto 122:f9eeca106725 732 HAL_StatusTypeDef HAL_FLASH_Unlock(void);
Kojto 122:f9eeca106725 733 HAL_StatusTypeDef HAL_FLASH_Lock(void);
Kojto 122:f9eeca106725 734 /* Option bytes control */
Kojto 122:f9eeca106725 735 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
Kojto 122:f9eeca106725 736 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
Kojto 122:f9eeca106725 737 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
Kojto 122:f9eeca106725 738 /**
Kojto 122:f9eeca106725 739 * @}
Kojto 122:f9eeca106725 740 */
Kojto 122:f9eeca106725 741
Kojto 122:f9eeca106725 742 /* Peripheral State functions ************************************************/
Kojto 122:f9eeca106725 743 /** @addtogroup FLASH_Exported_Functions_Group3
Kojto 122:f9eeca106725 744 * @{
Kojto 122:f9eeca106725 745 */
Kojto 122:f9eeca106725 746 uint32_t HAL_FLASH_GetError(void);
Kojto 122:f9eeca106725 747 /**
Kojto 122:f9eeca106725 748 * @}
Kojto 122:f9eeca106725 749 */
Kojto 122:f9eeca106725 750
Kojto 122:f9eeca106725 751 /**
Kojto 122:f9eeca106725 752 * @}
Kojto 122:f9eeca106725 753 */
Kojto 122:f9eeca106725 754
Kojto 122:f9eeca106725 755 /* Private constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 756 /** @defgroup FLASH_Private_Constants FLASH Private Constants
Kojto 122:f9eeca106725 757 * @{
Kojto 122:f9eeca106725 758 */
Kojto 122:f9eeca106725 759 #define FLASH_SIZE_DATA_REGISTER ((uint32_t)0x1FFF75E0)
Kojto 122:f9eeca106725 760
Kojto 122:f9eeca106725 761 #define FLASH_SIZE ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0xFFFF)) ? (0x400 << 10) : \
Kojto 122:f9eeca106725 762 (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) << 10))
Kojto 122:f9eeca106725 763
Kojto 122:f9eeca106725 764 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 122:f9eeca106725 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 122:f9eeca106725 769
Kojto 122:f9eeca106725 770 #define FLASH_PAGE_SIZE ((uint32_t)0x800)
Kojto 122:f9eeca106725 771
Kojto 122:f9eeca106725 772 #define FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */
Kojto 122:f9eeca106725 773 /**
Kojto 122:f9eeca106725 774 * @}
Kojto 122:f9eeca106725 775 */
Kojto 122:f9eeca106725 776
Kojto 122:f9eeca106725 777 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 778 /** @defgroup FLASH_Private_Macros FLASH Private Macros
Kojto 122:f9eeca106725 779 * @{
Kojto 122:f9eeca106725 780 */
Kojto 122:f9eeca106725 781
Kojto 122:f9eeca106725 782 #define IS_FLASH_TYPEERASE(VALUE) (((VALUE) == FLASH_TYPEERASE_PAGES) || \
Kojto 122:f9eeca106725 783 ((VALUE) == FLASH_TYPEERASE_MASSERASE))
Kojto 122:f9eeca106725 784
Kojto 122:f9eeca106725 785 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 122:f9eeca106725 786 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
Kojto 122:f9eeca106725 787 ((BANK) == FLASH_BANK_2) || \
Kojto 122:f9eeca106725 788 ((BANK) == FLASH_BANK_BOTH))
Kojto 122:f9eeca106725 789
Kojto 122:f9eeca106725 790 #define IS_FLASH_BANK_EXCLUSIVE(BANK) (((BANK) == FLASH_BANK_1) || \
Kojto 122:f9eeca106725 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 122:f9eeca106725 797
Kojto 122:f9eeca106725 798 #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD) || \
Kojto 122:f9eeca106725 799 ((VALUE) == FLASH_TYPEPROGRAM_FAST) || \
Kojto 122:f9eeca106725 800 ((VALUE) == FLASH_TYPEPROGRAM_FAST_AND_LAST))
Kojto 122:f9eeca106725 801
Kojto 122:f9eeca106725 802 #define IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x400) ? \
Kojto 122:f9eeca106725 803 ((ADDRESS) <= FLASH_BASE+0xFFFFF) : ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x200) ? \
Kojto 122:f9eeca106725 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 122:f9eeca106725 807
Kojto 122:f9eeca106725 808 #define IS_FLASH_OTP_ADDRESS(ADDRESS) (((ADDRESS) >= 0x1FFF7000) && ((ADDRESS) <= 0x1FFF73FF))
Kojto 122:f9eeca106725 809
Kojto 122:f9eeca106725 810 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (IS_FLASH_MAIN_MEM_ADDRESS(ADDRESS) || IS_FLASH_OTP_ADDRESS(ADDRESS))
Kojto 122:f9eeca106725 811
Kojto 122:f9eeca106725 812 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 122:f9eeca106725 813 #define IS_FLASH_PAGE(PAGE) (((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x400) ? ((PAGE) < 256) : \
Kojto 122:f9eeca106725 814 ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x200) ? ((PAGE) < 128) : \
Kojto 122:f9eeca106725 815 ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) == 0x100) ? ((PAGE) < 64) : \
Kojto 122:f9eeca106725 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 122:f9eeca106725 822
Kojto 122:f9eeca106725 823 #define IS_OPTIONBYTE(VALUE) (((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_PCROP)))
Kojto 122:f9eeca106725 824
Kojto 122:f9eeca106725 825 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 122:f9eeca106725 826 #define IS_OB_WRPAREA(VALUE) (((VALUE) == OB_WRPAREA_BANK1_AREAA) || ((VALUE) == OB_WRPAREA_BANK1_AREAB) || \
Kojto 122:f9eeca106725 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 122:f9eeca106725 831
Kojto 122:f9eeca106725 832 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
Kojto 122:f9eeca106725 833 ((LEVEL) == OB_RDP_LEVEL_1)/* ||\
Kojto 122:f9eeca106725 834 ((LEVEL) == OB_RDP_LEVEL_2)*/)
Kojto 122:f9eeca106725 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 122:f9eeca106725 841
Kojto 122:f9eeca106725 842 #define IS_OB_USER_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL_0) || ((LEVEL) == OB_BOR_LEVEL_1) || \
Kojto 122:f9eeca106725 843 ((LEVEL) == OB_BOR_LEVEL_2) || ((LEVEL) == OB_BOR_LEVEL_3) || \
Kojto 122:f9eeca106725 844 ((LEVEL) == OB_BOR_LEVEL_4))
Kojto 122:f9eeca106725 845
Kojto 122:f9eeca106725 846 #define IS_OB_USER_STOP(VALUE) (((VALUE) == OB_STOP_RST) || ((VALUE) == OB_STOP_NORST))
Kojto 122:f9eeca106725 847
Kojto 122:f9eeca106725 848 #define IS_OB_USER_STANDBY(VALUE) (((VALUE) == OB_STANDBY_RST) || ((VALUE) == OB_STANDBY_NORST))
Kojto 122:f9eeca106725 849
Kojto 122:f9eeca106725 850 #define IS_OB_USER_SHUTDOWN(VALUE) (((VALUE) == OB_SHUTDOWN_RST) || ((VALUE) == OB_SHUTDOWN_NORST))
Kojto 122:f9eeca106725 851
Kojto 122:f9eeca106725 852 #define IS_OB_USER_IWDG(VALUE) (((VALUE) == OB_IWDG_HW) || ((VALUE) == OB_IWDG_SW))
Kojto 122:f9eeca106725 853
Kojto 122:f9eeca106725 854 #define IS_OB_USER_IWDG_STOP(VALUE) (((VALUE) == OB_IWDG_STOP_FREEZE) || ((VALUE) == OB_IWDG_STOP_RUN))
Kojto 122:f9eeca106725 855
Kojto 122:f9eeca106725 856 #define IS_OB_USER_IWDG_STDBY(VALUE) (((VALUE) == OB_IWDG_STDBY_FREEZE) || ((VALUE) == OB_IWDG_STDBY_RUN))
Kojto 122:f9eeca106725 857
Kojto 122:f9eeca106725 858 #define IS_OB_USER_WWDG(VALUE) (((VALUE) == OB_WWDG_HW) || ((VALUE) == OB_WWDG_SW))
Kojto 122:f9eeca106725 859
Kojto 122:f9eeca106725 860 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
Kojto 122:f9eeca106725 861 #define IS_OB_USER_BFB2(VALUE) (((VALUE) == OB_BFB2_DISABLE) || ((VALUE) == OB_BFB2_ENABLE))
Kojto 122:f9eeca106725 862
Kojto 122:f9eeca106725 863 #define IS_OB_USER_DUALBANK(VALUE) (((VALUE) == OB_DUALBANK_SINGLE) || ((VALUE) == OB_DUALBANK_DUAL))
Kojto 122:f9eeca106725 864 #endif
Kojto 122:f9eeca106725 865
Kojto 122:f9eeca106725 866 #define IS_OB_USER_BOOT1(VALUE) (((VALUE) == OB_BOOT1_SRAM) || ((VALUE) == OB_BOOT1_SYSTEM))
Kojto 122:f9eeca106725 867
Kojto 122:f9eeca106725 868 #define IS_OB_USER_SRAM2_PARITY(VALUE) (((VALUE) == OB_SRAM2_PARITY_ENABLE) || ((VALUE) == OB_SRAM2_PARITY_DISABLE))
Kojto 122:f9eeca106725 869
Kojto 122:f9eeca106725 870 #define IS_OB_USER_SRAM2_RST(VALUE) (((VALUE) == OB_SRAM2_RST_ERASE) || ((VALUE) == OB_SRAM2_RST_NOT_ERASE))
Kojto 122:f9eeca106725 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 122:f9eeca106725 878 #define IS_OB_PCROP_RDP(VALUE) (((VALUE) == OB_PCROP_RDP_NOT_ERASE) || ((VALUE) == OB_PCROP_RDP_ERASE))
Kojto 122:f9eeca106725 879
Kojto 122:f9eeca106725 880 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
Kojto 122:f9eeca106725 881 ((LATENCY) == FLASH_LATENCY_1) || \
Kojto 122:f9eeca106725 882 ((LATENCY) == FLASH_LATENCY_2) || \
Kojto 122:f9eeca106725 883 ((LATENCY) == FLASH_LATENCY_3) || \
Kojto 122:f9eeca106725 884 ((LATENCY) == FLASH_LATENCY_4))
Kojto 122:f9eeca106725 885 /**
Kojto 122:f9eeca106725 886 * @}
Kojto 122:f9eeca106725 887 */
Kojto 122:f9eeca106725 888
Kojto 122:f9eeca106725 889 /**
Kojto 122:f9eeca106725 890 * @}
Kojto 122:f9eeca106725 891 */
Kojto 122:f9eeca106725 892
Kojto 122:f9eeca106725 893 /**
Kojto 122:f9eeca106725 894 * @}
Kojto 122:f9eeca106725 895 */
Kojto 122:f9eeca106725 896
Kojto 122:f9eeca106725 897 #ifdef __cplusplus
Kojto 122:f9eeca106725 898 }
Kojto 122:f9eeca106725 899 #endif
Kojto 122:f9eeca106725 900
Kojto 122:f9eeca106725 901 #endif /* __STM32L4xx_HAL_FLASH_H */
Kojto 122:f9eeca106725 902
Kojto 122:f9eeca106725 903 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/