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

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
93:e188a91d3eaa
12

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 93:e188a91d3eaa 1 /**
Kojto 93:e188a91d3eaa 2 ******************************************************************************
Kojto 93:e188a91d3eaa 3 * @file stm32f0xx_hal_flash.h
Kojto 93:e188a91d3eaa 4 * @author MCD Application Team
Kojto 93:e188a91d3eaa 5 * @version V1.2.0
Kojto 93:e188a91d3eaa 6 * @date 11-December-2014
Kojto 93:e188a91d3eaa 7 * @brief Header file of Flash HAL module.
Kojto 93:e188a91d3eaa 8 ******************************************************************************
Kojto 93:e188a91d3eaa 9 * @attention
Kojto 93:e188a91d3eaa 10 *
Kojto 93:e188a91d3eaa 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
Kojto 93:e188a91d3eaa 12 *
Kojto 93:e188a91d3eaa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 93:e188a91d3eaa 14 * are permitted provided that the following conditions are met:
Kojto 93:e188a91d3eaa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 93:e188a91d3eaa 16 * this list of conditions and the following disclaimer.
Kojto 93:e188a91d3eaa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 93:e188a91d3eaa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 93:e188a91d3eaa 19 * and/or other materials provided with the distribution.
Kojto 93:e188a91d3eaa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 93:e188a91d3eaa 21 * may be used to endorse or promote products derived from this software
Kojto 93:e188a91d3eaa 22 * without specific prior written permission.
Kojto 93:e188a91d3eaa 23 *
Kojto 93:e188a91d3eaa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 93:e188a91d3eaa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 93:e188a91d3eaa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 93:e188a91d3eaa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 93:e188a91d3eaa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 93:e188a91d3eaa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 93:e188a91d3eaa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 93:e188a91d3eaa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 93:e188a91d3eaa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 93:e188a91d3eaa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 93:e188a91d3eaa 34 *
Kojto 93:e188a91d3eaa 35 ******************************************************************************
Kojto 93:e188a91d3eaa 36 */
Kojto 93:e188a91d3eaa 37
Kojto 93:e188a91d3eaa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 93:e188a91d3eaa 39 #ifndef __STM32F0xx_HAL_FLASH_H
Kojto 93:e188a91d3eaa 40 #define __STM32F0xx_HAL_FLASH_H
Kojto 93:e188a91d3eaa 41
Kojto 93:e188a91d3eaa 42 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 43 extern "C" {
Kojto 93:e188a91d3eaa 44 #endif
Kojto 93:e188a91d3eaa 45
Kojto 93:e188a91d3eaa 46 /* Includes ------------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 47 #include "stm32f0xx_hal_def.h"
Kojto 93:e188a91d3eaa 48
Kojto 93:e188a91d3eaa 49 /** @addtogroup STM32F0xx_HAL_Driver
Kojto 93:e188a91d3eaa 50 * @{
Kojto 93:e188a91d3eaa 51 */
Kojto 93:e188a91d3eaa 52
Kojto 93:e188a91d3eaa 53 /** @addtogroup FLASH
Kojto 93:e188a91d3eaa 54 * @{
Kojto 93:e188a91d3eaa 55 */
Kojto 93:e188a91d3eaa 56
Kojto 93:e188a91d3eaa 57 /* Exported types ------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 58
Kojto 93:e188a91d3eaa 59 /** @defgroup FLASH_Exported_Types FLASH Exported Types
Kojto 93:e188a91d3eaa 60 * @{
Kojto 93:e188a91d3eaa 61 */
Kojto 93:e188a91d3eaa 62
Kojto 93:e188a91d3eaa 63 /**
Kojto 93:e188a91d3eaa 64 * @brief FLASH Erase structure definition
Kojto 93:e188a91d3eaa 65 */
Kojto 93:e188a91d3eaa 66 typedef struct
Kojto 93:e188a91d3eaa 67 {
Kojto 93:e188a91d3eaa 68 uint32_t TypeErase; /*!< TypeErase: Mass erase or page erase.
Kojto 93:e188a91d3eaa 69 This parameter can be a value of @ref FLASH_Type_Erase */
Kojto 93:e188a91d3eaa 70
Kojto 93:e188a91d3eaa 71 uint32_t PageAddress; /*!< PageAdress: Initial FLASH page address to erase when mass erase is disabled
Kojto 93:e188a91d3eaa 72 This parameter must be a value of @ref FLASHEx_Address */
Kojto 93:e188a91d3eaa 73
Kojto 93:e188a91d3eaa 74 uint32_t NbPages; /*!< NbPages: Number of pagess to be erased.
Kojto 93:e188a91d3eaa 75 This parameter must be a value between 1 and (max number of pages - value of initial page)*/
Kojto 93:e188a91d3eaa 76
Kojto 93:e188a91d3eaa 77 } FLASH_EraseInitTypeDef;
Kojto 93:e188a91d3eaa 78
Kojto 93:e188a91d3eaa 79 /**
Kojto 93:e188a91d3eaa 80 * @brief FLASH Options bytes program structure definition
Kojto 93:e188a91d3eaa 81 */
Kojto 93:e188a91d3eaa 82 typedef struct
Kojto 93:e188a91d3eaa 83 {
Kojto 93:e188a91d3eaa 84 uint32_t OptionType; /*!< OptionType: Option byte to be configured.
Kojto 93:e188a91d3eaa 85 This parameter can be a value of @ref FLASH_OB_Type */
Kojto 93:e188a91d3eaa 86
Kojto 93:e188a91d3eaa 87 uint32_t WRPState; /*!< WRPState: Write protection activation or deactivation.
Kojto 93:e188a91d3eaa 88 This parameter can be a value of @ref FLASH_OB_WRP_State */
Kojto 93:e188a91d3eaa 89
Kojto 93:e188a91d3eaa 90 uint32_t WRPPage; /*!< WRPSector: specifies the page(s) to be write protected
Kojto 93:e188a91d3eaa 91 This parameter can be a value of @ref FLASHEx_OB_Write_Protection */
Kojto 93:e188a91d3eaa 92
Kojto 93:e188a91d3eaa 93 uint8_t RDPLevel; /*!< RDPLevel: Set the read protection level..
Kojto 93:e188a91d3eaa 94 This parameter can be a value of @ref FLASH_OB_Read_Protection */
Kojto 93:e188a91d3eaa 95
Kojto 93:e188a91d3eaa 96 uint8_t USERConfig; /*!< USERConfig: Program the FLASH User Option Byte:
Kojto 93:e188a91d3eaa 97 IWDG / STOP / STDBY / BOOT1 / VDDA_ANALOG / SRAM_PARITY
Kojto 93:e188a91d3eaa 98 This parameter can be a combination of @ref FLASH_OB_Watchdog, @ref FLASH_OB_nRST_STOP,
Kojto 93:e188a91d3eaa 99 @ref FLASH_OB_nRST_STDBY, @ref FLASH_OB_BOOT1, @ref FLASH_OB_VDDA_Analog_Monitoring and
Kojto 93:e188a91d3eaa 100 @ref FLASH_OB_RAM_Parity_Check_Enable */
Kojto 93:e188a91d3eaa 101
Kojto 93:e188a91d3eaa 102 uint32_t DATAAddress; /*!< DATAAddress: Address of the option byte DATA to be prgrammed
Kojto 93:e188a91d3eaa 103 This parameter can be a value of @ref FLASH_OB_Data_Address */
Kojto 93:e188a91d3eaa 104
Kojto 93:e188a91d3eaa 105 uint8_t DATAData; /*!< DATAData: Data to be stored in the option byte DATA
Kojto 93:e188a91d3eaa 106 This parameter can have any value */
Kojto 93:e188a91d3eaa 107
Kojto 93:e188a91d3eaa 108 } FLASH_OBProgramInitTypeDef;
Kojto 93:e188a91d3eaa 109
Kojto 93:e188a91d3eaa 110 /**
Kojto 93:e188a91d3eaa 111 * @brief FLASH Procedure structure definition
Kojto 93:e188a91d3eaa 112 */
Kojto 93:e188a91d3eaa 113 typedef enum
Kojto 93:e188a91d3eaa 114 {
Kojto 93:e188a91d3eaa 115 FLASH_PROC_NONE = 0,
Kojto 93:e188a91d3eaa 116 FLASH_PROC_PAGEERASE = 1,
Kojto 93:e188a91d3eaa 117 FLASH_PROC_MASSERASE = 2,
Kojto 93:e188a91d3eaa 118 FLASH_PROC_PROGRAMHALFWORD = 3,
Kojto 93:e188a91d3eaa 119 FLASH_PROC_PROGRAMWORD = 4,
Kojto 93:e188a91d3eaa 120 FLASH_PROC_PROGRAMDOUBLEWORD = 5
Kojto 93:e188a91d3eaa 121 } FLASH_ProcedureTypeDef;
Kojto 93:e188a91d3eaa 122
Kojto 93:e188a91d3eaa 123 /**
Kojto 93:e188a91d3eaa 124 * @brief FLASH handle Structure definition
Kojto 93:e188a91d3eaa 125 */
Kojto 93:e188a91d3eaa 126 typedef struct
Kojto 93:e188a91d3eaa 127 {
Kojto 93:e188a91d3eaa 128 __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
Kojto 93:e188a91d3eaa 129
Kojto 93:e188a91d3eaa 130 __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */
Kojto 93:e188a91d3eaa 131
Kojto 93:e188a91d3eaa 132 __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */
Kojto 93:e188a91d3eaa 133
Kojto 93:e188a91d3eaa 134 __IO uint64_t Data; /*!< Internal variable to save data to be programmed */
Kojto 93:e188a91d3eaa 135
Kojto 93:e188a91d3eaa 136 HAL_LockTypeDef Lock; /*!< FLASH locking object */
Kojto 93:e188a91d3eaa 137
Kojto 93:e188a91d3eaa 138 __IO uint32_t ErrorCode; /*!< FLASH error code
Kojto 93:e188a91d3eaa 139 This parameter can be a value of @ref FLASH_Error */
Kojto 93:e188a91d3eaa 140
Kojto 93:e188a91d3eaa 141 } FLASH_ProcessTypeDef;
Kojto 93:e188a91d3eaa 142
Kojto 93:e188a91d3eaa 143 /**
Kojto 93:e188a91d3eaa 144 * @}
Kojto 93:e188a91d3eaa 145 */
Kojto 93:e188a91d3eaa 146
Kojto 93:e188a91d3eaa 147 /* Exported constants --------------------------------------------------------*/
Kojto 93:e188a91d3eaa 148
Kojto 93:e188a91d3eaa 149 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
Kojto 93:e188a91d3eaa 150 * @{
Kojto 93:e188a91d3eaa 151 */
Kojto 93:e188a91d3eaa 152
Kojto 93:e188a91d3eaa 153 /** @defgroup FLASH_Error FLASH Error
Kojto 93:e188a91d3eaa 154 * @{
Kojto 93:e188a91d3eaa 155 */
Kojto 93:e188a91d3eaa 156 #define FLASH_ERROR_NONE ((uint32_t)0x00000000)
Kojto 93:e188a91d3eaa 157 #define FLASH_ERROR_PG ((uint32_t)0x00000001)
Kojto 93:e188a91d3eaa 158 #define FLASH_ERROR_WRP ((uint32_t)0x00000002)
Kojto 93:e188a91d3eaa 159 /**
Kojto 93:e188a91d3eaa 160 * @}
Kojto 93:e188a91d3eaa 161 */
Kojto 93:e188a91d3eaa 162
Kojto 93:e188a91d3eaa 163 /** @defgroup FLASH_Type_Erase FLASH Type Erase
Kojto 93:e188a91d3eaa 164 * @{
Kojto 93:e188a91d3eaa 165 */
Kojto 93:e188a91d3eaa 166 #define TYPEERASE_PAGES ((uint32_t)0x00) /*!<Pages erase only*/
Kojto 93:e188a91d3eaa 167 #define TYPEERASE_MASSERASE ((uint32_t)0x01) /*!<Flash mass erase activation*/
Kojto 93:e188a91d3eaa 168
Kojto 93:e188a91d3eaa 169 #define IS_TYPEERASE(VALUE) (((VALUE) == TYPEERASE_PAGES) || \
Kojto 93:e188a91d3eaa 170 ((VALUE) == TYPEERASE_MASSERASE))
Kojto 93:e188a91d3eaa 171 /**
Kojto 93:e188a91d3eaa 172 * @}
Kojto 93:e188a91d3eaa 173 */
Kojto 93:e188a91d3eaa 174
Kojto 93:e188a91d3eaa 175 /** @defgroup FLASH_Type_Program FLASH Type Program
Kojto 93:e188a91d3eaa 176 * @{
Kojto 93:e188a91d3eaa 177 */
Kojto 93:e188a91d3eaa 178 #define TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!<Program a half-word (16-bit) at a specified address.*/
Kojto 93:e188a91d3eaa 179 #define TYPEPROGRAM_WORD ((uint32_t)0x02) /*!<Program a word (32-bit) at a specified address.*/
Kojto 93:e188a91d3eaa 180 #define TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03) /*!<Program a double word (64-bit) at a specified address*/
Kojto 93:e188a91d3eaa 181
Kojto 93:e188a91d3eaa 182 #define IS_TYPEPROGRAM(VALUE) (((VALUE) == TYPEPROGRAM_HALFWORD) || \
Kojto 93:e188a91d3eaa 183 ((VALUE) == TYPEPROGRAM_WORD) || \
Kojto 93:e188a91d3eaa 184 ((VALUE) == TYPEPROGRAM_DOUBLEWORD))
Kojto 93:e188a91d3eaa 185 /**
Kojto 93:e188a91d3eaa 186 * @}
Kojto 93:e188a91d3eaa 187 */
Kojto 93:e188a91d3eaa 188
Kojto 93:e188a91d3eaa 189 /** @defgroup FLASH_OB_WRP_State FLASH WRP State
Kojto 93:e188a91d3eaa 190 * @{
Kojto 93:e188a91d3eaa 191 */
Kojto 93:e188a91d3eaa 192 #define WRPSTATE_DISABLE ((uint32_t)0x00) /*!<Disable the write protection of the desired pages*/
Kojto 93:e188a91d3eaa 193 #define WRPSTATE_ENABLE ((uint32_t)0x01) /*!<Enable the write protection of the desired pagess*/
Kojto 93:e188a91d3eaa 194
Kojto 93:e188a91d3eaa 195 #define IS_WRPSTATE(VALUE) (((VALUE) == WRPSTATE_DISABLE) || \
Kojto 93:e188a91d3eaa 196 ((VALUE) == WRPSTATE_ENABLE))
Kojto 93:e188a91d3eaa 197 /**
Kojto 93:e188a91d3eaa 198 * @}
Kojto 93:e188a91d3eaa 199 */
Kojto 93:e188a91d3eaa 200
Kojto 93:e188a91d3eaa 201 /** @defgroup FLASH_OB_Type FLASH Option Bytes Type
Kojto 93:e188a91d3eaa 202 * @{
Kojto 93:e188a91d3eaa 203 */
Kojto 93:e188a91d3eaa 204 #define OPTIONBYTE_WRP ((uint32_t)0x01) /*!<WRP option byte configuration*/
Kojto 93:e188a91d3eaa 205 #define OPTIONBYTE_RDP ((uint32_t)0x02) /*!<RDP option byte configuration*/
Kojto 93:e188a91d3eaa 206 #define OPTIONBYTE_USER ((uint32_t)0x04) /*!<USER option byte configuration*/
Kojto 93:e188a91d3eaa 207 #define OPTIONBYTE_DATA ((uint32_t)0x08) /*!<DATA option byte configuration*/
Kojto 93:e188a91d3eaa 208
Kojto 93:e188a91d3eaa 209 #define IS_OPTIONBYTE(VALUE) ((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_DATA))
Kojto 93:e188a91d3eaa 210 /**
Kojto 93:e188a91d3eaa 211 * @}
Kojto 93:e188a91d3eaa 212 */
Kojto 93:e188a91d3eaa 213
Kojto 93:e188a91d3eaa 214 /** @defgroup FLASH_Latency FLASH Latency
Kojto 93:e188a91d3eaa 215 * @{
Kojto 93:e188a91d3eaa 216 */
Kojto 93:e188a91d3eaa 217 #define FLASH_LATENCY_0 ((uint32_t)0x00000000) /*!< FLASH Zero Latency cycle */
Kojto 93:e188a91d3eaa 218 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One Latency cycle */
Kojto 93:e188a91d3eaa 219
Kojto 93:e188a91d3eaa 220 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
Kojto 93:e188a91d3eaa 221 ((LATENCY) == FLASH_LATENCY_1))
Kojto 93:e188a91d3eaa 222 /**
Kojto 93:e188a91d3eaa 223 * @}
Kojto 93:e188a91d3eaa 224 */
Kojto 93:e188a91d3eaa 225
Kojto 93:e188a91d3eaa 226 /** @defgroup FLASH_OB_Data_Address FLASH OB Data Address
Kojto 93:e188a91d3eaa 227 * @{
Kojto 93:e188a91d3eaa 228 */
Kojto 93:e188a91d3eaa 229 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
Kojto 93:e188a91d3eaa 230 /**
Kojto 93:e188a91d3eaa 231 * @}
Kojto 93:e188a91d3eaa 232 */
Kojto 93:e188a91d3eaa 233
Kojto 93:e188a91d3eaa 234 /** @defgroup FLASH_OB_Read_Protection FLASH OB Read Protection
Kojto 93:e188a91d3eaa 235 * @{
Kojto 93:e188a91d3eaa 236 */
Kojto 93:e188a91d3eaa 237 #define OB_RDP_LEVEL_0 ((uint8_t)0xAA)
Kojto 93:e188a91d3eaa 238 #define OB_RDP_LEVEL_1 ((uint8_t)0xBB)
Kojto 93:e188a91d3eaa 239 #define OB_RDP_LEVEL_2 ((uint8_t)0xCC) /*!< Warning: When enabling read protection level 2
Kojto 93:e188a91d3eaa 240 it's no more possible to go back to level 1 or 0 */
Kojto 93:e188a91d3eaa 241 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
Kojto 93:e188a91d3eaa 242 ((LEVEL) == OB_RDP_LEVEL_1))/*||\
Kojto 93:e188a91d3eaa 243 ((LEVEL) == OB_RDP_LEVEL_2))*/
Kojto 93:e188a91d3eaa 244 /**
Kojto 93:e188a91d3eaa 245 * @}
Kojto 93:e188a91d3eaa 246 */
Kojto 93:e188a91d3eaa 247
Kojto 93:e188a91d3eaa 248 /** @defgroup FLASH_OB_Watchdog FLASH OB Watchdog
Kojto 93:e188a91d3eaa 249 * @{
Kojto 93:e188a91d3eaa 250 */
Kojto 93:e188a91d3eaa 251 #define OB_WDG_SW ((uint8_t)0x01) /*!< Software WDG selected */
Kojto 93:e188a91d3eaa 252 #define OB_WDG_HW ((uint8_t)0x00) /*!< Hardware WDG selected */
Kojto 93:e188a91d3eaa 253 #define IS_OB_WDG_SOURCE(SOURCE) (((SOURCE) == OB_WDG_SW) || ((SOURCE) == OB_WDG_HW))
Kojto 93:e188a91d3eaa 254 /**
Kojto 93:e188a91d3eaa 255 * @}
Kojto 93:e188a91d3eaa 256 */
Kojto 93:e188a91d3eaa 257
Kojto 93:e188a91d3eaa 258 /** @defgroup FLASH_OB_nRST_STOP FLASH OB nRST STOP
Kojto 93:e188a91d3eaa 259 * @{
Kojto 93:e188a91d3eaa 260 */
Kojto 93:e188a91d3eaa 261 #define OB_STOP_NO_RST ((uint8_t)0x02) /*!< No reset generated when entering in STOP */
Kojto 93:e188a91d3eaa 262 #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
Kojto 93:e188a91d3eaa 263 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
Kojto 93:e188a91d3eaa 264 /**
Kojto 93:e188a91d3eaa 265 * @}
Kojto 93:e188a91d3eaa 266 */
Kojto 93:e188a91d3eaa 267
Kojto 93:e188a91d3eaa 268 /** @defgroup FLASH_OB_nRST_STDBY FLASH OB nRST STDBY
Kojto 93:e188a91d3eaa 269 * @{
Kojto 93:e188a91d3eaa 270 */
Kojto 93:e188a91d3eaa 271 #define OB_STDBY_NO_RST ((uint8_t)0x04) /*!< No reset generated when entering in STANDBY */
Kojto 93:e188a91d3eaa 272 #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
Kojto 93:e188a91d3eaa 273 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
Kojto 93:e188a91d3eaa 274 /**
Kojto 93:e188a91d3eaa 275 * @}
Kojto 93:e188a91d3eaa 276 */
Kojto 93:e188a91d3eaa 277
Kojto 93:e188a91d3eaa 278 /** @defgroup FLASH_OB_BOOT1 FLASH OB BOOT1
Kojto 93:e188a91d3eaa 279 * @{
Kojto 93:e188a91d3eaa 280 */
Kojto 93:e188a91d3eaa 281 #define OB_BOOT1_RESET ((uint8_t)0x00) /*!< BOOT1 Reset */
Kojto 93:e188a91d3eaa 282 #define OB_BOOT1_SET ((uint8_t)0x10) /*!< BOOT1 Set */
Kojto 93:e188a91d3eaa 283 #define IS_OB_BOOT1(BOOT1) (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET))
Kojto 93:e188a91d3eaa 284 /**
Kojto 93:e188a91d3eaa 285 * @}
Kojto 93:e188a91d3eaa 286 */
Kojto 93:e188a91d3eaa 287
Kojto 93:e188a91d3eaa 288 /** @defgroup FLASH_OB_VDDA_Analog_Monitoring FLASH OB VDDA Analog Monitoring
Kojto 93:e188a91d3eaa 289 * @{
Kojto 93:e188a91d3eaa 290 */
Kojto 93:e188a91d3eaa 291 #define OB_VDDA_ANALOG_ON ((uint8_t)0x20) /*!< Analog monitoring on VDDA Power source ON */
Kojto 93:e188a91d3eaa 292 #define OB_VDDA_ANALOG_OFF ((uint8_t)0x00) /*!< Analog monitoring on VDDA Power source OFF */
Kojto 93:e188a91d3eaa 293 #define IS_OB_VDDA_ANALOG(ANALOG) (((ANALOG) == OB_VDDA_ANALOG_ON) || ((ANALOG) == OB_VDDA_ANALOG_OFF))
Kojto 93:e188a91d3eaa 294 /**
Kojto 93:e188a91d3eaa 295 * @}
Kojto 93:e188a91d3eaa 296 */
Kojto 93:e188a91d3eaa 297
Kojto 93:e188a91d3eaa 298 /** @defgroup FLASH_OB_RAM_Parity_Check_Enable FLASH OB RAM Parity Check Enable
Kojto 93:e188a91d3eaa 299 * @{
Kojto 93:e188a91d3eaa 300 */
Kojto 93:e188a91d3eaa 301 #define OB_RAM_PARITY_CHECK_SET ((uint8_t)0x00) /*!< RAM parity check enable set */
Kojto 93:e188a91d3eaa 302 #define OB_RAM_PARITY_CHECK_RESET ((uint8_t)0x40) /*!< RAM parity check enable reset */
Kojto 93:e188a91d3eaa 303 #define IS_OB_SRAM_PARITY(PARITY) (((PARITY) == OB_RAM_PARITY_CHECK_SET) || ((PARITY) == OB_RAM_PARITY_CHECK_RESET))
Kojto 93:e188a91d3eaa 304 /**
Kojto 93:e188a91d3eaa 305 * @}
Kojto 93:e188a91d3eaa 306 */
Kojto 93:e188a91d3eaa 307
Kojto 93:e188a91d3eaa 308 /** @defgroup FLASH_Flag_definition FLASH Flag definition
Kojto 93:e188a91d3eaa 309 * @{
Kojto 93:e188a91d3eaa 310 */
Kojto 93:e188a91d3eaa 311 #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */
Kojto 93:e188a91d3eaa 312 #define FLASH_FLAG_PGERR FLASH_SR_PGERR /*!< FLASH Programming error flag */
Kojto 93:e188a91d3eaa 313 #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */
Kojto 93:e188a91d3eaa 314 #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */
Kojto 93:e188a91d3eaa 315 /**
Kojto 93:e188a91d3eaa 316 * @}
Kojto 93:e188a91d3eaa 317 */
Kojto 93:e188a91d3eaa 318
Kojto 93:e188a91d3eaa 319 /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition
Kojto 93:e188a91d3eaa 320 * @{
Kojto 93:e188a91d3eaa 321 */
Kojto 93:e188a91d3eaa 322 #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */
Kojto 93:e188a91d3eaa 323 #define FLASH_IT_ERR FLASH_CR_ERRIE /*!< Error Interrupt source */
Kojto 93:e188a91d3eaa 324 /**
Kojto 93:e188a91d3eaa 325 * @}
Kojto 93:e188a91d3eaa 326 */
Kojto 93:e188a91d3eaa 327
Kojto 93:e188a91d3eaa 328 /** @defgroup FLASH_Timeout_definition FLASH Timeout definition
Kojto 93:e188a91d3eaa 329 * @brief FLASH Timeout definition
Kojto 93:e188a91d3eaa 330 * @{
Kojto 93:e188a91d3eaa 331 */
Kojto 93:e188a91d3eaa 332 #define HAL_FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */
Kojto 93:e188a91d3eaa 333 /**
Kojto 93:e188a91d3eaa 334 * @}
Kojto 93:e188a91d3eaa 335 */
Kojto 93:e188a91d3eaa 336
Kojto 93:e188a91d3eaa 337 /**
Kojto 93:e188a91d3eaa 338 * @}
Kojto 93:e188a91d3eaa 339 */
Kojto 93:e188a91d3eaa 340
Kojto 93:e188a91d3eaa 341 /* Exported macro ------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 342
Kojto 93:e188a91d3eaa 343 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
Kojto 93:e188a91d3eaa 344 * @brief macros to control FLASH features
Kojto 93:e188a91d3eaa 345 * @{
Kojto 93:e188a91d3eaa 346 */
Kojto 93:e188a91d3eaa 347
Kojto 93:e188a91d3eaa 348 /** @defgroup FLASH_Latency FLASH Latency
Kojto 93:e188a91d3eaa 349 * @brief macros to handle FLASH Latency
Kojto 93:e188a91d3eaa 350 * @{
Kojto 93:e188a91d3eaa 351 */
Kojto 93:e188a91d3eaa 352
Kojto 93:e188a91d3eaa 353 /**
Kojto 93:e188a91d3eaa 354 * @brief Set the FLASH Latency.
Kojto 93:e188a91d3eaa 355 * @param __LATENCY__: FLASH Latency
Kojto 93:e188a91d3eaa 356 * The value of this parameter depend on device used within the same series
Kojto 93:e188a91d3eaa 357 * @retval None
Kojto 93:e188a91d3eaa 358 */
Kojto 93:e188a91d3eaa 359 #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
Kojto 93:e188a91d3eaa 360 /**
Kojto 93:e188a91d3eaa 361 * @}
Kojto 93:e188a91d3eaa 362 */
Kojto 93:e188a91d3eaa 363
Kojto 93:e188a91d3eaa 364 /** @defgroup FLASH_Prefetch FLASH Prefetch
Kojto 93:e188a91d3eaa 365 * @brief macros to handle FLASH Prefetch buffer
Kojto 93:e188a91d3eaa 366 * @{
Kojto 93:e188a91d3eaa 367 */
Kojto 93:e188a91d3eaa 368 /**
Kojto 93:e188a91d3eaa 369 * @brief Enable the FLASH prefetch buffer.
Kojto 93:e188a91d3eaa 370 * @retval None
Kojto 93:e188a91d3eaa 371 */
Kojto 93:e188a91d3eaa 372 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE)
Kojto 93:e188a91d3eaa 373
Kojto 93:e188a91d3eaa 374 /**
Kojto 93:e188a91d3eaa 375 * @brief Disable the FLASH prefetch buffer.
Kojto 93:e188a91d3eaa 376 * @retval None
Kojto 93:e188a91d3eaa 377 */
Kojto 93:e188a91d3eaa 378 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
Kojto 93:e188a91d3eaa 379
Kojto 93:e188a91d3eaa 380 /**
Kojto 93:e188a91d3eaa 381 * @}
Kojto 93:e188a91d3eaa 382 */
Kojto 93:e188a91d3eaa 383
Kojto 93:e188a91d3eaa 384 /** @defgroup FLASH_Interrupt FLASH Interrupt
Kojto 93:e188a91d3eaa 385 * @brief macros to handle FLASH interrupts
Kojto 93:e188a91d3eaa 386 * @{
Kojto 93:e188a91d3eaa 387 */
Kojto 93:e188a91d3eaa 388
Kojto 93:e188a91d3eaa 389 /**
Kojto 93:e188a91d3eaa 390 * @brief Enable the specified FLASH interrupt.
Kojto 93:e188a91d3eaa 391 * @param __INTERRUPT__ : FLASH interrupt
Kojto 93:e188a91d3eaa 392 * This parameter can be any combination of the following values:
Kojto 93:e188a91d3eaa 393 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
Kojto 93:e188a91d3eaa 394 * @arg FLASH_IT_ERR: Error Interrupt
Kojto 93:e188a91d3eaa 395 * @retval none
Kojto 93:e188a91d3eaa 396 */
Kojto 93:e188a91d3eaa 397 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (FLASH->CR |= (__INTERRUPT__))
Kojto 93:e188a91d3eaa 398
Kojto 93:e188a91d3eaa 399 /**
Kojto 93:e188a91d3eaa 400 * @brief Disable the specified FLASH interrupt.
Kojto 93:e188a91d3eaa 401 * @param __INTERRUPT__ : FLASH interrupt
Kojto 93:e188a91d3eaa 402 * This parameter can be any combination of the following values:
Kojto 93:e188a91d3eaa 403 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
Kojto 93:e188a91d3eaa 404 * @arg FLASH_IT_ERR: Error Interrupt
Kojto 93:e188a91d3eaa 405 * @retval none
Kojto 93:e188a91d3eaa 406 */
Kojto 93:e188a91d3eaa 407 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (FLASH->CR &= ~(uint32_t)(__INTERRUPT__))
Kojto 93:e188a91d3eaa 408
Kojto 93:e188a91d3eaa 409 /**
Kojto 93:e188a91d3eaa 410 * @brief Get the specified FLASH flag status.
Kojto 93:e188a91d3eaa 411 * @param __FLAG__: specifies the FLASH flag to check.
Kojto 93:e188a91d3eaa 412 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 413 * @arg FLASH_FLAG_EOP : FLASH End of Operation flag
Kojto 93:e188a91d3eaa 414 * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag
Kojto 93:e188a91d3eaa 415 * @arg FLASH_FLAG_PGERR : FLASH Programming error flag
Kojto 93:e188a91d3eaa 416 * @arg FLASH_FLAG_BSY : FLASH Busy flag
Kojto 93:e188a91d3eaa 417 * @retval The new state of __FLAG__ (SET or RESET).
Kojto 93:e188a91d3eaa 418 */
Kojto 93:e188a91d3eaa 419 #define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__)) == (__FLAG__))
Kojto 93:e188a91d3eaa 420
Kojto 93:e188a91d3eaa 421 /**
Kojto 93:e188a91d3eaa 422 * @brief Clear the specified FLASH flag.
Kojto 93:e188a91d3eaa 423 * @param __FLAG__: specifies the FLASH flags to clear.
Kojto 93:e188a91d3eaa 424 * This parameter can be any combination of the following values:
Kojto 93:e188a91d3eaa 425 * @arg FLASH_FLAG_EOP : FLASH End of Operation flag
Kojto 93:e188a91d3eaa 426 * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag
Kojto 93:e188a91d3eaa 427 * @arg FLASH_FLAG_PGERR : FLASH Programming error flag
Kojto 93:e188a91d3eaa 428 * @retval none
Kojto 93:e188a91d3eaa 429 */
Kojto 93:e188a91d3eaa 430 #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (FLASH->SR = (__FLAG__))
Kojto 93:e188a91d3eaa 431
Kojto 93:e188a91d3eaa 432 /**
Kojto 93:e188a91d3eaa 433 * @}
Kojto 93:e188a91d3eaa 434 */
Kojto 93:e188a91d3eaa 435
Kojto 93:e188a91d3eaa 436 /**
Kojto 93:e188a91d3eaa 437 * @}
Kojto 93:e188a91d3eaa 438 */
Kojto 93:e188a91d3eaa 439
Kojto 93:e188a91d3eaa 440 /* Include FLASH HAL Extension module */
Kojto 93:e188a91d3eaa 441 #include "stm32f0xx_hal_flash_ex.h"
Kojto 93:e188a91d3eaa 442
Kojto 93:e188a91d3eaa 443 /* Exported functions --------------------------------------------------------*/
Kojto 93:e188a91d3eaa 444
Kojto 93:e188a91d3eaa 445 /** @addtogroup FLASH_Exported_Functions
Kojto 93:e188a91d3eaa 446 * @{
Kojto 93:e188a91d3eaa 447 */
Kojto 93:e188a91d3eaa 448
Kojto 93:e188a91d3eaa 449 /** @addtogroup FLASH_Exported_Functions_Group1
Kojto 93:e188a91d3eaa 450 * @brief Data transfers functions
Kojto 93:e188a91d3eaa 451 * @{
Kojto 93:e188a91d3eaa 452 */
Kojto 93:e188a91d3eaa 453
Kojto 93:e188a91d3eaa 454 /* IO operation functions *****************************************************/
Kojto 93:e188a91d3eaa 455 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
Kojto 93:e188a91d3eaa 456 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
Kojto 93:e188a91d3eaa 457
Kojto 93:e188a91d3eaa 458 /* FLASH IRQ handler method */
Kojto 93:e188a91d3eaa 459 void HAL_FLASH_IRQHandler(void);
Kojto 93:e188a91d3eaa 460 /* Callbacks in non blocking modes */
Kojto 93:e188a91d3eaa 461 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
Kojto 93:e188a91d3eaa 462 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
Kojto 93:e188a91d3eaa 463
Kojto 93:e188a91d3eaa 464 /**
Kojto 93:e188a91d3eaa 465 * @}
Kojto 93:e188a91d3eaa 466 */
Kojto 93:e188a91d3eaa 467
Kojto 93:e188a91d3eaa 468 /** @addtogroup FLASH_Exported_Functions_Group2
Kojto 93:e188a91d3eaa 469 * @brief management functions
Kojto 93:e188a91d3eaa 470 * @{
Kojto 93:e188a91d3eaa 471 */
Kojto 93:e188a91d3eaa 472
Kojto 93:e188a91d3eaa 473 /* FLASH Memory Programming functions *****************************************/
Kojto 93:e188a91d3eaa 474 HAL_StatusTypeDef HAL_FLASH_Unlock(void);
Kojto 93:e188a91d3eaa 475 HAL_StatusTypeDef HAL_FLASH_Lock(void);
Kojto 93:e188a91d3eaa 476
Kojto 93:e188a91d3eaa 477 /* Option Bytes Programming functions *****************************************/
Kojto 93:e188a91d3eaa 478 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
Kojto 93:e188a91d3eaa 479 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
Kojto 93:e188a91d3eaa 480 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
Kojto 93:e188a91d3eaa 481
Kojto 93:e188a91d3eaa 482 /**
Kojto 93:e188a91d3eaa 483 * @}
Kojto 93:e188a91d3eaa 484 */
Kojto 93:e188a91d3eaa 485
Kojto 93:e188a91d3eaa 486 /** @addtogroup FLASH_Exported_Functions_Group3
Kojto 93:e188a91d3eaa 487 * @{
Kojto 93:e188a91d3eaa 488 */
Kojto 93:e188a91d3eaa 489 /* Peripheral State and Error functions ***************************************/
Kojto 93:e188a91d3eaa 490 uint32_t HAL_FLASH_GetError(void);
Kojto 93:e188a91d3eaa 491
Kojto 93:e188a91d3eaa 492 /**
Kojto 93:e188a91d3eaa 493 * @}
Kojto 93:e188a91d3eaa 494 */
Kojto 93:e188a91d3eaa 495
Kojto 93:e188a91d3eaa 496 /**
Kojto 93:e188a91d3eaa 497 * @}
Kojto 93:e188a91d3eaa 498 */
Kojto 93:e188a91d3eaa 499
Kojto 93:e188a91d3eaa 500 /**
Kojto 93:e188a91d3eaa 501 * @}
Kojto 93:e188a91d3eaa 502 */
Kojto 93:e188a91d3eaa 503
Kojto 93:e188a91d3eaa 504 /**
Kojto 93:e188a91d3eaa 505 * @}
Kojto 93:e188a91d3eaa 506 */
Kojto 93:e188a91d3eaa 507
Kojto 93:e188a91d3eaa 508 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 509 }
Kojto 93:e188a91d3eaa 510 #endif
Kojto 93:e188a91d3eaa 511
Kojto 93:e188a91d3eaa 512 #endif /* __STM32F0xx_HAL_FLASH_H */
Kojto 93:e188a91d3eaa 513
Kojto 93:e188a91d3eaa 514 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 93:e188a91d3eaa 515