my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Thu Nov 27 13:33:22 2014 +0000
Revision:
92:4fc01daae5a5
Parent:
84:0b3ab51c8877
Child:
96:487b796308b0
Release 92 of the mbed libray

Main changes:

- nRF51822: fixed pin assignment issues
- ST targets moving to the STM32Cube driver
- LPC1439: fixed serial interrupt issue
- first Cortex-A platform supported in mbed (RZ_A1H)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 84:0b3ab51c8877 1 /**
bogdanm 84:0b3ab51c8877 2 ******************************************************************************
bogdanm 84:0b3ab51c8877 3 * @file stm32l0xx_hal_flash.h
bogdanm 84:0b3ab51c8877 4 * @author MCD Application Team
bogdanm 92:4fc01daae5a5 5 * @version V1.1.0
bogdanm 92:4fc01daae5a5 6 * @date 18-June-2014
bogdanm 84:0b3ab51c8877 7 * @brief This file contains all the functions prototypes for the FLASH
bogdanm 84:0b3ab51c8877 8 * firmware library.
bogdanm 84:0b3ab51c8877 9 ******************************************************************************
bogdanm 84:0b3ab51c8877 10 * @attention
bogdanm 84:0b3ab51c8877 11 *
bogdanm 84:0b3ab51c8877 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 84:0b3ab51c8877 13 *
bogdanm 84:0b3ab51c8877 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 84:0b3ab51c8877 15 * are permitted provided that the following conditions are met:
bogdanm 84:0b3ab51c8877 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 84:0b3ab51c8877 17 * this list of conditions and the following disclaimer.
bogdanm 84:0b3ab51c8877 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 84:0b3ab51c8877 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 84:0b3ab51c8877 20 * and/or other materials provided with the distribution.
bogdanm 84:0b3ab51c8877 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 84:0b3ab51c8877 22 * may be used to endorse or promote products derived from this software
bogdanm 84:0b3ab51c8877 23 * without specific prior written permission.
bogdanm 84:0b3ab51c8877 24 *
bogdanm 84:0b3ab51c8877 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 84:0b3ab51c8877 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 84:0b3ab51c8877 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 84:0b3ab51c8877 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 84:0b3ab51c8877 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 84:0b3ab51c8877 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 84:0b3ab51c8877 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 84:0b3ab51c8877 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 84:0b3ab51c8877 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 84:0b3ab51c8877 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 84:0b3ab51c8877 35 *
bogdanm 84:0b3ab51c8877 36 ******************************************************************************
bogdanm 84:0b3ab51c8877 37 */
bogdanm 84:0b3ab51c8877 38
bogdanm 84:0b3ab51c8877 39 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 84:0b3ab51c8877 40 #ifndef __STM32L0XX_HAL_FLASH_H
bogdanm 84:0b3ab51c8877 41 #define __STM32L0XX_HAL_FLASH_H
bogdanm 84:0b3ab51c8877 42
bogdanm 84:0b3ab51c8877 43 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 44 extern "C" {
bogdanm 84:0b3ab51c8877 45 #endif
bogdanm 84:0b3ab51c8877 46
bogdanm 84:0b3ab51c8877 47 /* Includes ------------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 48 #include "stm32l0xx_hal_def.h"
bogdanm 84:0b3ab51c8877 49
bogdanm 84:0b3ab51c8877 50 /** @addtogroup STM32L0xx_HAL_Driver
bogdanm 84:0b3ab51c8877 51 * @{
bogdanm 84:0b3ab51c8877 52 */
bogdanm 84:0b3ab51c8877 53
bogdanm 84:0b3ab51c8877 54 /** @addtogroup FLASH
bogdanm 84:0b3ab51c8877 55 * @{
bogdanm 84:0b3ab51c8877 56 */
bogdanm 84:0b3ab51c8877 57
bogdanm 84:0b3ab51c8877 58 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 59
bogdanm 84:0b3ab51c8877 60 /**
bogdanm 84:0b3ab51c8877 61 * @brief FLASH Error structure definition
bogdanm 84:0b3ab51c8877 62 */
bogdanm 84:0b3ab51c8877 63 typedef enum
bogdanm 84:0b3ab51c8877 64 {
bogdanm 84:0b3ab51c8877 65 FLASH_ERROR_RD = 0x01,
bogdanm 84:0b3ab51c8877 66 FLASH_ERROR_ENDHV = 0x02,
bogdanm 84:0b3ab51c8877 67 FLASH_ERROR_SIZE = 0x04,
bogdanm 84:0b3ab51c8877 68 FLASH_ERROR_PGA = 0x08,
bogdanm 84:0b3ab51c8877 69 FLASH_ERROR_WRP = 0x10,
bogdanm 84:0b3ab51c8877 70 FLASH_ERROR_OPTV = 0x20,
bogdanm 84:0b3ab51c8877 71 FLASH_ERROR_NOTZERO = 0x40
bogdanm 84:0b3ab51c8877 72 }FLASH_ErrorTypeDef;
bogdanm 84:0b3ab51c8877 73
bogdanm 84:0b3ab51c8877 74 /**
bogdanm 84:0b3ab51c8877 75 * @brief FLASH Procedure structure definition
bogdanm 84:0b3ab51c8877 76 */
bogdanm 84:0b3ab51c8877 77 typedef enum
bogdanm 84:0b3ab51c8877 78 {
bogdanm 84:0b3ab51c8877 79 FLASH_PROC_NONE = 0,
bogdanm 84:0b3ab51c8877 80 FLASH_PROC_PAGEERASE,
bogdanm 84:0b3ab51c8877 81 FLASH_PROC_PROGRAM
bogdanm 84:0b3ab51c8877 82 } FLASH_ProcedureTypeDef;
bogdanm 84:0b3ab51c8877 83
bogdanm 84:0b3ab51c8877 84 /**
bogdanm 84:0b3ab51c8877 85 * @brief FLASH Erase structure definition
bogdanm 84:0b3ab51c8877 86 */
bogdanm 84:0b3ab51c8877 87 typedef struct
bogdanm 84:0b3ab51c8877 88 {
bogdanm 84:0b3ab51c8877 89 uint32_t TypeErase; /*!< TypeErase: Mass erase or sector Erase.
bogdanm 84:0b3ab51c8877 90 This parameter can be a value of @ref FLASH_Type_Erase */
bogdanm 84:0b3ab51c8877 91
bogdanm 92:4fc01daae5a5 92 uint32_t Page; /*!< Sector: Initial FLASH sector to erase when Mass erase is disabled
bogdanm 92:4fc01daae5a5 93 This parameter must be an address value between 0x08000000 and 0x0800FFFF */
bogdanm 84:0b3ab51c8877 94
bogdanm 92:4fc01daae5a5 95 uint32_t NbPages; /*!< NbSectors: Number of sectors to be erased.
bogdanm 92:4fc01daae5a5 96 This parameter must be a value between 1 and (max number of sectors - initial sector value) */
bogdanm 84:0b3ab51c8877 97
bogdanm 84:0b3ab51c8877 98 } FLASH_EraseInitTypeDef;
bogdanm 84:0b3ab51c8877 99
bogdanm 84:0b3ab51c8877 100 /**
bogdanm 84:0b3ab51c8877 101 * @brief FLASH Option Bytes PROGRAM structure definition
bogdanm 84:0b3ab51c8877 102 */
bogdanm 84:0b3ab51c8877 103 typedef struct
bogdanm 84:0b3ab51c8877 104 {
bogdanm 84:0b3ab51c8877 105 uint32_t OptionType; /*!< OptionType: Option byte to be configured.
bogdanm 84:0b3ab51c8877 106 This parameter can be a value of @ref FLASH_Option_Type */
bogdanm 84:0b3ab51c8877 107
bogdanm 84:0b3ab51c8877 108 uint32_t WRPState; /*!< WRPState: Write protection activation or deactivation.
bogdanm 84:0b3ab51c8877 109 This parameter can be a value of @ref FLASH_WRP_State */
bogdanm 84:0b3ab51c8877 110
bogdanm 92:4fc01daae5a5 111 uint32_t WRPSector; /*!< WRPSector: specifies the sector(s) to be write protected.
bogdanm 92:4fc01daae5a5 112 The value of this parameter depends on device used within the same series */
bogdanm 84:0b3ab51c8877 113
bogdanm 84:0b3ab51c8877 114 uint32_t RDPLevel; /*!< RDPLevel: Set the read protection level..
bogdanm 84:0b3ab51c8877 115 This parameter can be a value of @ref FLASH_Option_Bytes_Read_Protection */
bogdanm 84:0b3ab51c8877 116
bogdanm 84:0b3ab51c8877 117 uint32_t BORLevel; /*!< BORLevel: Set the BOR Level.
bogdanm 92:4fc01daae5a5 118 This parameter can be a value of @ref FLASH_Option_Bytes_BOR_Level */
bogdanm 84:0b3ab51c8877 119 uint8_t USERConfig; /*!< USERConfig: Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
bogdanm 84:0b3ab51c8877 120 This parameter can be a combination of @ref FLASH_Option_Bytes_IWatchdog, @ref FLASH_Option_Bytes_nRST_STOP and @ref FLASH_Option_Bytes_nRST_STDBY*/
bogdanm 84:0b3ab51c8877 121 } FLASH_OBProgramInitTypeDef;
bogdanm 84:0b3ab51c8877 122
bogdanm 84:0b3ab51c8877 123 /**
bogdanm 84:0b3ab51c8877 124 * @brief FLASH handle Structure definition
bogdanm 84:0b3ab51c8877 125 */
bogdanm 84:0b3ab51c8877 126 typedef struct
bogdanm 84:0b3ab51c8877 127 {
bogdanm 84:0b3ab51c8877 128 __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*Internal variable to indicate which procedure is ongoing or not in IT context*/
bogdanm 84:0b3ab51c8877 129
bogdanm 84:0b3ab51c8877 130 __IO uint32_t NbPagesToErase; /*Internal variable to save the remaining sectors to erase in IT context*/
bogdanm 84:0b3ab51c8877 131
bogdanm 84:0b3ab51c8877 132 __IO uint32_t Page; /*Internal variable to define the current sector which is erasing*/
bogdanm 84:0b3ab51c8877 133
bogdanm 84:0b3ab51c8877 134 __IO uint32_t Address; /*Internal variable to save address selected for program*/
bogdanm 84:0b3ab51c8877 135
bogdanm 84:0b3ab51c8877 136 HAL_LockTypeDef Lock; /* FLASH locking object */
bogdanm 84:0b3ab51c8877 137
bogdanm 84:0b3ab51c8877 138 __IO FLASH_ErrorTypeDef ErrorCode; /* FLASH error code */
bogdanm 84:0b3ab51c8877 139
bogdanm 84:0b3ab51c8877 140 }FLASH_ProcessTypeDef;
bogdanm 84:0b3ab51c8877 141
bogdanm 92:4fc01daae5a5 142 /*Variables used for Erase sectors under interruption*/
bogdanm 92:4fc01daae5a5 143 extern FLASH_ProcessTypeDef pFlash;
bogdanm 92:4fc01daae5a5 144
bogdanm 84:0b3ab51c8877 145 /* Exported constants --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 146
bogdanm 84:0b3ab51c8877 147 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
bogdanm 84:0b3ab51c8877 148 * @{
bogdanm 84:0b3ab51c8877 149 */
bogdanm 84:0b3ab51c8877 150
bogdanm 92:4fc01daae5a5 151 /** @defgroup FLASH_Type_Erase
bogdanm 84:0b3ab51c8877 152 * @{
bogdanm 84:0b3ab51c8877 153 */
bogdanm 84:0b3ab51c8877 154 #define TYPEERASE_PAGEERASE ((uint32_t)0x00) /*!<Page erase only*/
bogdanm 84:0b3ab51c8877 155 #define TYPEERASE_WORD ((uint32_t)0x01) /*!<Data erase word activation*/
bogdanm 84:0b3ab51c8877 156
bogdanm 84:0b3ab51c8877 157 #define IS_TYPEERASE(VALUE)(((VALUE) == TYPEERASE_PAGEERASE) || \
bogdanm 84:0b3ab51c8877 158 ((VALUE) == TYPEERASE_WORD))
bogdanm 84:0b3ab51c8877 159 /**
bogdanm 84:0b3ab51c8877 160 * @}
bogdanm 84:0b3ab51c8877 161 */
bogdanm 84:0b3ab51c8877 162
bogdanm 92:4fc01daae5a5 163 /** @defgroup FLASH_Type_Program
bogdanm 84:0b3ab51c8877 164 * @{
bogdanm 84:0b3ab51c8877 165 */
bogdanm 84:0b3ab51c8877 166 #define TYPEPROGRAM_BYTE ((uint32_t)0x00) /*!<Program byte (8-bit) at a specified address.*/
bogdanm 84:0b3ab51c8877 167 #define TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!<Program a half-word (16-bit) at a specified address.*/
bogdanm 84:0b3ab51c8877 168 #define TYPEPROGRAM_WORD ((uint32_t)0x02) /*!<Program a word (32-bit) at a specified address.*/
bogdanm 84:0b3ab51c8877 169 #define TYPEPROGRAM_FASTBYTE ((uint32_t)0x04) /*!<Fast Program byte (8-bit) at a specified address.*/
bogdanm 84:0b3ab51c8877 170 #define TYPEPROGRAM_FASTHALFWORD ((uint32_t)0x08) /*!<Fast Program a half-word (16-bit) at a specified address.*/
bogdanm 84:0b3ab51c8877 171 #define TYPEPROGRAM_FASTWORD ((uint32_t)0x10) /*!<Fast Program a word (32-bit) at a specified address.*/
bogdanm 84:0b3ab51c8877 172
bogdanm 84:0b3ab51c8877 173 #define IS_TYPEPROGRAM(VALUE)(((VALUE) == TYPEPROGRAM_BYTE) || \
bogdanm 84:0b3ab51c8877 174 ((VALUE) == TYPEPROGRAM_HALFWORD) || \
bogdanm 84:0b3ab51c8877 175 ((VALUE) == TYPEPROGRAM_WORD) || \
bogdanm 84:0b3ab51c8877 176 ((VALUE) == TYPEPROGRAM_FASTBYTE) || \
bogdanm 84:0b3ab51c8877 177 ((VALUE) == TYPEPROGRAM_FASTHALFWORD) || \
bogdanm 84:0b3ab51c8877 178 ((VALUE) == TYPEPROGRAM_FASTWORD))
bogdanm 84:0b3ab51c8877 179 /**
bogdanm 84:0b3ab51c8877 180 * @}
bogdanm 84:0b3ab51c8877 181 */
bogdanm 84:0b3ab51c8877 182
bogdanm 92:4fc01daae5a5 183 /** @defgroup FLASH_WRP_State
bogdanm 84:0b3ab51c8877 184 * @{
bogdanm 84:0b3ab51c8877 185 */
bogdanm 84:0b3ab51c8877 186 #define WRPSTATE_DISABLE ((uint32_t)0x00) /*!<Disable the write protection of the desired bank 1 sectors*/
bogdanm 84:0b3ab51c8877 187 #define WRPSTATE_ENABLE ((uint32_t)0x01) /*!<Enable the write protection of the desired bank 1 sectors*/
bogdanm 84:0b3ab51c8877 188
bogdanm 84:0b3ab51c8877 189 #define IS_WRPSTATE(VALUE)(((VALUE) == WRPSTATE_DISABLE) || \
bogdanm 84:0b3ab51c8877 190 ((VALUE) == WRPSTATE_ENABLE))
bogdanm 84:0b3ab51c8877 191 /**
bogdanm 84:0b3ab51c8877 192 * @}
bogdanm 84:0b3ab51c8877 193 */
bogdanm 84:0b3ab51c8877 194
bogdanm 92:4fc01daae5a5 195 /** @defgroup FLASH_Option_Type
bogdanm 84:0b3ab51c8877 196 * @{
bogdanm 84:0b3ab51c8877 197 */
bogdanm 84:0b3ab51c8877 198 #define OPTIONBYTE_WRP ((uint32_t)0x01) /*!<WRP option byte configuration*/
bogdanm 84:0b3ab51c8877 199 #define OPTIONBYTE_RDP ((uint32_t)0x02) /*!<RDP option byte configuration*/
bogdanm 84:0b3ab51c8877 200 #define OPTIONBYTE_USER ((uint32_t)0x04) /*!<USER option byte configuration*/
bogdanm 84:0b3ab51c8877 201 #define OPTIONBYTE_BOR ((uint32_t)0x08) /*!<BOR option byte configuration*/
bogdanm 84:0b3ab51c8877 202
bogdanm 84:0b3ab51c8877 203 #define IS_OPTIONBYTE(VALUE)(((VALUE) < (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR)))
bogdanm 84:0b3ab51c8877 204 /**
bogdanm 84:0b3ab51c8877 205 * @}
bogdanm 84:0b3ab51c8877 206 */
bogdanm 84:0b3ab51c8877 207
bogdanm 92:4fc01daae5a5 208 /** @defgroup FLASH_Interrupts
bogdanm 84:0b3ab51c8877 209 * @{
bogdanm 84:0b3ab51c8877 210 */
bogdanm 84:0b3ab51c8877 211 #define FLASH_IT_EOP FLASH_PECR_EOPIE /*!< End of programming interrupt source */
bogdanm 84:0b3ab51c8877 212 #define FLASH_IT_ERR FLASH_PECR_ERRIE /*!< Error interrupt source */
bogdanm 84:0b3ab51c8877 213 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFCFFFF) == 0x00000000) && (((IT) != 0x00000000)))
bogdanm 84:0b3ab51c8877 214 /**
bogdanm 84:0b3ab51c8877 215 * @}
bogdanm 84:0b3ab51c8877 216 */
bogdanm 84:0b3ab51c8877 217
bogdanm 92:4fc01daae5a5 218 /** @defgroup FLASH_Address
bogdanm 84:0b3ab51c8877 219 * @{
bogdanm 84:0b3ab51c8877 220 */
bogdanm 92:4fc01daae5a5 221 #define IS_FLASH_DATA_ADDRESS(ADDRESS) (((ADDRESS) >= DATA_EEPROM_BASE) && ((ADDRESS) <= DATA_EEPROM_END)) /* 2K */
bogdanm 92:4fc01daae5a5 222 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END)) /* 64K */
bogdanm 84:0b3ab51c8877 223 #define IS_NBPAGES(PAGES) (((PAGES) >= 1) && ((PAGES) <= 512)) /* 512 pages from page0 to page 511 */
bogdanm 84:0b3ab51c8877 224 /**
bogdanm 84:0b3ab51c8877 225 * @}
bogdanm 84:0b3ab51c8877 226 */
bogdanm 84:0b3ab51c8877 227
bogdanm 92:4fc01daae5a5 228 /** @defgroup FLASH_Option_Bytes_Write_Protection
bogdanm 84:0b3ab51c8877 229 * @{
bogdanm 84:0b3ab51c8877 230 */
bogdanm 84:0b3ab51c8877 231 #define OB_WRP_Pages0to31 ((uint32_t)0x00000001) /* Write protection of Sector0 */
bogdanm 84:0b3ab51c8877 232 #define OB_WRP_Pages32to63 ((uint32_t)0x00000002) /* Write protection of Sector1 */
bogdanm 84:0b3ab51c8877 233 #define OB_WRP_Pages64to95 ((uint32_t)0x00000004) /* Write protection of Sector2 */
bogdanm 84:0b3ab51c8877 234 #define OB_WRP_Pages96to127 ((uint32_t)0x00000008) /* Write protection of Sector3 */
bogdanm 84:0b3ab51c8877 235 #define OB_WRP_Pages128to159 ((uint32_t)0x00000010) /* Write protection of Sector4 */
bogdanm 84:0b3ab51c8877 236 #define OB_WRP_Pages160to191 ((uint32_t)0x00000020) /* Write protection of Sector5 */
bogdanm 84:0b3ab51c8877 237 #define OB_WRP_Pages192to223 ((uint32_t)0x00000040) /* Write protection of Sector6 */
bogdanm 84:0b3ab51c8877 238 #define OB_WRP_Pages224to255 ((uint32_t)0x00000080) /* Write protection of Sector7 */
bogdanm 84:0b3ab51c8877 239 #define OB_WRP_Pages256to287 ((uint32_t)0x00000100) /* Write protection of Sector8 */
bogdanm 84:0b3ab51c8877 240 #define OB_WRP_Pages288to319 ((uint32_t)0x00000200) /* Write protection of Sector9 */
bogdanm 84:0b3ab51c8877 241 #define OB_WRP_Pages320to351 ((uint32_t)0x00000400) /* Write protection of Sector10 */
bogdanm 84:0b3ab51c8877 242 #define OB_WRP_Pages352to383 ((uint32_t)0x00000800) /* Write protection of Sector11 */
bogdanm 84:0b3ab51c8877 243 #define OB_WRP_Pages384to415 ((uint32_t)0x00001000) /* Write protection of Sector12 */
bogdanm 84:0b3ab51c8877 244 #define OB_WRP_Pages416to447 ((uint32_t)0x00002000) /* Write protection of Sector13 */
bogdanm 84:0b3ab51c8877 245 #define OB_WRP_Pages448to479 ((uint32_t)0x00004000) /* Write protection of Sector14 */
bogdanm 84:0b3ab51c8877 246 #define OB_WRP_Pages480to511 ((uint32_t)0x00008000) /* Write protection of Sector15 */
bogdanm 84:0b3ab51c8877 247
bogdanm 84:0b3ab51c8877 248 #define OB_WRP_AllPages ((uint32_t)0x0000FFFF) /*!< Write protection of all Sectors */
bogdanm 84:0b3ab51c8877 249
bogdanm 84:0b3ab51c8877 250 #define IS_OB_WRP(PAGE) (((PAGE) != 0x0000000))
bogdanm 84:0b3ab51c8877 251 /**
bogdanm 84:0b3ab51c8877 252 * @}
bogdanm 84:0b3ab51c8877 253 */
bogdanm 84:0b3ab51c8877 254
bogdanm 92:4fc01daae5a5 255 /** @defgroup FLASH_Option_Bytes_Read_Protection
bogdanm 84:0b3ab51c8877 256 * @{
bogdanm 84:0b3ab51c8877 257 */
bogdanm 84:0b3ab51c8877 258
bogdanm 84:0b3ab51c8877 259 /**
bogdanm 84:0b3ab51c8877 260 * @brief FLASH_Option_Bytes_Read_Protection
bogdanm 84:0b3ab51c8877 261 */
bogdanm 84:0b3ab51c8877 262 #define OB_RDP_Level_0 ((uint8_t)0xAA)
bogdanm 84:0b3ab51c8877 263 #define OB_RDP_Level_1 ((uint8_t)0xBB)
bogdanm 84:0b3ab51c8877 264 /*#define OB_RDP_Level_2 ((uint8_t)0xCC)*/ /* Warning: When enabling read protection level 2
bogdanm 84:0b3ab51c8877 265 it's no more possible to go back to level 1 or 0 */
bogdanm 84:0b3ab51c8877 266
bogdanm 84:0b3ab51c8877 267 #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\
bogdanm 84:0b3ab51c8877 268 ((LEVEL) == OB_RDP_Level_1))/*||\
bogdanm 84:0b3ab51c8877 269 ((LEVEL) == OB_RDP_Level_2))*/
bogdanm 84:0b3ab51c8877 270 /**
bogdanm 84:0b3ab51c8877 271 * @}
bogdanm 84:0b3ab51c8877 272 */
bogdanm 84:0b3ab51c8877 273
bogdanm 92:4fc01daae5a5 274 /** @defgroup FLASH_Option_Bytes_IWatchdog
bogdanm 84:0b3ab51c8877 275 * @{
bogdanm 84:0b3ab51c8877 276 */
bogdanm 84:0b3ab51c8877 277 #define OB_IWDG_SW ((uint8_t)0x10) /*!< Software WDG selected */
bogdanm 84:0b3ab51c8877 278 #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware WDG selected */
bogdanm 84:0b3ab51c8877 279 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
bogdanm 84:0b3ab51c8877 280 /**
bogdanm 84:0b3ab51c8877 281 * @}
bogdanm 84:0b3ab51c8877 282 */
bogdanm 84:0b3ab51c8877 283
bogdanm 92:4fc01daae5a5 284 /** @defgroup FLASH_Option_Bytes_nRST_STOP
bogdanm 84:0b3ab51c8877 285 * @{
bogdanm 84:0b3ab51c8877 286 */
bogdanm 84:0b3ab51c8877 287 #define OB_STOP_NoRST ((uint8_t)0x20) /*!< No reset generated when entering in STOP */
bogdanm 84:0b3ab51c8877 288 #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
bogdanm 84:0b3ab51c8877 289 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
bogdanm 84:0b3ab51c8877 290 /**
bogdanm 84:0b3ab51c8877 291 * @}
bogdanm 84:0b3ab51c8877 292 */
bogdanm 84:0b3ab51c8877 293
bogdanm 92:4fc01daae5a5 294 /** @defgroup FLASH_Option_Bytes_nRST_STDBY
bogdanm 84:0b3ab51c8877 295 * @{
bogdanm 84:0b3ab51c8877 296 */
bogdanm 84:0b3ab51c8877 297 #define OB_STDBY_NoRST ((uint8_t)0x40) /*!< No reset generated when entering in STANDBY */
bogdanm 84:0b3ab51c8877 298 #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
bogdanm 84:0b3ab51c8877 299 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
bogdanm 84:0b3ab51c8877 300 /**
bogdanm 84:0b3ab51c8877 301 * @}
bogdanm 84:0b3ab51c8877 302 */
bogdanm 84:0b3ab51c8877 303
bogdanm 92:4fc01daae5a5 304 /** @defgroup FLASH_Option_Bytes_BOR_Level
bogdanm 84:0b3ab51c8877 305 * @{
bogdanm 84:0b3ab51c8877 306 */
bogdanm 84:0b3ab51c8877 307
bogdanm 84:0b3ab51c8877 308 #define OB_BOR_OFF ((uint8_t)0x00) /*!< BOR is disabled at power down, the reset is asserted when the VDD
bogdanm 84:0b3ab51c8877 309 power supply reaches the PDR(Power Down Reset) threshold (1.5V) */
bogdanm 84:0b3ab51c8877 310 #define OB_BOR_LEVEL1 ((uint8_t)0x08) /*!< BOR Reset threshold levels for 1.7V - 1.8V VDD power supply */
bogdanm 84:0b3ab51c8877 311 #define OB_BOR_LEVEL2 ((uint8_t)0x09) /*!< BOR Reset threshold levels for 1.9V - 2.0V VDD power supply */
bogdanm 84:0b3ab51c8877 312 #define OB_BOR_LEVEL3 ((uint8_t)0x0A) /*!< BOR Reset threshold levels for 2.3V - 2.4V VDD power supply */
bogdanm 84:0b3ab51c8877 313 #define OB_BOR_LEVEL4 ((uint8_t)0x0B) /*!< BOR Reset threshold levels for 2.55V - 2.65V VDD power supply */
bogdanm 84:0b3ab51c8877 314 #define OB_BOR_LEVEL5 ((uint8_t)0x0C) /*!< BOR Reset threshold levels for 2.8V - 2.9V VDD power supply */
bogdanm 84:0b3ab51c8877 315
bogdanm 84:0b3ab51c8877 316 #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_OFF) || \
bogdanm 84:0b3ab51c8877 317 ((LEVEL) == OB_BOR_LEVEL1) || \
bogdanm 84:0b3ab51c8877 318 ((LEVEL) == OB_BOR_LEVEL2) || \
bogdanm 84:0b3ab51c8877 319 ((LEVEL) == OB_BOR_LEVEL3) || \
bogdanm 84:0b3ab51c8877 320 ((LEVEL) == OB_BOR_LEVEL4) || \
bogdanm 84:0b3ab51c8877 321 ((LEVEL) == OB_BOR_LEVEL5))
bogdanm 84:0b3ab51c8877 322
bogdanm 84:0b3ab51c8877 323 /**
bogdanm 84:0b3ab51c8877 324 * @}
bogdanm 84:0b3ab51c8877 325 */
bogdanm 84:0b3ab51c8877 326
bogdanm 92:4fc01daae5a5 327 /** @defgroup FLASH_Flags
bogdanm 84:0b3ab51c8877 328 * @{
bogdanm 84:0b3ab51c8877 329 */
bogdanm 84:0b3ab51c8877 330
bogdanm 84:0b3ab51c8877 331 #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */
bogdanm 84:0b3ab51c8877 332 #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Programming flag */
bogdanm 84:0b3ab51c8877 333 #define FLASH_FLAG_ENDHV FLASH_SR_ENHV /*!< FLASH End of High Voltage flag */
bogdanm 84:0b3ab51c8877 334 #define FLASH_FLAG_READY FLASH_SR_READY /*!< FLASH Ready flag after low power mode */
bogdanm 84:0b3ab51c8877 335 #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */
bogdanm 84:0b3ab51c8877 336 #define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming Alignment error flag */
bogdanm 84:0b3ab51c8877 337 #define FLASH_FLAG_SIZERR FLASH_SR_SIZERR /*!< FLASH Size error flag */
bogdanm 84:0b3ab51c8877 338 #define FLASH_FLAG_OPTVERR FLASH_SR_OPTVERR /*!< FLASH Option Validity error flag */
bogdanm 84:0b3ab51c8877 339 #define FLASH_FLAG_RDERR FLASH_SR_RDERR /*!< FLASH Read protected error flag */
bogdanm 84:0b3ab51c8877 340 #define FLASH_FLAG_NOTZEROERR FLASH_SR_NOTZEROERR /*!< FLASH Read protected error flag */
bogdanm 84:0b3ab51c8877 341
bogdanm 84:0b3ab51c8877 342 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFED0FF) == 0x00000000) && ((FLAG) != 0x00000000))
bogdanm 84:0b3ab51c8877 343
bogdanm 84:0b3ab51c8877 344 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
bogdanm 84:0b3ab51c8877 345 ((FLAG) == FLASH_FLAG_ENDHV) || ((FLAG) == FLASH_FLAG_READY ) || \
bogdanm 84:0b3ab51c8877 346 ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_PGAERR ) || \
bogdanm 84:0b3ab51c8877 347 ((FLAG) == FLASH_FLAG_SIZERR) || ((FLAG) == FLASH_FLAG_OPTVERR) || \
bogdanm 84:0b3ab51c8877 348 ((FLAG) == FLASH_FLAG_RDERR) || ((FLAG) == FLASH_FLAG_NOTZEROERR))
bogdanm 84:0b3ab51c8877 349 /**
bogdanm 84:0b3ab51c8877 350 * @}
bogdanm 84:0b3ab51c8877 351 */
bogdanm 84:0b3ab51c8877 352
bogdanm 92:4fc01daae5a5 353 /** @defgroup FLASH_Keys
bogdanm 84:0b3ab51c8877 354 * @{
bogdanm 84:0b3ab51c8877 355 */
bogdanm 84:0b3ab51c8877 356
bogdanm 84:0b3ab51c8877 357 #define FLASH_PDKEY1 ((uint32_t)0x04152637) /*!< Flash power down key1 */
bogdanm 84:0b3ab51c8877 358 #define FLASH_PDKEY2 ((uint32_t)0xFAFBFCFD) /*!< Flash power down key2: used with FLASH_PDKEY1
bogdanm 84:0b3ab51c8877 359 to unlock the RUN_PD bit in FLASH_ACR */
bogdanm 84:0b3ab51c8877 360
bogdanm 84:0b3ab51c8877 361 #define FLASH_PEKEY1 ((uint32_t)0x89ABCDEF) /*!< Flash program erase key1 */
bogdanm 84:0b3ab51c8877 362 #define FLASH_PEKEY2 ((uint32_t)0x02030405) /*!< Flash program erase key: used with FLASH_PEKEY2
bogdanm 84:0b3ab51c8877 363 to unlock the write access to the FLASH_PECR register and
bogdanm 84:0b3ab51c8877 364 data EEPROM */
bogdanm 84:0b3ab51c8877 365
bogdanm 84:0b3ab51c8877 366 #define FLASH_PRGKEY1 ((uint32_t)0x8C9DAEBF) /*!< Flash program memory key1 */
bogdanm 84:0b3ab51c8877 367 #define FLASH_PRGKEY2 ((uint32_t)0x13141516) /*!< Flash program memory key2: used with FLASH_PRGKEY2
bogdanm 84:0b3ab51c8877 368 to unlock the program memory */
bogdanm 84:0b3ab51c8877 369
bogdanm 84:0b3ab51c8877 370 #define FLASH_OPTKEY1 ((uint32_t)0xFBEAD9C8) /*!< Flash option key1 */
bogdanm 84:0b3ab51c8877 371 #define FLASH_OPTKEY2 ((uint32_t)0x24252627) /*!< Flash option key2: used with FLASH_OPTKEY1 to
bogdanm 84:0b3ab51c8877 372 unlock the write access to the option byte block */
bogdanm 84:0b3ab51c8877 373 /**
bogdanm 84:0b3ab51c8877 374 * @}
bogdanm 84:0b3ab51c8877 375 */
bogdanm 84:0b3ab51c8877 376
bogdanm 92:4fc01daae5a5 377 /* CMSIS_Legacy */
bogdanm 92:4fc01daae5a5 378
bogdanm 84:0b3ab51c8877 379 #if defined ( __ICCARM__ )
bogdanm 84:0b3ab51c8877 380 #define InterruptType_ACTLR_DISMCYCINT_Msk IntType_ACTLR_DISMCYCINT_Msk
bogdanm 84:0b3ab51c8877 381 #endif
bogdanm 84:0b3ab51c8877 382
bogdanm 84:0b3ab51c8877 383 /**
bogdanm 84:0b3ab51c8877 384 * @}
bogdanm 84:0b3ab51c8877 385 */
bogdanm 84:0b3ab51c8877 386
bogdanm 84:0b3ab51c8877 387 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 388 /** @defgroup FLASH_Interrupt FLASH Interrupt
bogdanm 84:0b3ab51c8877 389 * @brief macros to handle FLASH interrupts
bogdanm 84:0b3ab51c8877 390 * @{
bogdanm 84:0b3ab51c8877 391 */
bogdanm 84:0b3ab51c8877 392
bogdanm 84:0b3ab51c8877 393 /**
bogdanm 84:0b3ab51c8877 394 * @brief Enables or disables the specified FLASH interrupts.
bogdanm 84:0b3ab51c8877 395 * @param __INTERRUPT__: specifies the FLASH interrupt sources to be enabled or
bogdanm 84:0b3ab51c8877 396 * disabled.
bogdanm 84:0b3ab51c8877 397 * This parameter can be any combination of the following values:
bogdanm 84:0b3ab51c8877 398 * @arg FLASH_IT_EOP: FLASH end of programming Interrupt
bogdanm 84:0b3ab51c8877 399 * @arg FLASH_IT_ERR: FLASH Error Interrupt
bogdanm 84:0b3ab51c8877 400 * @retval None
bogdanm 84:0b3ab51c8877 401 */
bogdanm 84:0b3ab51c8877 402 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (FLASH->PECR |= (__INTERRUPT__))
bogdanm 84:0b3ab51c8877 403
bogdanm 84:0b3ab51c8877 404 /**
bogdanm 84:0b3ab51c8877 405 * @brief Disable the specified FLASH interrupt.
bogdanm 84:0b3ab51c8877 406 * @param __INTERRUPT__ : FLASH interrupt
bogdanm 84:0b3ab51c8877 407 * This parameter can be any combination of the following values:
bogdanm 84:0b3ab51c8877 408 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
bogdanm 84:0b3ab51c8877 409 * @arg FLASH_IT_ERR: Error Interrupt
bogdanm 84:0b3ab51c8877 410 * @retval none
bogdanm 84:0b3ab51c8877 411 */
bogdanm 84:0b3ab51c8877 412 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (FLASH->PECR &= ~(uint32_t)(__INTERRUPT__))
bogdanm 84:0b3ab51c8877 413
bogdanm 84:0b3ab51c8877 414 /**
bogdanm 84:0b3ab51c8877 415 * @brief Checks whether the specified FLASH flag is set or not.
bogdanm 84:0b3ab51c8877 416 * @param __FLAG__: specifies the FLASH flag to check.
bogdanm 84:0b3ab51c8877 417 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 418 * @arg FLASH_FLAG_BSY: FLASH write/erase operations in progress flag
bogdanm 84:0b3ab51c8877 419 * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
bogdanm 84:0b3ab51c8877 420 * @arg FLASH_FLAG_READY: FLASH Ready flag after low power mode
bogdanm 84:0b3ab51c8877 421 * @arg FLASH_FLAG_ENDHV: FLASH End of high voltage flag
bogdanm 84:0b3ab51c8877 422 * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag
bogdanm 84:0b3ab51c8877 423 * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag
bogdanm 84:0b3ab51c8877 424 * @arg FLASH_FLAG_SIZERR: FLASH size error flag
bogdanm 84:0b3ab51c8877 425 * @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag
bogdanm 84:0b3ab51c8877 426 * @arg FLASH_FLAG_OPTVERRUSR: FLASH Option User validity error flag
bogdanm 84:0b3ab51c8877 427 * @arg FLASH_FLAG_RDERR: FLASH Read protected error flag
bogdanm 84:0b3ab51c8877 428 * @arg FLASH_FLAG_NOTZEROERR: Not Zero area error flag
bogdanm 84:0b3ab51c8877 429 * @retval The new state of FLASH_FLAG (SET or RESET).
bogdanm 84:0b3ab51c8877 430 */
bogdanm 84:0b3ab51c8877 431 #define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__)) == (__FLAG__))
bogdanm 84:0b3ab51c8877 432
bogdanm 84:0b3ab51c8877 433 /**
bogdanm 84:0b3ab51c8877 434 * @brief Clears the FLASH's pending flags.
bogdanm 84:0b3ab51c8877 435 * @param __FLAG__: specifies the FLASH flags to clear.
bogdanm 84:0b3ab51c8877 436 * This parameter can be any combination of the following values:
bogdanm 84:0b3ab51c8877 437 * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
bogdanm 84:0b3ab51c8877 438 * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag
bogdanm 84:0b3ab51c8877 439 * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag
bogdanm 84:0b3ab51c8877 440 * @arg FLASH_FLAG_SIZERR: FLASH size error flag
bogdanm 84:0b3ab51c8877 441 * @arg FLASH_FLAG_OPTVERR: FLASH Option validity error flag
bogdanm 84:0b3ab51c8877 442 * @arg FLASH_FLAG_OPTVERRUSR: FLASH Option User validity error flag
bogdanm 84:0b3ab51c8877 443 * @arg FLASH_FLAG_RDERR: FLASH Read protected error flag
bogdanm 84:0b3ab51c8877 444 * @arg FLASH_FLAG_NOTZEROERR: Not Zero area error flag
bogdanm 84:0b3ab51c8877 445 * @retval None
bogdanm 84:0b3ab51c8877 446 */
bogdanm 84:0b3ab51c8877 447 #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (FLASH->SR = (__FLAG__))
bogdanm 84:0b3ab51c8877 448
bogdanm 84:0b3ab51c8877 449 /**
bogdanm 84:0b3ab51c8877 450 * @}
bogdanm 84:0b3ab51c8877 451 */
bogdanm 84:0b3ab51c8877 452
bogdanm 84:0b3ab51c8877 453 /* Include FLASH HAL Extension module */
bogdanm 84:0b3ab51c8877 454 #include "stm32l0xx_hal_flash_ex.h"
bogdanm 84:0b3ab51c8877 455 #include "stm32l0xx_hal_flash_ramfunc.h"
bogdanm 84:0b3ab51c8877 456
bogdanm 84:0b3ab51c8877 457 /* Exported functions ------------------------------------------------------- */
bogdanm 84:0b3ab51c8877 458
bogdanm 84:0b3ab51c8877 459 /**
bogdanm 84:0b3ab51c8877 460 * @brief FLASH memory functions that can be executed from FLASH.
bogdanm 84:0b3ab51c8877 461 */
bogdanm 84:0b3ab51c8877 462 /* Program operation functions ***********************************************/
bogdanm 84:0b3ab51c8877 463 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint32_t Data);
bogdanm 84:0b3ab51c8877 464 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint32_t Data);
bogdanm 84:0b3ab51c8877 465
bogdanm 84:0b3ab51c8877 466 /* FLASH IRQ handler function */
bogdanm 84:0b3ab51c8877 467 void HAL_FLASH_IRQHandler(void);
bogdanm 84:0b3ab51c8877 468
bogdanm 84:0b3ab51c8877 469 /* Callbacks in non blocking modes */
bogdanm 84:0b3ab51c8877 470 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
bogdanm 84:0b3ab51c8877 471 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
bogdanm 84:0b3ab51c8877 472
bogdanm 84:0b3ab51c8877 473 /* Peripheral Control functions **********************************************/
bogdanm 84:0b3ab51c8877 474 HAL_StatusTypeDef HAL_FLASH_Unlock(void);
bogdanm 84:0b3ab51c8877 475 HAL_StatusTypeDef HAL_FLASH_Lock(void);
bogdanm 84:0b3ab51c8877 476 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
bogdanm 84:0b3ab51c8877 477 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
bogdanm 84:0b3ab51c8877 478
bogdanm 84:0b3ab51c8877 479 /* Option bytes control */
bogdanm 84:0b3ab51c8877 480 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
bogdanm 84:0b3ab51c8877 481
bogdanm 84:0b3ab51c8877 482 /* Peripheral State functions ************************************************/
bogdanm 84:0b3ab51c8877 483 FLASH_ErrorTypeDef HAL_FLASH_GetError(void);
bogdanm 84:0b3ab51c8877 484
bogdanm 84:0b3ab51c8877 485 /* Non-User functions ********************************************************/
bogdanm 84:0b3ab51c8877 486 HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
bogdanm 84:0b3ab51c8877 487 void FLASH_Erase_Page(uint32_t Page_Address);
bogdanm 84:0b3ab51c8877 488
bogdanm 84:0b3ab51c8877 489 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 490 }
bogdanm 84:0b3ab51c8877 491 #endif
bogdanm 84:0b3ab51c8877 492
bogdanm 84:0b3ab51c8877 493 #endif /* __STM32L0XX_HAL_FLASH_H */
bogdanm 84:0b3ab51c8877 494
bogdanm 84:0b3ab51c8877 495 /**
bogdanm 84:0b3ab51c8877 496 * @}
bogdanm 84:0b3ab51c8877 497 */
bogdanm 84:0b3ab51c8877 498
bogdanm 84:0b3ab51c8877 499 /**
bogdanm 84:0b3ab51c8877 500 * @}
bogdanm 84:0b3ab51c8877 501 */
bogdanm 84:0b3ab51c8877 502
bogdanm 84:0b3ab51c8877 503 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/