I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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