Hal Drivers for L4

Dependents:   BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo

Fork of STM32L4xx_HAL_Driver by Senior Design: Sound Monitor

Committer:
EricLew
Date:
Mon Nov 02 19:37:23 2015 +0000
Revision:
0:80ee8f3b695e
Errors are with definitions of LCD and QSPI functions. I believe all .h and .c files are  uploaded, but there may need to be certain functions called.

Who changed what in which revision?

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