Bayley Wang
/
flash_configuration
flash based config testing
FlashWriter/stm32f4xx_flash.c@0:941e150e78b6, 2017-03-01 (annotated)
- Committer:
- bwang
- Date:
- Wed Mar 01 00:52:47 2017 +0000
- Revision:
- 0:941e150e78b6
first commit, reading/writing of config arrays works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 0:941e150e78b6 | 1 | /** |
bwang | 0:941e150e78b6 | 2 | ****************************************************************************** |
bwang | 0:941e150e78b6 | 3 | * @file stm32f4xx_flash.c |
bwang | 0:941e150e78b6 | 4 | * @author MCD Application Team |
bwang | 0:941e150e78b6 | 5 | * @version V1.7.1 |
bwang | 0:941e150e78b6 | 6 | * @date 20-May-2016 |
bwang | 0:941e150e78b6 | 7 | * @brief This file provides firmware functions to manage the following |
bwang | 0:941e150e78b6 | 8 | * functionalities of the FLASH peripheral: |
bwang | 0:941e150e78b6 | 9 | * + FLASH Interface configuration |
bwang | 0:941e150e78b6 | 10 | * + FLASH Memory Programming |
bwang | 0:941e150e78b6 | 11 | * + Option Bytes Programming |
bwang | 0:941e150e78b6 | 12 | * + Interrupts and flags management |
bwang | 0:941e150e78b6 | 13 | * |
bwang | 0:941e150e78b6 | 14 | @verbatim |
bwang | 0:941e150e78b6 | 15 | =============================================================================== |
bwang | 0:941e150e78b6 | 16 | ##### How to use this driver ##### |
bwang | 0:941e150e78b6 | 17 | =============================================================================== |
bwang | 0:941e150e78b6 | 18 | [..] |
bwang | 0:941e150e78b6 | 19 | This driver provides functions to configure and program the FLASH memory |
bwang | 0:941e150e78b6 | 20 | of all STM32F4xx devices. These functions are split in 4 groups: |
bwang | 0:941e150e78b6 | 21 | |
bwang | 0:941e150e78b6 | 22 | (#) FLASH Interface configuration functions: this group includes the |
bwang | 0:941e150e78b6 | 23 | management of the following features: |
bwang | 0:941e150e78b6 | 24 | (++) Set the latency |
bwang | 0:941e150e78b6 | 25 | (++) Enable/Disable the prefetch buffer |
bwang | 0:941e150e78b6 | 26 | (++) Enable/Disable the Instruction cache and the Data cache |
bwang | 0:941e150e78b6 | 27 | (++) Reset the Instruction cache and the Data cache |
bwang | 0:941e150e78b6 | 28 | |
bwang | 0:941e150e78b6 | 29 | (#) FLASH Memory Programming functions: this group includes all needed |
bwang | 0:941e150e78b6 | 30 | functions to erase and program the main memory: |
bwang | 0:941e150e78b6 | 31 | (++) Lock and Unlock the FLASH interface |
bwang | 0:941e150e78b6 | 32 | (++) Erase function: Erase sector, erase all sectors |
bwang | 0:941e150e78b6 | 33 | (++) Program functions: byte, half word, word and double word |
bwang | 0:941e150e78b6 | 34 | |
bwang | 0:941e150e78b6 | 35 | (#) Option Bytes Programming functions: this group includes all needed |
bwang | 0:941e150e78b6 | 36 | functions to manage the Option Bytes: |
bwang | 0:941e150e78b6 | 37 | (++) Set/Reset the write protection |
bwang | 0:941e150e78b6 | 38 | (++) Set the Read protection Level |
bwang | 0:941e150e78b6 | 39 | (++) Set the BOR level |
bwang | 0:941e150e78b6 | 40 | (++) Program the user Option Bytes |
bwang | 0:941e150e78b6 | 41 | (++) Launch the Option Bytes loader |
bwang | 0:941e150e78b6 | 42 | |
bwang | 0:941e150e78b6 | 43 | (#) Interrupts and flags management functions: this group |
bwang | 0:941e150e78b6 | 44 | includes all needed functions to: |
bwang | 0:941e150e78b6 | 45 | (++) Enable/Disable the FLASH interrupt sources |
bwang | 0:941e150e78b6 | 46 | (++) Get flags status |
bwang | 0:941e150e78b6 | 47 | (++) Clear flags |
bwang | 0:941e150e78b6 | 48 | (++) Get FLASH operation status |
bwang | 0:941e150e78b6 | 49 | (++) Wait for last FLASH operation |
bwang | 0:941e150e78b6 | 50 | @endverbatim |
bwang | 0:941e150e78b6 | 51 | ****************************************************************************** |
bwang | 0:941e150e78b6 | 52 | * @attention |
bwang | 0:941e150e78b6 | 53 | * |
bwang | 0:941e150e78b6 | 54 | * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
bwang | 0:941e150e78b6 | 55 | * |
bwang | 0:941e150e78b6 | 56 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
bwang | 0:941e150e78b6 | 57 | * You may not use this file except in compliance with the License. |
bwang | 0:941e150e78b6 | 58 | * You may obtain a copy of the License at: |
bwang | 0:941e150e78b6 | 59 | * |
bwang | 0:941e150e78b6 | 60 | * http://www.st.com/software_license_agreement_liberty_v2 |
bwang | 0:941e150e78b6 | 61 | * |
bwang | 0:941e150e78b6 | 62 | * Unless required by applicable law or agreed to in writing, software |
bwang | 0:941e150e78b6 | 63 | * distributed under the License is distributed on an "AS IS" BASIS, |
bwang | 0:941e150e78b6 | 64 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bwang | 0:941e150e78b6 | 65 | * See the License for the specific language governing permissions and |
bwang | 0:941e150e78b6 | 66 | * limitations under the License. |
bwang | 0:941e150e78b6 | 67 | * |
bwang | 0:941e150e78b6 | 68 | ****************************************************************************** |
bwang | 0:941e150e78b6 | 69 | */ |
bwang | 0:941e150e78b6 | 70 | |
bwang | 0:941e150e78b6 | 71 | /* Includes ------------------------------------------------------------------*/ |
bwang | 0:941e150e78b6 | 72 | #include "stm32f4xx_flash.h" |
bwang | 0:941e150e78b6 | 73 | |
bwang | 0:941e150e78b6 | 74 | /** @addtogroup STM32F4xx_StdPeriph_Driver |
bwang | 0:941e150e78b6 | 75 | * @{ |
bwang | 0:941e150e78b6 | 76 | */ |
bwang | 0:941e150e78b6 | 77 | |
bwang | 0:941e150e78b6 | 78 | /** @defgroup FLASH |
bwang | 0:941e150e78b6 | 79 | * @brief FLASH driver modules |
bwang | 0:941e150e78b6 | 80 | * @{ |
bwang | 0:941e150e78b6 | 81 | */ |
bwang | 0:941e150e78b6 | 82 | |
bwang | 0:941e150e78b6 | 83 | /* Private typedef -----------------------------------------------------------*/ |
bwang | 0:941e150e78b6 | 84 | /* Private define ------------------------------------------------------------*/ |
bwang | 0:941e150e78b6 | 85 | #define SECTOR_MASK ((uint32_t)0xFFFFFF07) |
bwang | 0:941e150e78b6 | 86 | |
bwang | 0:941e150e78b6 | 87 | /* Private macro -------------------------------------------------------------*/ |
bwang | 0:941e150e78b6 | 88 | /* Private variables ---------------------------------------------------------*/ |
bwang | 0:941e150e78b6 | 89 | /* Private function prototypes -----------------------------------------------*/ |
bwang | 0:941e150e78b6 | 90 | /* Private functions ---------------------------------------------------------*/ |
bwang | 0:941e150e78b6 | 91 | |
bwang | 0:941e150e78b6 | 92 | /** @defgroup FLASH_Private_Functions |
bwang | 0:941e150e78b6 | 93 | * @{ |
bwang | 0:941e150e78b6 | 94 | */ |
bwang | 0:941e150e78b6 | 95 | |
bwang | 0:941e150e78b6 | 96 | /** @defgroup FLASH_Group1 FLASH Interface configuration functions |
bwang | 0:941e150e78b6 | 97 | * @brief FLASH Interface configuration functions |
bwang | 0:941e150e78b6 | 98 | * |
bwang | 0:941e150e78b6 | 99 | |
bwang | 0:941e150e78b6 | 100 | @verbatim |
bwang | 0:941e150e78b6 | 101 | =============================================================================== |
bwang | 0:941e150e78b6 | 102 | ##### FLASH Interface configuration functions ##### |
bwang | 0:941e150e78b6 | 103 | =============================================================================== |
bwang | 0:941e150e78b6 | 104 | [..] |
bwang | 0:941e150e78b6 | 105 | This group includes the following functions: |
bwang | 0:941e150e78b6 | 106 | (+) void FLASH_SetLatency(uint32_t FLASH_Latency) |
bwang | 0:941e150e78b6 | 107 | To correctly read data from FLASH memory, the number of wait states (LATENCY) |
bwang | 0:941e150e78b6 | 108 | must be correctly programmed according to the frequency of the CPU clock |
bwang | 0:941e150e78b6 | 109 | (HCLK) and the supply voltage of the device. |
bwang | 0:941e150e78b6 | 110 | [..] |
bwang | 0:941e150e78b6 | 111 | For STM32F405xx/07xx and STM32F415xx/17xx devices |
bwang | 0:941e150e78b6 | 112 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 113 | | Latency | HCLK clock frequency (MHz) | |
bwang | 0:941e150e78b6 | 114 | | |---------------------------------------------------------------------| |
bwang | 0:941e150e78b6 | 115 | | | voltage range | voltage range | voltage range | voltage range | |
bwang | 0:941e150e78b6 | 116 | | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | |
bwang | 0:941e150e78b6 | 117 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 118 | |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 | |
bwang | 0:941e150e78b6 | 119 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 120 | |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 | |
bwang | 0:941e150e78b6 | 121 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 122 | |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 | |
bwang | 0:941e150e78b6 | 123 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 124 | |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |66 < HCLK <= 88 |60 < HCLK <= 80 | |
bwang | 0:941e150e78b6 | 125 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 126 | |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|88 < HCLK <= 110 |80 < HCLK <= 100 | |
bwang | 0:941e150e78b6 | 127 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 128 | |5WS(6CPU cycle)|150< HCLK <= 168|120< HCLK <= 144|110 < HCLK <= 132|100 < HCLK <= 120| |
bwang | 0:941e150e78b6 | 129 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 130 | |6WS(7CPU cycle)| NA |144< HCLK <= 168|132 < HCLK <= 154|120 < HCLK <= 140| |
bwang | 0:941e150e78b6 | 131 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 132 | |7WS(8CPU cycle)| NA | NA |154 < HCLK <= 168|140 < HCLK <= 160| |
bwang | 0:941e150e78b6 | 133 | +---------------|----------------|----------------|-----------------|-----------------+ |
bwang | 0:941e150e78b6 | 134 | |
bwang | 0:941e150e78b6 | 135 | [..] |
bwang | 0:941e150e78b6 | 136 | For STM32F42xxx/43xxx devices |
bwang | 0:941e150e78b6 | 137 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 138 | | Latency | HCLK clock frequency (MHz) | |
bwang | 0:941e150e78b6 | 139 | | |---------------------------------------------------------------------| |
bwang | 0:941e150e78b6 | 140 | | | voltage range | voltage range | voltage range | voltage range | |
bwang | 0:941e150e78b6 | 141 | | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | |
bwang | 0:941e150e78b6 | 142 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 143 | |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 | |
bwang | 0:941e150e78b6 | 144 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 145 | |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 | |
bwang | 0:941e150e78b6 | 146 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 147 | |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 | |
bwang | 0:941e150e78b6 | 148 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 149 | |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |66 < HCLK <= 88 |60 < HCLK <= 80 | |
bwang | 0:941e150e78b6 | 150 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 151 | |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|88 < HCLK <= 110 |80 < HCLK <= 100 | |
bwang | 0:941e150e78b6 | 152 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 153 | |5WS(6CPU cycle)|120< HCLK <= 180|120< HCLK <= 144|110 < HCLK <= 132|100 < HCLK <= 120| |
bwang | 0:941e150e78b6 | 154 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 155 | |6WS(7CPU cycle)| NA |144< HCLK <= 168|132 < HCLK <= 154|120 < HCLK <= 140| |
bwang | 0:941e150e78b6 | 156 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 157 | |7WS(8CPU cycle)| NA |168< HCLK <= 180|154 < HCLK <= 176|140 < HCLK <= 160| |
bwang | 0:941e150e78b6 | 158 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 159 | |8WS(9CPU cycle)| NA | NA |176 < HCLK <= 180|160 < HCLK <= 168| |
bwang | 0:941e150e78b6 | 160 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 161 | |
bwang | 0:941e150e78b6 | 162 | [..] |
bwang | 0:941e150e78b6 | 163 | For STM32F401x devices |
bwang | 0:941e150e78b6 | 164 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 165 | | Latency | HCLK clock frequency (MHz) | |
bwang | 0:941e150e78b6 | 166 | | |---------------------------------------------------------------------| |
bwang | 0:941e150e78b6 | 167 | | | voltage range | voltage range | voltage range | voltage range | |
bwang | 0:941e150e78b6 | 168 | | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | |
bwang | 0:941e150e78b6 | 169 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 170 | |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 | |
bwang | 0:941e150e78b6 | 171 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 172 | |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 | |
bwang | 0:941e150e78b6 | 173 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 174 | |2WS(3CPU cycle)|60 < HCLK <= 84 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 | |
bwang | 0:941e150e78b6 | 175 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 176 | |3WS(4CPU cycle)| NA |72 < HCLK <= 84 |66 < HCLK <= 84 |60 < HCLK <= 80 | |
bwang | 0:941e150e78b6 | 177 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 178 | |4WS(5CPU cycle)| NA | NA | NA |80 < HCLK <= 84 | |
bwang | 0:941e150e78b6 | 179 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 180 | |
bwang | 0:941e150e78b6 | 181 | [..] |
bwang | 0:941e150e78b6 | 182 | For STM32F410xx/STM32F411xE devices |
bwang | 0:941e150e78b6 | 183 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 184 | | Latency | HCLK clock frequency (MHz) | |
bwang | 0:941e150e78b6 | 185 | | |---------------------------------------------------------------------| |
bwang | 0:941e150e78b6 | 186 | | | voltage range | voltage range | voltage range | voltage range | |
bwang | 0:941e150e78b6 | 187 | | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | |
bwang | 0:941e150e78b6 | 188 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 189 | |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 18 |0 < HCLK <= 16 | |
bwang | 0:941e150e78b6 | 190 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 191 | |1WS(2CPU cycle)|30 < HCLK <= 64 |24 < HCLK <= 48 |18 < HCLK <= 36 |16 < HCLK <= 32 | |
bwang | 0:941e150e78b6 | 192 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 193 | |2WS(3CPU cycle)|64 < HCLK <= 90 |48 < HCLK <= 72 |36 < HCLK <= 54 |32 < HCLK <= 48 | |
bwang | 0:941e150e78b6 | 194 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 195 | |3WS(4CPU cycle)|90 < HCLK <= 100|72 < HCLK <= 96 |54 < HCLK <= 72 |48 < HCLK <= 64 | |
bwang | 0:941e150e78b6 | 196 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 197 | |4WS(5CPU cycle)| NA |96 < HCLK <= 100|72 < HCLK <= 90 |64 < HCLK <= 80 | |
bwang | 0:941e150e78b6 | 198 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 199 | |5WS(6CPU cycle)| NA | NA |90 < HCLK <= 100 |80 < HCLK <= 96 | |
bwang | 0:941e150e78b6 | 200 | |---------------|----------------|----------------|-----------------|-----------------| |
bwang | 0:941e150e78b6 | 201 | |6WS(7CPU cycle)| NA | NA | NA |96 < HCLK <= 100 | |
bwang | 0:941e150e78b6 | 202 | +-------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 203 | |
bwang | 0:941e150e78b6 | 204 | [..] |
bwang | 0:941e150e78b6 | 205 | +-------------------------------------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 206 | | | voltage range | voltage range | voltage range | voltage range | voltage range 2.7 V - 3.6 V | |
bwang | 0:941e150e78b6 | 207 | | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V | with External Vpp = 9V | |
bwang | 0:941e150e78b6 | 208 | |---------------|----------------|----------------|-----------------|-----------------|-----------------------------| |
bwang | 0:941e150e78b6 | 209 | |Max Parallelism| x32 | x16 | x8 | x64 | |
bwang | 0:941e150e78b6 | 210 | |---------------|----------------|----------------|-----------------|-----------------|-----------------------------| |
bwang | 0:941e150e78b6 | 211 | |PSIZE[1:0] | 10 | 01 | 00 | 11 | |
bwang | 0:941e150e78b6 | 212 | +-------------------------------------------------------------------------------------------------------------------+ |
bwang | 0:941e150e78b6 | 213 | |
bwang | 0:941e150e78b6 | 214 | -@- On STM32F405xx/407xx and STM32F415xx/417xx devices: |
bwang | 0:941e150e78b6 | 215 | (++) when VOS = '0' Scale 2 mode, the maximum value of fHCLK = 144MHz. |
bwang | 0:941e150e78b6 | 216 | (++) when VOS = '1' Scale 1 mode, the maximum value of fHCLK = 168MHz. |
bwang | 0:941e150e78b6 | 217 | [..] |
bwang | 0:941e150e78b6 | 218 | On STM32F42xxx/43xxx devices: |
bwang | 0:941e150e78b6 | 219 | (++) when VOS[1:0] = '0x01' Scale 3 mode, the maximum value of fHCLK is 120MHz. |
bwang | 0:941e150e78b6 | 220 | (++) when VOS[1:0] = '0x10' Scale 2 mode, the maximum value of fHCLK is 144MHz if OverDrive OFF and 168MHz if OverDrive ON. |
bwang | 0:941e150e78b6 | 221 | (++) when VOS[1:0] = '0x11' Scale 1 mode, the maximum value of fHCLK is 168MHz if OverDrive OFF and 180MHz if OverDrive ON. |
bwang | 0:941e150e78b6 | 222 | [..] |
bwang | 0:941e150e78b6 | 223 | On STM32F401x devices: |
bwang | 0:941e150e78b6 | 224 | (++) when VOS[1:0] = '0x01' Scale 3 mode, the maximum value of fHCLK is 60MHz. |
bwang | 0:941e150e78b6 | 225 | (++) when VOS[1:0] = '0x10' Scale 2 mode, the maximum value of fHCLK is 84MHz. |
bwang | 0:941e150e78b6 | 226 | [..] |
bwang | 0:941e150e78b6 | 227 | On STM32F410xx/STM32F411xE devices: |
bwang | 0:941e150e78b6 | 228 | (++) when VOS[1:0] = '0x01' Scale 3 mode, the maximum value of fHCLK is 64MHz. |
bwang | 0:941e150e78b6 | 229 | (++) when VOS[1:0] = '0x10' Scale 2 mode, the maximum value of fHCLK is 84MHz. |
bwang | 0:941e150e78b6 | 230 | (++) when VOS[1:0] = '0x11' Scale 1 mode, the maximum value of fHCLK is 100MHz. |
bwang | 0:941e150e78b6 | 231 | |
bwang | 0:941e150e78b6 | 232 | For more details please refer product DataSheet |
bwang | 0:941e150e78b6 | 233 | You can use PWR_MainRegulatorModeConfig() function to control VOS bits. |
bwang | 0:941e150e78b6 | 234 | |
bwang | 0:941e150e78b6 | 235 | (+) void FLASH_PrefetchBufferCmd(FunctionalState NewState) |
bwang | 0:941e150e78b6 | 236 | (+) void FLASH_InstructionCacheCmd(FunctionalState NewState) |
bwang | 0:941e150e78b6 | 237 | (+) void FLASH_DataCacheCmd(FunctionalState NewState) |
bwang | 0:941e150e78b6 | 238 | (+) void FLASH_InstructionCacheReset(void) |
bwang | 0:941e150e78b6 | 239 | (+) void FLASH_DataCacheReset(void) |
bwang | 0:941e150e78b6 | 240 | |
bwang | 0:941e150e78b6 | 241 | [..] |
bwang | 0:941e150e78b6 | 242 | The unlock sequence is not needed for these functions. |
bwang | 0:941e150e78b6 | 243 | |
bwang | 0:941e150e78b6 | 244 | @endverbatim |
bwang | 0:941e150e78b6 | 245 | * @{ |
bwang | 0:941e150e78b6 | 246 | */ |
bwang | 0:941e150e78b6 | 247 | |
bwang | 0:941e150e78b6 | 248 | /** |
bwang | 0:941e150e78b6 | 249 | * @brief Sets the code latency value. |
bwang | 0:941e150e78b6 | 250 | * @param FLASH_Latency: specifies the FLASH Latency value. |
bwang | 0:941e150e78b6 | 251 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 252 | * @arg FLASH_Latency_0: FLASH Zero Latency cycle |
bwang | 0:941e150e78b6 | 253 | * @arg FLASH_Latency_1: FLASH One Latency cycle |
bwang | 0:941e150e78b6 | 254 | * @arg FLASH_Latency_2: FLASH Two Latency cycles |
bwang | 0:941e150e78b6 | 255 | * @arg FLASH_Latency_3: FLASH Three Latency cycles |
bwang | 0:941e150e78b6 | 256 | * @arg FLASH_Latency_4: FLASH Four Latency cycles |
bwang | 0:941e150e78b6 | 257 | * @arg FLASH_Latency_5: FLASH Five Latency cycles |
bwang | 0:941e150e78b6 | 258 | * @arg FLASH_Latency_6: FLASH Six Latency cycles |
bwang | 0:941e150e78b6 | 259 | * @arg FLASH_Latency_7: FLASH Seven Latency cycles |
bwang | 0:941e150e78b6 | 260 | * @arg FLASH_Latency_8: FLASH Eight Latency cycles |
bwang | 0:941e150e78b6 | 261 | * @arg FLASH_Latency_9: FLASH Nine Latency cycles |
bwang | 0:941e150e78b6 | 262 | * @arg FLASH_Latency_10: FLASH Teen Latency cycles |
bwang | 0:941e150e78b6 | 263 | * @arg FLASH_Latency_11: FLASH Eleven Latency cycles |
bwang | 0:941e150e78b6 | 264 | * @arg FLASH_Latency_12: FLASH Twelve Latency cycles |
bwang | 0:941e150e78b6 | 265 | * @arg FLASH_Latency_13: FLASH Thirteen Latency cycles |
bwang | 0:941e150e78b6 | 266 | * @arg FLASH_Latency_14: FLASH Fourteen Latency cycles |
bwang | 0:941e150e78b6 | 267 | * @arg FLASH_Latency_15: FLASH Fifteen Latency cycles |
bwang | 0:941e150e78b6 | 268 | * |
bwang | 0:941e150e78b6 | 269 | * @note For STM32F405xx/407xx, STM32F415xx/417xx, STM32F401xx/411xE and STM32F412xG devices |
bwang | 0:941e150e78b6 | 270 | * this parameter can be a value between FLASH_Latency_0 and FLASH_Latency_7. |
bwang | 0:941e150e78b6 | 271 | * |
bwang | 0:941e150e78b6 | 272 | * @note For STM32F42xxx/43xxx devices this parameter can be a value between |
bwang | 0:941e150e78b6 | 273 | * FLASH_Latency_0 and FLASH_Latency_15. |
bwang | 0:941e150e78b6 | 274 | * |
bwang | 0:941e150e78b6 | 275 | * @retval None |
bwang | 0:941e150e78b6 | 276 | */ |
bwang | 0:941e150e78b6 | 277 | void FLASH_SetLatency(uint32_t FLASH_Latency) |
bwang | 0:941e150e78b6 | 278 | { |
bwang | 0:941e150e78b6 | 279 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 280 | assert_param(IS_FLASH_LATENCY(FLASH_Latency)); |
bwang | 0:941e150e78b6 | 281 | |
bwang | 0:941e150e78b6 | 282 | /* Perform Byte access to FLASH_ACR[8:0] to set the Latency value */ |
bwang | 0:941e150e78b6 | 283 | *(__IO uint8_t *)ACR_BYTE0_ADDRESS = (uint8_t)FLASH_Latency; |
bwang | 0:941e150e78b6 | 284 | } |
bwang | 0:941e150e78b6 | 285 | |
bwang | 0:941e150e78b6 | 286 | /** |
bwang | 0:941e150e78b6 | 287 | * @brief Enables or disables the Prefetch Buffer. |
bwang | 0:941e150e78b6 | 288 | * @param NewState: new state of the Prefetch Buffer. |
bwang | 0:941e150e78b6 | 289 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 290 | * @retval None |
bwang | 0:941e150e78b6 | 291 | */ |
bwang | 0:941e150e78b6 | 292 | void FLASH_PrefetchBufferCmd(FunctionalState NewState) |
bwang | 0:941e150e78b6 | 293 | { |
bwang | 0:941e150e78b6 | 294 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 295 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 296 | |
bwang | 0:941e150e78b6 | 297 | /* Enable or disable the Prefetch Buffer */ |
bwang | 0:941e150e78b6 | 298 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 299 | { |
bwang | 0:941e150e78b6 | 300 | FLASH->ACR |= FLASH_ACR_PRFTEN; |
bwang | 0:941e150e78b6 | 301 | } |
bwang | 0:941e150e78b6 | 302 | else |
bwang | 0:941e150e78b6 | 303 | { |
bwang | 0:941e150e78b6 | 304 | FLASH->ACR &= (~FLASH_ACR_PRFTEN); |
bwang | 0:941e150e78b6 | 305 | } |
bwang | 0:941e150e78b6 | 306 | } |
bwang | 0:941e150e78b6 | 307 | |
bwang | 0:941e150e78b6 | 308 | /** |
bwang | 0:941e150e78b6 | 309 | * @brief Enables or disables the Instruction Cache feature. |
bwang | 0:941e150e78b6 | 310 | * @param NewState: new state of the Instruction Cache. |
bwang | 0:941e150e78b6 | 311 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 312 | * @retval None |
bwang | 0:941e150e78b6 | 313 | */ |
bwang | 0:941e150e78b6 | 314 | void FLASH_InstructionCacheCmd(FunctionalState NewState) |
bwang | 0:941e150e78b6 | 315 | { |
bwang | 0:941e150e78b6 | 316 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 317 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 318 | |
bwang | 0:941e150e78b6 | 319 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 320 | { |
bwang | 0:941e150e78b6 | 321 | FLASH->ACR |= FLASH_ACR_ICEN; |
bwang | 0:941e150e78b6 | 322 | } |
bwang | 0:941e150e78b6 | 323 | else |
bwang | 0:941e150e78b6 | 324 | { |
bwang | 0:941e150e78b6 | 325 | FLASH->ACR &= (~FLASH_ACR_ICEN); |
bwang | 0:941e150e78b6 | 326 | } |
bwang | 0:941e150e78b6 | 327 | } |
bwang | 0:941e150e78b6 | 328 | |
bwang | 0:941e150e78b6 | 329 | /** |
bwang | 0:941e150e78b6 | 330 | * @brief Enables or disables the Data Cache feature. |
bwang | 0:941e150e78b6 | 331 | * @param NewState: new state of the Data Cache. |
bwang | 0:941e150e78b6 | 332 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 333 | * @retval None |
bwang | 0:941e150e78b6 | 334 | */ |
bwang | 0:941e150e78b6 | 335 | void FLASH_DataCacheCmd(FunctionalState NewState) |
bwang | 0:941e150e78b6 | 336 | { |
bwang | 0:941e150e78b6 | 337 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 338 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 339 | |
bwang | 0:941e150e78b6 | 340 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 341 | { |
bwang | 0:941e150e78b6 | 342 | FLASH->ACR |= FLASH_ACR_DCEN; |
bwang | 0:941e150e78b6 | 343 | } |
bwang | 0:941e150e78b6 | 344 | else |
bwang | 0:941e150e78b6 | 345 | { |
bwang | 0:941e150e78b6 | 346 | FLASH->ACR &= (~FLASH_ACR_DCEN); |
bwang | 0:941e150e78b6 | 347 | } |
bwang | 0:941e150e78b6 | 348 | } |
bwang | 0:941e150e78b6 | 349 | |
bwang | 0:941e150e78b6 | 350 | /** |
bwang | 0:941e150e78b6 | 351 | * @brief Resets the Instruction Cache. |
bwang | 0:941e150e78b6 | 352 | * @note This function must be used only when the Instruction Cache is disabled. |
bwang | 0:941e150e78b6 | 353 | * @param None |
bwang | 0:941e150e78b6 | 354 | * @retval None |
bwang | 0:941e150e78b6 | 355 | */ |
bwang | 0:941e150e78b6 | 356 | void FLASH_InstructionCacheReset(void) |
bwang | 0:941e150e78b6 | 357 | { |
bwang | 0:941e150e78b6 | 358 | FLASH->ACR |= FLASH_ACR_ICRST; |
bwang | 0:941e150e78b6 | 359 | } |
bwang | 0:941e150e78b6 | 360 | |
bwang | 0:941e150e78b6 | 361 | /** |
bwang | 0:941e150e78b6 | 362 | * @brief Resets the Data Cache. |
bwang | 0:941e150e78b6 | 363 | * @note This function must be used only when the Data Cache is disabled. |
bwang | 0:941e150e78b6 | 364 | * @param None |
bwang | 0:941e150e78b6 | 365 | * @retval None |
bwang | 0:941e150e78b6 | 366 | */ |
bwang | 0:941e150e78b6 | 367 | void FLASH_DataCacheReset(void) |
bwang | 0:941e150e78b6 | 368 | { |
bwang | 0:941e150e78b6 | 369 | FLASH->ACR |= FLASH_ACR_DCRST; |
bwang | 0:941e150e78b6 | 370 | } |
bwang | 0:941e150e78b6 | 371 | |
bwang | 0:941e150e78b6 | 372 | /** |
bwang | 0:941e150e78b6 | 373 | * @} |
bwang | 0:941e150e78b6 | 374 | */ |
bwang | 0:941e150e78b6 | 375 | |
bwang | 0:941e150e78b6 | 376 | /** @defgroup FLASH_Group2 FLASH Memory Programming functions |
bwang | 0:941e150e78b6 | 377 | * @brief FLASH Memory Programming functions |
bwang | 0:941e150e78b6 | 378 | * |
bwang | 0:941e150e78b6 | 379 | @verbatim |
bwang | 0:941e150e78b6 | 380 | =============================================================================== |
bwang | 0:941e150e78b6 | 381 | ##### FLASH Memory Programming functions ##### |
bwang | 0:941e150e78b6 | 382 | =============================================================================== |
bwang | 0:941e150e78b6 | 383 | [..] |
bwang | 0:941e150e78b6 | 384 | This group includes the following functions: |
bwang | 0:941e150e78b6 | 385 | (+) void FLASH_Unlock(void) |
bwang | 0:941e150e78b6 | 386 | (+) void FLASH_Lock(void) |
bwang | 0:941e150e78b6 | 387 | (+) FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 388 | (+) FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 389 | (+) FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data) |
bwang | 0:941e150e78b6 | 390 | (+) FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data) |
bwang | 0:941e150e78b6 | 391 | (+) FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) |
bwang | 0:941e150e78b6 | 392 | (+) FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data) |
bwang | 0:941e150e78b6 | 393 | The following functions can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 394 | (+) FLASH_Status FLASH_EraseAllBank1Sectors(uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 395 | (+) FLASH_Status FLASH_EraseAllBank2Sectors(uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 396 | [..] |
bwang | 0:941e150e78b6 | 397 | Any operation of erase or program should follow these steps: |
bwang | 0:941e150e78b6 | 398 | (#) Call the FLASH_Unlock() function to enable the FLASH control register access |
bwang | 0:941e150e78b6 | 399 | |
bwang | 0:941e150e78b6 | 400 | (#) Call the desired function to erase sector(s) or program data |
bwang | 0:941e150e78b6 | 401 | |
bwang | 0:941e150e78b6 | 402 | (#) Call the FLASH_Lock() function to disable the FLASH control register access |
bwang | 0:941e150e78b6 | 403 | (recommended to protect the FLASH memory against possible unwanted operation) |
bwang | 0:941e150e78b6 | 404 | |
bwang | 0:941e150e78b6 | 405 | @endverbatim |
bwang | 0:941e150e78b6 | 406 | * @{ |
bwang | 0:941e150e78b6 | 407 | */ |
bwang | 0:941e150e78b6 | 408 | |
bwang | 0:941e150e78b6 | 409 | /** |
bwang | 0:941e150e78b6 | 410 | * @brief Unlocks the FLASH control register access |
bwang | 0:941e150e78b6 | 411 | * @param None |
bwang | 0:941e150e78b6 | 412 | * @retval None |
bwang | 0:941e150e78b6 | 413 | */ |
bwang | 0:941e150e78b6 | 414 | void FLASH_Unlock(void) |
bwang | 0:941e150e78b6 | 415 | { |
bwang | 0:941e150e78b6 | 416 | if((FLASH->CR & FLASH_CR_LOCK) != RESET) |
bwang | 0:941e150e78b6 | 417 | { |
bwang | 0:941e150e78b6 | 418 | /* Authorize the FLASH Registers access */ |
bwang | 0:941e150e78b6 | 419 | FLASH->KEYR = FLASH_KEY1; |
bwang | 0:941e150e78b6 | 420 | FLASH->KEYR = FLASH_KEY2; |
bwang | 0:941e150e78b6 | 421 | } |
bwang | 0:941e150e78b6 | 422 | } |
bwang | 0:941e150e78b6 | 423 | |
bwang | 0:941e150e78b6 | 424 | /** |
bwang | 0:941e150e78b6 | 425 | * @brief Locks the FLASH control register access |
bwang | 0:941e150e78b6 | 426 | * @param None |
bwang | 0:941e150e78b6 | 427 | * @retval None |
bwang | 0:941e150e78b6 | 428 | */ |
bwang | 0:941e150e78b6 | 429 | void FLASH_Lock(void) |
bwang | 0:941e150e78b6 | 430 | { |
bwang | 0:941e150e78b6 | 431 | /* Set the LOCK Bit to lock the FLASH Registers access */ |
bwang | 0:941e150e78b6 | 432 | FLASH->CR |= FLASH_CR_LOCK; |
bwang | 0:941e150e78b6 | 433 | } |
bwang | 0:941e150e78b6 | 434 | |
bwang | 0:941e150e78b6 | 435 | /** |
bwang | 0:941e150e78b6 | 436 | * @brief Erases a specified FLASH Sector. |
bwang | 0:941e150e78b6 | 437 | * |
bwang | 0:941e150e78b6 | 438 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 439 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 440 | * |
bwang | 0:941e150e78b6 | 441 | * @param FLASH_Sector: The Sector number to be erased. |
bwang | 0:941e150e78b6 | 442 | * |
bwang | 0:941e150e78b6 | 443 | * @note For STM32F405xx/407xx and STM32F415xx/417xx devices this parameter can |
bwang | 0:941e150e78b6 | 444 | * be a value between FLASH_Sector_0 and FLASH_Sector_11. |
bwang | 0:941e150e78b6 | 445 | * |
bwang | 0:941e150e78b6 | 446 | * For STM32F42xxx/43xxx devices this parameter can be a value between |
bwang | 0:941e150e78b6 | 447 | * FLASH_Sector_0 and FLASH_Sector_23. |
bwang | 0:941e150e78b6 | 448 | * |
bwang | 0:941e150e78b6 | 449 | * For STM32F401xx devices this parameter can be a value between |
bwang | 0:941e150e78b6 | 450 | * FLASH_Sector_0 and FLASH_Sector_5. |
bwang | 0:941e150e78b6 | 451 | * |
bwang | 0:941e150e78b6 | 452 | * For STM32F411xE and STM32F412xG devices this parameter can be a value between |
bwang | 0:941e150e78b6 | 453 | * FLASH_Sector_0 and FLASH_Sector_7. |
bwang | 0:941e150e78b6 | 454 | * |
bwang | 0:941e150e78b6 | 455 | * For STM32F410xx devices this parameter can be a value between |
bwang | 0:941e150e78b6 | 456 | * FLASH_Sector_0 and FLASH_Sector_4. |
bwang | 0:941e150e78b6 | 457 | * |
bwang | 0:941e150e78b6 | 458 | * @param VoltageRange: The device voltage range which defines the erase parallelism. |
bwang | 0:941e150e78b6 | 459 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 460 | * @arg VoltageRange_1: when the device voltage range is 1.8V to 2.1V, |
bwang | 0:941e150e78b6 | 461 | * the operation will be done by byte (8-bit) |
bwang | 0:941e150e78b6 | 462 | * @arg VoltageRange_2: when the device voltage range is 2.1V to 2.7V, |
bwang | 0:941e150e78b6 | 463 | * the operation will be done by half word (16-bit) |
bwang | 0:941e150e78b6 | 464 | * @arg VoltageRange_3: when the device voltage range is 2.7V to 3.6V, |
bwang | 0:941e150e78b6 | 465 | * the operation will be done by word (32-bit) |
bwang | 0:941e150e78b6 | 466 | * @arg VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, |
bwang | 0:941e150e78b6 | 467 | * the operation will be done by double word (64-bit) |
bwang | 0:941e150e78b6 | 468 | * |
bwang | 0:941e150e78b6 | 469 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 470 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 471 | */ |
bwang | 0:941e150e78b6 | 472 | FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 473 | { |
bwang | 0:941e150e78b6 | 474 | uint32_t tmp_psize = 0x0; |
bwang | 0:941e150e78b6 | 475 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 476 | |
bwang | 0:941e150e78b6 | 477 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 478 | assert_param(IS_FLASH_SECTOR(FLASH_Sector)); |
bwang | 0:941e150e78b6 | 479 | assert_param(IS_VOLTAGERANGE(VoltageRange)); |
bwang | 0:941e150e78b6 | 480 | |
bwang | 0:941e150e78b6 | 481 | if(VoltageRange == VoltageRange_1) |
bwang | 0:941e150e78b6 | 482 | { |
bwang | 0:941e150e78b6 | 483 | tmp_psize = FLASH_PSIZE_BYTE; |
bwang | 0:941e150e78b6 | 484 | } |
bwang | 0:941e150e78b6 | 485 | else if(VoltageRange == VoltageRange_2) |
bwang | 0:941e150e78b6 | 486 | { |
bwang | 0:941e150e78b6 | 487 | tmp_psize = FLASH_PSIZE_HALF_WORD; |
bwang | 0:941e150e78b6 | 488 | } |
bwang | 0:941e150e78b6 | 489 | else if(VoltageRange == VoltageRange_3) |
bwang | 0:941e150e78b6 | 490 | { |
bwang | 0:941e150e78b6 | 491 | tmp_psize = FLASH_PSIZE_WORD; |
bwang | 0:941e150e78b6 | 492 | } |
bwang | 0:941e150e78b6 | 493 | else |
bwang | 0:941e150e78b6 | 494 | { |
bwang | 0:941e150e78b6 | 495 | tmp_psize = FLASH_PSIZE_DOUBLE_WORD; |
bwang | 0:941e150e78b6 | 496 | } |
bwang | 0:941e150e78b6 | 497 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 498 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 499 | |
bwang | 0:941e150e78b6 | 500 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 501 | { |
bwang | 0:941e150e78b6 | 502 | /* if the previous operation is completed, proceed to erase the sector */ |
bwang | 0:941e150e78b6 | 503 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 504 | FLASH->CR |= tmp_psize; |
bwang | 0:941e150e78b6 | 505 | FLASH->CR &= SECTOR_MASK; |
bwang | 0:941e150e78b6 | 506 | FLASH->CR |= FLASH_CR_SER | FLASH_Sector; |
bwang | 0:941e150e78b6 | 507 | FLASH->CR |= FLASH_CR_STRT; |
bwang | 0:941e150e78b6 | 508 | |
bwang | 0:941e150e78b6 | 509 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 510 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 511 | |
bwang | 0:941e150e78b6 | 512 | /* if the erase operation is completed, disable the SER Bit */ |
bwang | 0:941e150e78b6 | 513 | FLASH->CR &= (~FLASH_CR_SER); |
bwang | 0:941e150e78b6 | 514 | FLASH->CR &= SECTOR_MASK; |
bwang | 0:941e150e78b6 | 515 | } |
bwang | 0:941e150e78b6 | 516 | /* Return the Erase Status */ |
bwang | 0:941e150e78b6 | 517 | return status; |
bwang | 0:941e150e78b6 | 518 | } |
bwang | 0:941e150e78b6 | 519 | |
bwang | 0:941e150e78b6 | 520 | /** |
bwang | 0:941e150e78b6 | 521 | * @brief Erases all FLASH Sectors. |
bwang | 0:941e150e78b6 | 522 | * |
bwang | 0:941e150e78b6 | 523 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 524 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 525 | * |
bwang | 0:941e150e78b6 | 526 | * @param VoltageRange: The device voltage range which defines the erase parallelism. |
bwang | 0:941e150e78b6 | 527 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 528 | * @arg VoltageRange_1: when the device voltage range is 1.8V to 2.1V, |
bwang | 0:941e150e78b6 | 529 | * the operation will be done by byte (8-bit) |
bwang | 0:941e150e78b6 | 530 | * @arg VoltageRange_2: when the device voltage range is 2.1V to 2.7V, |
bwang | 0:941e150e78b6 | 531 | * the operation will be done by half word (16-bit) |
bwang | 0:941e150e78b6 | 532 | * @arg VoltageRange_3: when the device voltage range is 2.7V to 3.6V, |
bwang | 0:941e150e78b6 | 533 | * the operation will be done by word (32-bit) |
bwang | 0:941e150e78b6 | 534 | * @arg VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, |
bwang | 0:941e150e78b6 | 535 | * the operation will be done by double word (64-bit) |
bwang | 0:941e150e78b6 | 536 | * |
bwang | 0:941e150e78b6 | 537 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 538 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 539 | */ |
bwang | 0:941e150e78b6 | 540 | FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 541 | { |
bwang | 0:941e150e78b6 | 542 | uint32_t tmp_psize = 0x0; |
bwang | 0:941e150e78b6 | 543 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 544 | |
bwang | 0:941e150e78b6 | 545 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 546 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 547 | assert_param(IS_VOLTAGERANGE(VoltageRange)); |
bwang | 0:941e150e78b6 | 548 | |
bwang | 0:941e150e78b6 | 549 | if(VoltageRange == VoltageRange_1) |
bwang | 0:941e150e78b6 | 550 | { |
bwang | 0:941e150e78b6 | 551 | tmp_psize = FLASH_PSIZE_BYTE; |
bwang | 0:941e150e78b6 | 552 | } |
bwang | 0:941e150e78b6 | 553 | else if(VoltageRange == VoltageRange_2) |
bwang | 0:941e150e78b6 | 554 | { |
bwang | 0:941e150e78b6 | 555 | tmp_psize = FLASH_PSIZE_HALF_WORD; |
bwang | 0:941e150e78b6 | 556 | } |
bwang | 0:941e150e78b6 | 557 | else if(VoltageRange == VoltageRange_3) |
bwang | 0:941e150e78b6 | 558 | { |
bwang | 0:941e150e78b6 | 559 | tmp_psize = FLASH_PSIZE_WORD; |
bwang | 0:941e150e78b6 | 560 | } |
bwang | 0:941e150e78b6 | 561 | else |
bwang | 0:941e150e78b6 | 562 | { |
bwang | 0:941e150e78b6 | 563 | tmp_psize = FLASH_PSIZE_DOUBLE_WORD; |
bwang | 0:941e150e78b6 | 564 | } |
bwang | 0:941e150e78b6 | 565 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 566 | { |
bwang | 0:941e150e78b6 | 567 | /* if the previous operation is completed, proceed to erase all sectors */ |
bwang | 0:941e150e78b6 | 568 | #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx) |
bwang | 0:941e150e78b6 | 569 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 570 | FLASH->CR |= tmp_psize; |
bwang | 0:941e150e78b6 | 571 | FLASH->CR |= (FLASH_CR_MER1 | FLASH_CR_MER2); |
bwang | 0:941e150e78b6 | 572 | FLASH->CR |= FLASH_CR_STRT; |
bwang | 0:941e150e78b6 | 573 | |
bwang | 0:941e150e78b6 | 574 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 575 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 576 | |
bwang | 0:941e150e78b6 | 577 | /* if the erase operation is completed, disable the MER Bit */ |
bwang | 0:941e150e78b6 | 578 | FLASH->CR &= ~(FLASH_CR_MER1 | FLASH_CR_MER2); |
bwang | 0:941e150e78b6 | 579 | #endif /* STM32F427_437xx || STM32F429_439xx || STM32F469_479xx */ |
bwang | 0:941e150e78b6 | 580 | |
bwang | 0:941e150e78b6 | 581 | #if defined(STM32F40_41xxx) || defined(STM32F401xx) || defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F446xx) |
bwang | 0:941e150e78b6 | 582 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 583 | FLASH->CR |= tmp_psize; |
bwang | 0:941e150e78b6 | 584 | FLASH->CR |= FLASH_CR_MER; |
bwang | 0:941e150e78b6 | 585 | FLASH->CR |= FLASH_CR_STRT; |
bwang | 0:941e150e78b6 | 586 | |
bwang | 0:941e150e78b6 | 587 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 588 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 589 | |
bwang | 0:941e150e78b6 | 590 | /* if the erase operation is completed, disable the MER Bit */ |
bwang | 0:941e150e78b6 | 591 | FLASH->CR &= (~FLASH_CR_MER); |
bwang | 0:941e150e78b6 | 592 | #endif /* STM32F40_41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F412xG || STM32F446xx */ |
bwang | 0:941e150e78b6 | 593 | |
bwang | 0:941e150e78b6 | 594 | } |
bwang | 0:941e150e78b6 | 595 | /* Return the Erase Status */ |
bwang | 0:941e150e78b6 | 596 | return status; |
bwang | 0:941e150e78b6 | 597 | } |
bwang | 0:941e150e78b6 | 598 | |
bwang | 0:941e150e78b6 | 599 | /** |
bwang | 0:941e150e78b6 | 600 | * @brief Erases all FLASH Sectors in Bank 1. |
bwang | 0:941e150e78b6 | 601 | * |
bwang | 0:941e150e78b6 | 602 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 603 | * |
bwang | 0:941e150e78b6 | 604 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 605 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 606 | * |
bwang | 0:941e150e78b6 | 607 | * @param VoltageRange: The device voltage range which defines the erase parallelism. |
bwang | 0:941e150e78b6 | 608 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 609 | * @arg VoltageRange_1: when the device voltage range is 1.8V to 2.1V, |
bwang | 0:941e150e78b6 | 610 | * the operation will be done by byte (8-bit) |
bwang | 0:941e150e78b6 | 611 | * @arg VoltageRange_2: when the device voltage range is 2.1V to 2.7V, |
bwang | 0:941e150e78b6 | 612 | * the operation will be done by half word (16-bit) |
bwang | 0:941e150e78b6 | 613 | * @arg VoltageRange_3: when the device voltage range is 2.7V to 3.6V, |
bwang | 0:941e150e78b6 | 614 | * the operation will be done by word (32-bit) |
bwang | 0:941e150e78b6 | 615 | * @arg VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, |
bwang | 0:941e150e78b6 | 616 | * the operation will be done by double word (64-bit) |
bwang | 0:941e150e78b6 | 617 | * |
bwang | 0:941e150e78b6 | 618 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 619 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 620 | */ |
bwang | 0:941e150e78b6 | 621 | FLASH_Status FLASH_EraseAllBank1Sectors(uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 622 | { |
bwang | 0:941e150e78b6 | 623 | uint32_t tmp_psize = 0x0; |
bwang | 0:941e150e78b6 | 624 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 625 | |
bwang | 0:941e150e78b6 | 626 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 627 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 628 | assert_param(IS_VOLTAGERANGE(VoltageRange)); |
bwang | 0:941e150e78b6 | 629 | |
bwang | 0:941e150e78b6 | 630 | if(VoltageRange == VoltageRange_1) |
bwang | 0:941e150e78b6 | 631 | { |
bwang | 0:941e150e78b6 | 632 | tmp_psize = FLASH_PSIZE_BYTE; |
bwang | 0:941e150e78b6 | 633 | } |
bwang | 0:941e150e78b6 | 634 | else if(VoltageRange == VoltageRange_2) |
bwang | 0:941e150e78b6 | 635 | { |
bwang | 0:941e150e78b6 | 636 | tmp_psize = FLASH_PSIZE_HALF_WORD; |
bwang | 0:941e150e78b6 | 637 | } |
bwang | 0:941e150e78b6 | 638 | else if(VoltageRange == VoltageRange_3) |
bwang | 0:941e150e78b6 | 639 | { |
bwang | 0:941e150e78b6 | 640 | tmp_psize = FLASH_PSIZE_WORD; |
bwang | 0:941e150e78b6 | 641 | } |
bwang | 0:941e150e78b6 | 642 | else |
bwang | 0:941e150e78b6 | 643 | { |
bwang | 0:941e150e78b6 | 644 | tmp_psize = FLASH_PSIZE_DOUBLE_WORD; |
bwang | 0:941e150e78b6 | 645 | } |
bwang | 0:941e150e78b6 | 646 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 647 | { |
bwang | 0:941e150e78b6 | 648 | /* if the previous operation is completed, proceed to erase all sectors */ |
bwang | 0:941e150e78b6 | 649 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 650 | FLASH->CR |= tmp_psize; |
bwang | 0:941e150e78b6 | 651 | FLASH->CR |= FLASH_CR_MER1; |
bwang | 0:941e150e78b6 | 652 | FLASH->CR |= FLASH_CR_STRT; |
bwang | 0:941e150e78b6 | 653 | |
bwang | 0:941e150e78b6 | 654 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 655 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 656 | |
bwang | 0:941e150e78b6 | 657 | /* if the erase operation is completed, disable the MER Bit */ |
bwang | 0:941e150e78b6 | 658 | FLASH->CR &= (~FLASH_CR_MER1); |
bwang | 0:941e150e78b6 | 659 | |
bwang | 0:941e150e78b6 | 660 | } |
bwang | 0:941e150e78b6 | 661 | /* Return the Erase Status */ |
bwang | 0:941e150e78b6 | 662 | return status; |
bwang | 0:941e150e78b6 | 663 | } |
bwang | 0:941e150e78b6 | 664 | |
bwang | 0:941e150e78b6 | 665 | |
bwang | 0:941e150e78b6 | 666 | /** |
bwang | 0:941e150e78b6 | 667 | * @brief Erases all FLASH Sectors in Bank 2. |
bwang | 0:941e150e78b6 | 668 | * |
bwang | 0:941e150e78b6 | 669 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 670 | * |
bwang | 0:941e150e78b6 | 671 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 672 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 673 | * |
bwang | 0:941e150e78b6 | 674 | * @param VoltageRange: The device voltage range which defines the erase parallelism. |
bwang | 0:941e150e78b6 | 675 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 676 | * @arg VoltageRange_1: when the device voltage range is 1.8V to 2.1V, |
bwang | 0:941e150e78b6 | 677 | * the operation will be done by byte (8-bit) |
bwang | 0:941e150e78b6 | 678 | * @arg VoltageRange_2: when the device voltage range is 2.1V to 2.7V, |
bwang | 0:941e150e78b6 | 679 | * the operation will be done by half word (16-bit) |
bwang | 0:941e150e78b6 | 680 | * @arg VoltageRange_3: when the device voltage range is 2.7V to 3.6V, |
bwang | 0:941e150e78b6 | 681 | * the operation will be done by word (32-bit) |
bwang | 0:941e150e78b6 | 682 | * @arg VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, |
bwang | 0:941e150e78b6 | 683 | * the operation will be done by double word (64-bit) |
bwang | 0:941e150e78b6 | 684 | * |
bwang | 0:941e150e78b6 | 685 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 686 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 687 | */ |
bwang | 0:941e150e78b6 | 688 | FLASH_Status FLASH_EraseAllBank2Sectors(uint8_t VoltageRange) |
bwang | 0:941e150e78b6 | 689 | { |
bwang | 0:941e150e78b6 | 690 | uint32_t tmp_psize = 0x0; |
bwang | 0:941e150e78b6 | 691 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 692 | |
bwang | 0:941e150e78b6 | 693 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 694 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 695 | assert_param(IS_VOLTAGERANGE(VoltageRange)); |
bwang | 0:941e150e78b6 | 696 | |
bwang | 0:941e150e78b6 | 697 | if(VoltageRange == VoltageRange_1) |
bwang | 0:941e150e78b6 | 698 | { |
bwang | 0:941e150e78b6 | 699 | tmp_psize = FLASH_PSIZE_BYTE; |
bwang | 0:941e150e78b6 | 700 | } |
bwang | 0:941e150e78b6 | 701 | else if(VoltageRange == VoltageRange_2) |
bwang | 0:941e150e78b6 | 702 | { |
bwang | 0:941e150e78b6 | 703 | tmp_psize = FLASH_PSIZE_HALF_WORD; |
bwang | 0:941e150e78b6 | 704 | } |
bwang | 0:941e150e78b6 | 705 | else if(VoltageRange == VoltageRange_3) |
bwang | 0:941e150e78b6 | 706 | { |
bwang | 0:941e150e78b6 | 707 | tmp_psize = FLASH_PSIZE_WORD; |
bwang | 0:941e150e78b6 | 708 | } |
bwang | 0:941e150e78b6 | 709 | else |
bwang | 0:941e150e78b6 | 710 | { |
bwang | 0:941e150e78b6 | 711 | tmp_psize = FLASH_PSIZE_DOUBLE_WORD; |
bwang | 0:941e150e78b6 | 712 | } |
bwang | 0:941e150e78b6 | 713 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 714 | { |
bwang | 0:941e150e78b6 | 715 | /* if the previous operation is completed, proceed to erase all sectors */ |
bwang | 0:941e150e78b6 | 716 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 717 | FLASH->CR |= tmp_psize; |
bwang | 0:941e150e78b6 | 718 | FLASH->CR |= FLASH_CR_MER2; |
bwang | 0:941e150e78b6 | 719 | FLASH->CR |= FLASH_CR_STRT; |
bwang | 0:941e150e78b6 | 720 | |
bwang | 0:941e150e78b6 | 721 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 722 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 723 | |
bwang | 0:941e150e78b6 | 724 | /* if the erase operation is completed, disable the MER Bit */ |
bwang | 0:941e150e78b6 | 725 | FLASH->CR &= (~FLASH_CR_MER2); |
bwang | 0:941e150e78b6 | 726 | |
bwang | 0:941e150e78b6 | 727 | } |
bwang | 0:941e150e78b6 | 728 | /* Return the Erase Status */ |
bwang | 0:941e150e78b6 | 729 | return status; |
bwang | 0:941e150e78b6 | 730 | } |
bwang | 0:941e150e78b6 | 731 | |
bwang | 0:941e150e78b6 | 732 | /** |
bwang | 0:941e150e78b6 | 733 | * @brief Programs a double word (64-bit) at a specified address. |
bwang | 0:941e150e78b6 | 734 | * @note This function must be used when the device voltage range is from |
bwang | 0:941e150e78b6 | 735 | * 2.7V to 3.6V and an External Vpp is present. |
bwang | 0:941e150e78b6 | 736 | * |
bwang | 0:941e150e78b6 | 737 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 738 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 739 | * |
bwang | 0:941e150e78b6 | 740 | * @param Address: specifies the address to be programmed. |
bwang | 0:941e150e78b6 | 741 | * @param Data: specifies the data to be programmed. |
bwang | 0:941e150e78b6 | 742 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 743 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 744 | */ |
bwang | 0:941e150e78b6 | 745 | FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data) |
bwang | 0:941e150e78b6 | 746 | { |
bwang | 0:941e150e78b6 | 747 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 748 | |
bwang | 0:941e150e78b6 | 749 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 750 | assert_param(IS_FLASH_ADDRESS(Address)); |
bwang | 0:941e150e78b6 | 751 | |
bwang | 0:941e150e78b6 | 752 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 753 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 754 | |
bwang | 0:941e150e78b6 | 755 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 756 | { |
bwang | 0:941e150e78b6 | 757 | /* if the previous operation is completed, proceed to program the new data */ |
bwang | 0:941e150e78b6 | 758 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 759 | FLASH->CR |= FLASH_PSIZE_DOUBLE_WORD; |
bwang | 0:941e150e78b6 | 760 | FLASH->CR |= FLASH_CR_PG; |
bwang | 0:941e150e78b6 | 761 | |
bwang | 0:941e150e78b6 | 762 | *(__IO uint64_t*)Address = Data; |
bwang | 0:941e150e78b6 | 763 | |
bwang | 0:941e150e78b6 | 764 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 765 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 766 | |
bwang | 0:941e150e78b6 | 767 | /* if the program operation is completed, disable the PG Bit */ |
bwang | 0:941e150e78b6 | 768 | FLASH->CR &= (~FLASH_CR_PG); |
bwang | 0:941e150e78b6 | 769 | } |
bwang | 0:941e150e78b6 | 770 | /* Return the Program Status */ |
bwang | 0:941e150e78b6 | 771 | return status; |
bwang | 0:941e150e78b6 | 772 | } |
bwang | 0:941e150e78b6 | 773 | |
bwang | 0:941e150e78b6 | 774 | /** |
bwang | 0:941e150e78b6 | 775 | * @brief Programs a word (32-bit) at a specified address. |
bwang | 0:941e150e78b6 | 776 | * |
bwang | 0:941e150e78b6 | 777 | * @note This function must be used when the device voltage range is from 2.7V to 3.6V. |
bwang | 0:941e150e78b6 | 778 | * |
bwang | 0:941e150e78b6 | 779 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 780 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 781 | * |
bwang | 0:941e150e78b6 | 782 | * @param Address: specifies the address to be programmed. |
bwang | 0:941e150e78b6 | 783 | * This parameter can be any address in Program memory zone or in OTP zone. |
bwang | 0:941e150e78b6 | 784 | * @param Data: specifies the data to be programmed. |
bwang | 0:941e150e78b6 | 785 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 786 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 787 | */ |
bwang | 0:941e150e78b6 | 788 | FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data) |
bwang | 0:941e150e78b6 | 789 | { |
bwang | 0:941e150e78b6 | 790 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 791 | |
bwang | 0:941e150e78b6 | 792 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 793 | assert_param(IS_FLASH_ADDRESS(Address)); |
bwang | 0:941e150e78b6 | 794 | |
bwang | 0:941e150e78b6 | 795 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 796 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 797 | |
bwang | 0:941e150e78b6 | 798 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 799 | { |
bwang | 0:941e150e78b6 | 800 | /* if the previous operation is completed, proceed to program the new data */ |
bwang | 0:941e150e78b6 | 801 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 802 | FLASH->CR |= FLASH_PSIZE_WORD; |
bwang | 0:941e150e78b6 | 803 | FLASH->CR |= FLASH_CR_PG; |
bwang | 0:941e150e78b6 | 804 | |
bwang | 0:941e150e78b6 | 805 | *(__IO uint32_t*)Address = Data; |
bwang | 0:941e150e78b6 | 806 | |
bwang | 0:941e150e78b6 | 807 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 808 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 809 | |
bwang | 0:941e150e78b6 | 810 | /* if the program operation is completed, disable the PG Bit */ |
bwang | 0:941e150e78b6 | 811 | FLASH->CR &= (~FLASH_CR_PG); |
bwang | 0:941e150e78b6 | 812 | } |
bwang | 0:941e150e78b6 | 813 | /* Return the Program Status */ |
bwang | 0:941e150e78b6 | 814 | return status; |
bwang | 0:941e150e78b6 | 815 | } |
bwang | 0:941e150e78b6 | 816 | |
bwang | 0:941e150e78b6 | 817 | /** |
bwang | 0:941e150e78b6 | 818 | * @brief Programs a half word (16-bit) at a specified address. |
bwang | 0:941e150e78b6 | 819 | * @note This function must be used when the device voltage range is from 2.1V to 3.6V. |
bwang | 0:941e150e78b6 | 820 | * |
bwang | 0:941e150e78b6 | 821 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 822 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 823 | * |
bwang | 0:941e150e78b6 | 824 | * @param Address: specifies the address to be programmed. |
bwang | 0:941e150e78b6 | 825 | * This parameter can be any address in Program memory zone or in OTP zone. |
bwang | 0:941e150e78b6 | 826 | * @param Data: specifies the data to be programmed. |
bwang | 0:941e150e78b6 | 827 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 828 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 829 | */ |
bwang | 0:941e150e78b6 | 830 | FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) |
bwang | 0:941e150e78b6 | 831 | { |
bwang | 0:941e150e78b6 | 832 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 833 | |
bwang | 0:941e150e78b6 | 834 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 835 | assert_param(IS_FLASH_ADDRESS(Address)); |
bwang | 0:941e150e78b6 | 836 | |
bwang | 0:941e150e78b6 | 837 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 838 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 839 | |
bwang | 0:941e150e78b6 | 840 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 841 | { |
bwang | 0:941e150e78b6 | 842 | /* if the previous operation is completed, proceed to program the new data */ |
bwang | 0:941e150e78b6 | 843 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 844 | FLASH->CR |= FLASH_PSIZE_HALF_WORD; |
bwang | 0:941e150e78b6 | 845 | FLASH->CR |= FLASH_CR_PG; |
bwang | 0:941e150e78b6 | 846 | |
bwang | 0:941e150e78b6 | 847 | *(__IO uint16_t*)Address = Data; |
bwang | 0:941e150e78b6 | 848 | |
bwang | 0:941e150e78b6 | 849 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 850 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 851 | |
bwang | 0:941e150e78b6 | 852 | /* if the program operation is completed, disable the PG Bit */ |
bwang | 0:941e150e78b6 | 853 | FLASH->CR &= (~FLASH_CR_PG); |
bwang | 0:941e150e78b6 | 854 | } |
bwang | 0:941e150e78b6 | 855 | /* Return the Program Status */ |
bwang | 0:941e150e78b6 | 856 | return status; |
bwang | 0:941e150e78b6 | 857 | } |
bwang | 0:941e150e78b6 | 858 | |
bwang | 0:941e150e78b6 | 859 | /** |
bwang | 0:941e150e78b6 | 860 | * @brief Programs a byte (8-bit) at a specified address. |
bwang | 0:941e150e78b6 | 861 | * @note This function can be used within all the device supply voltage ranges. |
bwang | 0:941e150e78b6 | 862 | * |
bwang | 0:941e150e78b6 | 863 | * @note If an erase and a program operations are requested simultaneously, |
bwang | 0:941e150e78b6 | 864 | * the erase operation is performed before the program one. |
bwang | 0:941e150e78b6 | 865 | * |
bwang | 0:941e150e78b6 | 866 | * @param Address: specifies the address to be programmed. |
bwang | 0:941e150e78b6 | 867 | * This parameter can be any address in Program memory zone or in OTP zone. |
bwang | 0:941e150e78b6 | 868 | * @param Data: specifies the data to be programmed. |
bwang | 0:941e150e78b6 | 869 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 870 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 871 | */ |
bwang | 0:941e150e78b6 | 872 | FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data) |
bwang | 0:941e150e78b6 | 873 | { |
bwang | 0:941e150e78b6 | 874 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 875 | |
bwang | 0:941e150e78b6 | 876 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 877 | assert_param(IS_FLASH_ADDRESS(Address)); |
bwang | 0:941e150e78b6 | 878 | |
bwang | 0:941e150e78b6 | 879 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 880 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 881 | |
bwang | 0:941e150e78b6 | 882 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 883 | { |
bwang | 0:941e150e78b6 | 884 | /* if the previous operation is completed, proceed to program the new data */ |
bwang | 0:941e150e78b6 | 885 | FLASH->CR &= CR_PSIZE_MASK; |
bwang | 0:941e150e78b6 | 886 | FLASH->CR |= FLASH_PSIZE_BYTE; |
bwang | 0:941e150e78b6 | 887 | FLASH->CR |= FLASH_CR_PG; |
bwang | 0:941e150e78b6 | 888 | |
bwang | 0:941e150e78b6 | 889 | *(__IO uint8_t*)Address = Data; |
bwang | 0:941e150e78b6 | 890 | |
bwang | 0:941e150e78b6 | 891 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 892 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 893 | |
bwang | 0:941e150e78b6 | 894 | /* if the program operation is completed, disable the PG Bit */ |
bwang | 0:941e150e78b6 | 895 | FLASH->CR &= (~FLASH_CR_PG); |
bwang | 0:941e150e78b6 | 896 | } |
bwang | 0:941e150e78b6 | 897 | |
bwang | 0:941e150e78b6 | 898 | /* Return the Program Status */ |
bwang | 0:941e150e78b6 | 899 | return status; |
bwang | 0:941e150e78b6 | 900 | } |
bwang | 0:941e150e78b6 | 901 | |
bwang | 0:941e150e78b6 | 902 | /** |
bwang | 0:941e150e78b6 | 903 | * @} |
bwang | 0:941e150e78b6 | 904 | */ |
bwang | 0:941e150e78b6 | 905 | |
bwang | 0:941e150e78b6 | 906 | /** @defgroup FLASH_Group3 Option Bytes Programming functions |
bwang | 0:941e150e78b6 | 907 | * @brief Option Bytes Programming functions |
bwang | 0:941e150e78b6 | 908 | * |
bwang | 0:941e150e78b6 | 909 | @verbatim |
bwang | 0:941e150e78b6 | 910 | =============================================================================== |
bwang | 0:941e150e78b6 | 911 | ##### Option Bytes Programming functions ##### |
bwang | 0:941e150e78b6 | 912 | =============================================================================== |
bwang | 0:941e150e78b6 | 913 | [..] |
bwang | 0:941e150e78b6 | 914 | This group includes the following functions: |
bwang | 0:941e150e78b6 | 915 | (+) void FLASH_OB_Unlock(void) |
bwang | 0:941e150e78b6 | 916 | (+) void FLASH_OB_Lock(void) |
bwang | 0:941e150e78b6 | 917 | (+) void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 918 | (+) void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 919 | (+) void FLASH_OB_PCROPSelectionConfig(uint8_t OB_PCROPSelect) |
bwang | 0:941e150e78b6 | 920 | (+) void FLASH_OB_PCROPConfig(uint32_t OB_PCROP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 921 | (+) void FLASH_OB_PCROP1Config(uint32_t OB_PCROP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 922 | (+) void FLASH_OB_RDPConfig(uint8_t OB_RDP) |
bwang | 0:941e150e78b6 | 923 | (+) void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) |
bwang | 0:941e150e78b6 | 924 | (+) void FLASH_OB_BORConfig(uint8_t OB_BOR) |
bwang | 0:941e150e78b6 | 925 | (+) FLASH_Status FLASH_ProgramOTP(uint32_t Address, uint32_t Data) |
bwang | 0:941e150e78b6 | 926 | (+) FLASH_Status FLASH_OB_Launch(void) |
bwang | 0:941e150e78b6 | 927 | (+) uint32_t FLASH_OB_GetUser(void) |
bwang | 0:941e150e78b6 | 928 | (+) uint8_t FLASH_OB_GetWRP(void) |
bwang | 0:941e150e78b6 | 929 | (+) uint8_t FLASH_OB_GetWRP1(void) |
bwang | 0:941e150e78b6 | 930 | (+) uint8_t FLASH_OB_GetPCROP(void) |
bwang | 0:941e150e78b6 | 931 | (+) uint8_t FLASH_OB_GetPCROP1(void) |
bwang | 0:941e150e78b6 | 932 | (+) uint8_t FLASH_OB_GetRDP(void) |
bwang | 0:941e150e78b6 | 933 | (+) uint8_t FLASH_OB_GetBOR(void) |
bwang | 0:941e150e78b6 | 934 | [..] |
bwang | 0:941e150e78b6 | 935 | The following function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 936 | (+) void FLASH_OB_BootConfig(uint8_t OB_BOOT) |
bwang | 0:941e150e78b6 | 937 | [..] |
bwang | 0:941e150e78b6 | 938 | Any operation of erase or program should follow these steps: |
bwang | 0:941e150e78b6 | 939 | (#) Call the FLASH_OB_Unlock() function to enable the FLASH option control |
bwang | 0:941e150e78b6 | 940 | register access |
bwang | 0:941e150e78b6 | 941 | |
bwang | 0:941e150e78b6 | 942 | (#) Call one or several functions to program the desired Option Bytes: |
bwang | 0:941e150e78b6 | 943 | (++) void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 944 | => to Enable/Disable the desired sector write protection |
bwang | 0:941e150e78b6 | 945 | (++) void FLASH_OB_RDPConfig(uint8_t OB_RDP) => to set the desired read |
bwang | 0:941e150e78b6 | 946 | Protection Level |
bwang | 0:941e150e78b6 | 947 | (++) void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) |
bwang | 0:941e150e78b6 | 948 | => to configure the user Option Bytes. |
bwang | 0:941e150e78b6 | 949 | (++) void FLASH_OB_BORConfig(uint8_t OB_BOR) => to set the BOR Level |
bwang | 0:941e150e78b6 | 950 | |
bwang | 0:941e150e78b6 | 951 | (#) Once all needed Option Bytes to be programmed are correctly written, |
bwang | 0:941e150e78b6 | 952 | call the FLASH_OB_Launch() function to launch the Option Bytes |
bwang | 0:941e150e78b6 | 953 | programming process. |
bwang | 0:941e150e78b6 | 954 | |
bwang | 0:941e150e78b6 | 955 | -@- When changing the IWDG mode from HW to SW or from SW to HW, a system |
bwang | 0:941e150e78b6 | 956 | reset is needed to make the change effective. |
bwang | 0:941e150e78b6 | 957 | |
bwang | 0:941e150e78b6 | 958 | (#) Call the FLASH_OB_Lock() function to disable the FLASH option control |
bwang | 0:941e150e78b6 | 959 | register access (recommended to protect the Option Bytes against |
bwang | 0:941e150e78b6 | 960 | possible unwanted operations) |
bwang | 0:941e150e78b6 | 961 | |
bwang | 0:941e150e78b6 | 962 | @endverbatim |
bwang | 0:941e150e78b6 | 963 | * @{ |
bwang | 0:941e150e78b6 | 964 | */ |
bwang | 0:941e150e78b6 | 965 | |
bwang | 0:941e150e78b6 | 966 | /** |
bwang | 0:941e150e78b6 | 967 | * @brief Unlocks the FLASH Option Control Registers access. |
bwang | 0:941e150e78b6 | 968 | * @param None |
bwang | 0:941e150e78b6 | 969 | * @retval None |
bwang | 0:941e150e78b6 | 970 | */ |
bwang | 0:941e150e78b6 | 971 | void FLASH_OB_Unlock(void) |
bwang | 0:941e150e78b6 | 972 | { |
bwang | 0:941e150e78b6 | 973 | if((FLASH->OPTCR & FLASH_OPTCR_OPTLOCK) != RESET) |
bwang | 0:941e150e78b6 | 974 | { |
bwang | 0:941e150e78b6 | 975 | /* Authorizes the Option Byte register programming */ |
bwang | 0:941e150e78b6 | 976 | FLASH->OPTKEYR = FLASH_OPT_KEY1; |
bwang | 0:941e150e78b6 | 977 | FLASH->OPTKEYR = FLASH_OPT_KEY2; |
bwang | 0:941e150e78b6 | 978 | } |
bwang | 0:941e150e78b6 | 979 | } |
bwang | 0:941e150e78b6 | 980 | |
bwang | 0:941e150e78b6 | 981 | /** |
bwang | 0:941e150e78b6 | 982 | * @brief Locks the FLASH Option Control Registers access. |
bwang | 0:941e150e78b6 | 983 | * @param None |
bwang | 0:941e150e78b6 | 984 | * @retval None |
bwang | 0:941e150e78b6 | 985 | */ |
bwang | 0:941e150e78b6 | 986 | void FLASH_OB_Lock(void) |
bwang | 0:941e150e78b6 | 987 | { |
bwang | 0:941e150e78b6 | 988 | /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */ |
bwang | 0:941e150e78b6 | 989 | FLASH->OPTCR |= FLASH_OPTCR_OPTLOCK; |
bwang | 0:941e150e78b6 | 990 | } |
bwang | 0:941e150e78b6 | 991 | |
bwang | 0:941e150e78b6 | 992 | /** |
bwang | 0:941e150e78b6 | 993 | * @brief Enables or disables the write protection of the desired sectors, for the first |
bwang | 0:941e150e78b6 | 994 | * 1 Mb of the Flash |
bwang | 0:941e150e78b6 | 995 | * |
bwang | 0:941e150e78b6 | 996 | * @note When the memory read protection level is selected (RDP level = 1), |
bwang | 0:941e150e78b6 | 997 | * it is not possible to program or erase the flash sector i if CortexM4 |
bwang | 0:941e150e78b6 | 998 | * debug features are connected or boot code is executed in RAM, even if nWRPi = 1 |
bwang | 0:941e150e78b6 | 999 | * @note Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1). |
bwang | 0:941e150e78b6 | 1000 | * |
bwang | 0:941e150e78b6 | 1001 | * @param OB_WRP: specifies the sector(s) to be write protected or unprotected. |
bwang | 0:941e150e78b6 | 1002 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1003 | * @arg OB_WRP: A value between OB_WRP_Sector0 and OB_WRP_Sector11 |
bwang | 0:941e150e78b6 | 1004 | * @arg OB_WRP_Sector_All |
bwang | 0:941e150e78b6 | 1005 | * @param Newstate: new state of the Write Protection. |
bwang | 0:941e150e78b6 | 1006 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 1007 | * @retval None |
bwang | 0:941e150e78b6 | 1008 | */ |
bwang | 0:941e150e78b6 | 1009 | void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 1010 | { |
bwang | 0:941e150e78b6 | 1011 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1012 | |
bwang | 0:941e150e78b6 | 1013 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1014 | assert_param(IS_OB_WRP(OB_WRP)); |
bwang | 0:941e150e78b6 | 1015 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 1016 | |
bwang | 0:941e150e78b6 | 1017 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1018 | |
bwang | 0:941e150e78b6 | 1019 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 1020 | { |
bwang | 0:941e150e78b6 | 1021 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 1022 | { |
bwang | 0:941e150e78b6 | 1023 | *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS &= (~OB_WRP); |
bwang | 0:941e150e78b6 | 1024 | } |
bwang | 0:941e150e78b6 | 1025 | else |
bwang | 0:941e150e78b6 | 1026 | { |
bwang | 0:941e150e78b6 | 1027 | *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS |= (uint16_t)OB_WRP; |
bwang | 0:941e150e78b6 | 1028 | } |
bwang | 0:941e150e78b6 | 1029 | } |
bwang | 0:941e150e78b6 | 1030 | } |
bwang | 0:941e150e78b6 | 1031 | |
bwang | 0:941e150e78b6 | 1032 | /** |
bwang | 0:941e150e78b6 | 1033 | * @brief Enables or disables the write protection of the desired sectors, for the second |
bwang | 0:941e150e78b6 | 1034 | * 1 Mb of the Flash |
bwang | 0:941e150e78b6 | 1035 | * |
bwang | 0:941e150e78b6 | 1036 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 1037 | * |
bwang | 0:941e150e78b6 | 1038 | * @note When the memory read out protection is selected (RDP level = 1), |
bwang | 0:941e150e78b6 | 1039 | * it is not possible to program or erase the flash sector i if CortexM4 |
bwang | 0:941e150e78b6 | 1040 | * debug features are connected or boot code is executed in RAM, even if nWRPi = 1 |
bwang | 0:941e150e78b6 | 1041 | * @note Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1). |
bwang | 0:941e150e78b6 | 1042 | * |
bwang | 0:941e150e78b6 | 1043 | * @param OB_WRP: specifies the sector(s) to be write protected or unprotected. |
bwang | 0:941e150e78b6 | 1044 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1045 | * @arg OB_WRP: A value between OB_WRP_Sector12 and OB_WRP_Sector23 |
bwang | 0:941e150e78b6 | 1046 | * @arg OB_WRP_Sector_All |
bwang | 0:941e150e78b6 | 1047 | * @param Newstate: new state of the Write Protection. |
bwang | 0:941e150e78b6 | 1048 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 1049 | * @retval None |
bwang | 0:941e150e78b6 | 1050 | */ |
bwang | 0:941e150e78b6 | 1051 | void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 1052 | { |
bwang | 0:941e150e78b6 | 1053 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1054 | |
bwang | 0:941e150e78b6 | 1055 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1056 | assert_param(IS_OB_WRP(OB_WRP)); |
bwang | 0:941e150e78b6 | 1057 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 1058 | |
bwang | 0:941e150e78b6 | 1059 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1060 | |
bwang | 0:941e150e78b6 | 1061 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 1062 | { |
bwang | 0:941e150e78b6 | 1063 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 1064 | { |
bwang | 0:941e150e78b6 | 1065 | *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~OB_WRP); |
bwang | 0:941e150e78b6 | 1066 | } |
bwang | 0:941e150e78b6 | 1067 | else |
bwang | 0:941e150e78b6 | 1068 | { |
bwang | 0:941e150e78b6 | 1069 | *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)OB_WRP; |
bwang | 0:941e150e78b6 | 1070 | } |
bwang | 0:941e150e78b6 | 1071 | } |
bwang | 0:941e150e78b6 | 1072 | } |
bwang | 0:941e150e78b6 | 1073 | |
bwang | 0:941e150e78b6 | 1074 | /** |
bwang | 0:941e150e78b6 | 1075 | * @brief Select the Protection Mode (SPRMOD). |
bwang | 0:941e150e78b6 | 1076 | * |
bwang | 0:941e150e78b6 | 1077 | * @note This function can be used only for STM32F42xxx/43xxx and STM32F401xx/411xE devices. |
bwang | 0:941e150e78b6 | 1078 | * |
bwang | 0:941e150e78b6 | 1079 | * @note After PCROP activation, Option Byte modification is not possible. |
bwang | 0:941e150e78b6 | 1080 | * Exception made for the global Read Out Protection modification level (level1 to level0) |
bwang | 0:941e150e78b6 | 1081 | * @note Once SPRMOD bit is active unprotection of a protected sector is not possible |
bwang | 0:941e150e78b6 | 1082 | * |
bwang | 0:941e150e78b6 | 1083 | * @note Read a protected sector will set RDERR Flag and write a protected sector will set WRPERR Flag |
bwang | 0:941e150e78b6 | 1084 | * |
bwang | 0:941e150e78b6 | 1085 | * @note Some Precautions should be taken when activating the PCROP feature : |
bwang | 0:941e150e78b6 | 1086 | * The active value of nWRPi bits is inverted when PCROP mode is active, this means if SPRMOD = 1 |
bwang | 0:941e150e78b6 | 1087 | * and WRPi = 1 (default value), then the user sector i is read/write protected. |
bwang | 0:941e150e78b6 | 1088 | * In order to avoid activation of PCROP Mode for undesired sectors, please follow the |
bwang | 0:941e150e78b6 | 1089 | * below safety sequence : |
bwang | 0:941e150e78b6 | 1090 | * - Disable PCROP for all Sectors using FLASH_OB_PCROPConfig(OB_PCROP_Sector_All, DISABLE) function |
bwang | 0:941e150e78b6 | 1091 | * for Bank1 or FLASH_OB_PCROP1Config(OB_PCROP_Sector_All, DISABLE) function for Bank2 |
bwang | 0:941e150e78b6 | 1092 | * - Enable PCROP for the desired Sector i using FLASH_OB_PCROPConfig(Sector i, ENABLE) function |
bwang | 0:941e150e78b6 | 1093 | * - Activate the PCROP Mode FLASH_OB_PCROPSelectionConfig() function. |
bwang | 0:941e150e78b6 | 1094 | * |
bwang | 0:941e150e78b6 | 1095 | * @param OB_PCROP: Select the Protection Mode of nWPRi bits |
bwang | 0:941e150e78b6 | 1096 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1097 | * @arg OB_PcROP_Disable: nWRPi control the write protection of respective user sectors. |
bwang | 0:941e150e78b6 | 1098 | * @arg OB_PcROP_Enable: nWRPi control the read&write protection (PCROP) of respective user sectors. |
bwang | 0:941e150e78b6 | 1099 | * @retval None |
bwang | 0:941e150e78b6 | 1100 | */ |
bwang | 0:941e150e78b6 | 1101 | void FLASH_OB_PCROPSelectionConfig(uint8_t OB_PcROP) |
bwang | 0:941e150e78b6 | 1102 | { |
bwang | 0:941e150e78b6 | 1103 | uint8_t optiontmp = 0xFF; |
bwang | 0:941e150e78b6 | 1104 | |
bwang | 0:941e150e78b6 | 1105 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1106 | assert_param(IS_OB_PCROP_SELECT(OB_PcROP)); |
bwang | 0:941e150e78b6 | 1107 | |
bwang | 0:941e150e78b6 | 1108 | /* Mask SPRMOD bit */ |
bwang | 0:941e150e78b6 | 1109 | optiontmp = (uint8_t)((*(__IO uint8_t *)OPTCR_BYTE3_ADDRESS) & (uint8_t)0x7F); |
bwang | 0:941e150e78b6 | 1110 | /* Update Option Byte */ |
bwang | 0:941e150e78b6 | 1111 | *(__IO uint8_t *)OPTCR_BYTE3_ADDRESS = (uint8_t)(OB_PcROP | optiontmp); |
bwang | 0:941e150e78b6 | 1112 | |
bwang | 0:941e150e78b6 | 1113 | } |
bwang | 0:941e150e78b6 | 1114 | |
bwang | 0:941e150e78b6 | 1115 | /** |
bwang | 0:941e150e78b6 | 1116 | * @brief Enables or disables the read/write protection (PCROP) of the desired |
bwang | 0:941e150e78b6 | 1117 | * sectors, for the first 1 MB of the Flash. |
bwang | 0:941e150e78b6 | 1118 | * |
bwang | 0:941e150e78b6 | 1119 | * @note This function can be used only for STM32F42xxx/43xxx , STM32F401xx/411xE |
bwang | 0:941e150e78b6 | 1120 | * and STM32F412xG devices. |
bwang | 0:941e150e78b6 | 1121 | * |
bwang | 0:941e150e78b6 | 1122 | * @param OB_PCROP: specifies the sector(s) to be read/write protected or unprotected. |
bwang | 0:941e150e78b6 | 1123 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1124 | * @arg OB_PCROP: A value between OB_PCROP_Sector0 and OB_PCROP_Sector11 for |
bwang | 0:941e150e78b6 | 1125 | * STM32F42xxx/43xxx devices and between OB_PCROP_Sector0 and |
bwang | 0:941e150e78b6 | 1126 | * OB_PCROP_Sector5 for STM32F401xx/411xE devices. |
bwang | 0:941e150e78b6 | 1127 | * @arg OB_PCROP_Sector_All |
bwang | 0:941e150e78b6 | 1128 | * @param Newstate: new state of the Write Protection. |
bwang | 0:941e150e78b6 | 1129 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 1130 | * @retval None |
bwang | 0:941e150e78b6 | 1131 | */ |
bwang | 0:941e150e78b6 | 1132 | void FLASH_OB_PCROPConfig(uint32_t OB_PCROP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 1133 | { |
bwang | 0:941e150e78b6 | 1134 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1135 | |
bwang | 0:941e150e78b6 | 1136 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1137 | assert_param(IS_OB_PCROP(OB_PCROP)); |
bwang | 0:941e150e78b6 | 1138 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 1139 | |
bwang | 0:941e150e78b6 | 1140 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1141 | |
bwang | 0:941e150e78b6 | 1142 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 1143 | { |
bwang | 0:941e150e78b6 | 1144 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 1145 | { |
bwang | 0:941e150e78b6 | 1146 | *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS |= (uint16_t)OB_PCROP; |
bwang | 0:941e150e78b6 | 1147 | } |
bwang | 0:941e150e78b6 | 1148 | else |
bwang | 0:941e150e78b6 | 1149 | { |
bwang | 0:941e150e78b6 | 1150 | *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS &= (~OB_PCROP); |
bwang | 0:941e150e78b6 | 1151 | } |
bwang | 0:941e150e78b6 | 1152 | } |
bwang | 0:941e150e78b6 | 1153 | } |
bwang | 0:941e150e78b6 | 1154 | |
bwang | 0:941e150e78b6 | 1155 | /** |
bwang | 0:941e150e78b6 | 1156 | * @brief Enables or disables the read/write protection (PCROP) of the desired |
bwang | 0:941e150e78b6 | 1157 | * sectors |
bwang | 0:941e150e78b6 | 1158 | * |
bwang | 0:941e150e78b6 | 1159 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 1160 | * |
bwang | 0:941e150e78b6 | 1161 | * @param OB_PCROP: specifies the sector(s) to be read/write protected or unprotected. |
bwang | 0:941e150e78b6 | 1162 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1163 | * @arg OB_PCROP: A value between OB_PCROP_Sector12 and OB_PCROP_Sector23 |
bwang | 0:941e150e78b6 | 1164 | * @arg OB_PCROP_Sector_All |
bwang | 0:941e150e78b6 | 1165 | * @param Newstate: new state of the Write Protection. |
bwang | 0:941e150e78b6 | 1166 | * This parameter can be: ENABLE or DISABLE. |
bwang | 0:941e150e78b6 | 1167 | * @retval None |
bwang | 0:941e150e78b6 | 1168 | */ |
bwang | 0:941e150e78b6 | 1169 | void FLASH_OB_PCROP1Config(uint32_t OB_PCROP, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 1170 | { |
bwang | 0:941e150e78b6 | 1171 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1172 | |
bwang | 0:941e150e78b6 | 1173 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1174 | assert_param(IS_OB_PCROP(OB_PCROP)); |
bwang | 0:941e150e78b6 | 1175 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 1176 | |
bwang | 0:941e150e78b6 | 1177 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1178 | |
bwang | 0:941e150e78b6 | 1179 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 1180 | { |
bwang | 0:941e150e78b6 | 1181 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 1182 | { |
bwang | 0:941e150e78b6 | 1183 | *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)OB_PCROP; |
bwang | 0:941e150e78b6 | 1184 | } |
bwang | 0:941e150e78b6 | 1185 | else |
bwang | 0:941e150e78b6 | 1186 | { |
bwang | 0:941e150e78b6 | 1187 | *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~OB_PCROP); |
bwang | 0:941e150e78b6 | 1188 | } |
bwang | 0:941e150e78b6 | 1189 | } |
bwang | 0:941e150e78b6 | 1190 | } |
bwang | 0:941e150e78b6 | 1191 | |
bwang | 0:941e150e78b6 | 1192 | |
bwang | 0:941e150e78b6 | 1193 | /** |
bwang | 0:941e150e78b6 | 1194 | * @brief Sets the read protection level. |
bwang | 0:941e150e78b6 | 1195 | * @param OB_RDP: specifies the read protection level. |
bwang | 0:941e150e78b6 | 1196 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1197 | * @arg OB_RDP_Level_0: No protection |
bwang | 0:941e150e78b6 | 1198 | * @arg OB_RDP_Level_1: Read protection of the memory |
bwang | 0:941e150e78b6 | 1199 | * @arg OB_RDP_Level_2: Full chip protection |
bwang | 0:941e150e78b6 | 1200 | * |
bwang | 0:941e150e78b6 | 1201 | * /!\ Warning /!\ When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0 |
bwang | 0:941e150e78b6 | 1202 | * |
bwang | 0:941e150e78b6 | 1203 | * @retval None |
bwang | 0:941e150e78b6 | 1204 | */ |
bwang | 0:941e150e78b6 | 1205 | void FLASH_OB_RDPConfig(uint8_t OB_RDP) |
bwang | 0:941e150e78b6 | 1206 | { |
bwang | 0:941e150e78b6 | 1207 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1208 | |
bwang | 0:941e150e78b6 | 1209 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1210 | assert_param(IS_OB_RDP(OB_RDP)); |
bwang | 0:941e150e78b6 | 1211 | |
bwang | 0:941e150e78b6 | 1212 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1213 | |
bwang | 0:941e150e78b6 | 1214 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 1215 | { |
bwang | 0:941e150e78b6 | 1216 | *(__IO uint8_t*)OPTCR_BYTE1_ADDRESS = OB_RDP; |
bwang | 0:941e150e78b6 | 1217 | |
bwang | 0:941e150e78b6 | 1218 | } |
bwang | 0:941e150e78b6 | 1219 | } |
bwang | 0:941e150e78b6 | 1220 | |
bwang | 0:941e150e78b6 | 1221 | /** |
bwang | 0:941e150e78b6 | 1222 | * @brief Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. |
bwang | 0:941e150e78b6 | 1223 | * @param OB_IWDG: Selects the IWDG mode |
bwang | 0:941e150e78b6 | 1224 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1225 | * @arg OB_IWDG_SW: Software IWDG selected |
bwang | 0:941e150e78b6 | 1226 | * @arg OB_IWDG_HW: Hardware IWDG selected |
bwang | 0:941e150e78b6 | 1227 | * @param OB_STOP: Reset event when entering STOP mode. |
bwang | 0:941e150e78b6 | 1228 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1229 | * @arg OB_STOP_NoRST: No reset generated when entering in STOP |
bwang | 0:941e150e78b6 | 1230 | * @arg OB_STOP_RST: Reset generated when entering in STOP |
bwang | 0:941e150e78b6 | 1231 | * @param OB_STDBY: Reset event when entering Standby mode. |
bwang | 0:941e150e78b6 | 1232 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1233 | * @arg OB_STDBY_NoRST: No reset generated when entering in STANDBY |
bwang | 0:941e150e78b6 | 1234 | * @arg OB_STDBY_RST: Reset generated when entering in STANDBY |
bwang | 0:941e150e78b6 | 1235 | * @retval None |
bwang | 0:941e150e78b6 | 1236 | */ |
bwang | 0:941e150e78b6 | 1237 | void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY) |
bwang | 0:941e150e78b6 | 1238 | { |
bwang | 0:941e150e78b6 | 1239 | uint8_t optiontmp = 0xFF; |
bwang | 0:941e150e78b6 | 1240 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1241 | |
bwang | 0:941e150e78b6 | 1242 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1243 | assert_param(IS_OB_IWDG_SOURCE(OB_IWDG)); |
bwang | 0:941e150e78b6 | 1244 | assert_param(IS_OB_STOP_SOURCE(OB_STOP)); |
bwang | 0:941e150e78b6 | 1245 | assert_param(IS_OB_STDBY_SOURCE(OB_STDBY)); |
bwang | 0:941e150e78b6 | 1246 | |
bwang | 0:941e150e78b6 | 1247 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 1248 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1249 | |
bwang | 0:941e150e78b6 | 1250 | if(status == FLASH_COMPLETE2) |
bwang | 0:941e150e78b6 | 1251 | { |
bwang | 0:941e150e78b6 | 1252 | #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx) |
bwang | 0:941e150e78b6 | 1253 | /* Mask OPTLOCK, OPTSTRT, BOR_LEV and BFB2 bits */ |
bwang | 0:941e150e78b6 | 1254 | optiontmp = (uint8_t)((*(__IO uint8_t *)OPTCR_BYTE0_ADDRESS) & (uint8_t)0x1F); |
bwang | 0:941e150e78b6 | 1255 | #endif /* STM32F427_437xx || STM32F429_439xx || STM32F469_479xx */ |
bwang | 0:941e150e78b6 | 1256 | |
bwang | 0:941e150e78b6 | 1257 | #if defined(STM32F40_41xxx) || defined(STM32F401xx) || defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F446xx) |
bwang | 0:941e150e78b6 | 1258 | /* Mask OPTLOCK, OPTSTRT and BOR_LEV bits */ |
bwang | 0:941e150e78b6 | 1259 | optiontmp = (uint8_t)((*(__IO uint8_t *)OPTCR_BYTE0_ADDRESS) & (uint8_t)0x0F); |
bwang | 0:941e150e78b6 | 1260 | #endif /* STM32F40_41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx */ |
bwang | 0:941e150e78b6 | 1261 | |
bwang | 0:941e150e78b6 | 1262 | /* Update User Option Byte */ |
bwang | 0:941e150e78b6 | 1263 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS = OB_IWDG | (uint8_t)(OB_STDBY | (uint8_t)(OB_STOP | ((uint8_t)optiontmp))); |
bwang | 0:941e150e78b6 | 1264 | } |
bwang | 0:941e150e78b6 | 1265 | } |
bwang | 0:941e150e78b6 | 1266 | |
bwang | 0:941e150e78b6 | 1267 | /** |
bwang | 0:941e150e78b6 | 1268 | * @brief Configure the Dual Bank Boot. |
bwang | 0:941e150e78b6 | 1269 | * |
bwang | 0:941e150e78b6 | 1270 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 1271 | * |
bwang | 0:941e150e78b6 | 1272 | * @param OB_BOOT: specifies the Dual Bank Boot Option byte. |
bwang | 0:941e150e78b6 | 1273 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1274 | * @arg OB_Dual_BootEnabled: Dual Bank Boot Enable |
bwang | 0:941e150e78b6 | 1275 | * @arg OB_Dual_BootDisabled: Dual Bank Boot Disabled |
bwang | 0:941e150e78b6 | 1276 | * @retval None |
bwang | 0:941e150e78b6 | 1277 | */ |
bwang | 0:941e150e78b6 | 1278 | void FLASH_OB_BootConfig(uint8_t OB_BOOT) |
bwang | 0:941e150e78b6 | 1279 | { |
bwang | 0:941e150e78b6 | 1280 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1281 | assert_param(IS_OB_BOOT(OB_BOOT)); |
bwang | 0:941e150e78b6 | 1282 | |
bwang | 0:941e150e78b6 | 1283 | /* Set Dual Bank Boot */ |
bwang | 0:941e150e78b6 | 1284 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS &= (~FLASH_OPTCR_BFB2); |
bwang | 0:941e150e78b6 | 1285 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= OB_BOOT; |
bwang | 0:941e150e78b6 | 1286 | |
bwang | 0:941e150e78b6 | 1287 | } |
bwang | 0:941e150e78b6 | 1288 | |
bwang | 0:941e150e78b6 | 1289 | /** |
bwang | 0:941e150e78b6 | 1290 | * @brief Sets the BOR Level. |
bwang | 0:941e150e78b6 | 1291 | * @param OB_BOR: specifies the Option Bytes BOR Reset Level. |
bwang | 0:941e150e78b6 | 1292 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1293 | * @arg OB_BOR_LEVEL3: Supply voltage ranges from 2.7 to 3.6 V |
bwang | 0:941e150e78b6 | 1294 | * @arg OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V |
bwang | 0:941e150e78b6 | 1295 | * @arg OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V |
bwang | 0:941e150e78b6 | 1296 | * @arg OB_BOR_OFF: Supply voltage ranges from 1.62 to 2.1 V |
bwang | 0:941e150e78b6 | 1297 | * @retval None |
bwang | 0:941e150e78b6 | 1298 | */ |
bwang | 0:941e150e78b6 | 1299 | void FLASH_OB_BORConfig(uint8_t OB_BOR) |
bwang | 0:941e150e78b6 | 1300 | { |
bwang | 0:941e150e78b6 | 1301 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1302 | assert_param(IS_OB_BOR(OB_BOR)); |
bwang | 0:941e150e78b6 | 1303 | |
bwang | 0:941e150e78b6 | 1304 | /* Set the BOR Level */ |
bwang | 0:941e150e78b6 | 1305 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS &= (~FLASH_OPTCR_BOR_LEV); |
bwang | 0:941e150e78b6 | 1306 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= OB_BOR; |
bwang | 0:941e150e78b6 | 1307 | |
bwang | 0:941e150e78b6 | 1308 | } |
bwang | 0:941e150e78b6 | 1309 | |
bwang | 0:941e150e78b6 | 1310 | /** |
bwang | 0:941e150e78b6 | 1311 | * @brief Launch the option byte loading. |
bwang | 0:941e150e78b6 | 1312 | * @param None |
bwang | 0:941e150e78b6 | 1313 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 1314 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 1315 | */ |
bwang | 0:941e150e78b6 | 1316 | FLASH_Status FLASH_OB_Launch(void) |
bwang | 0:941e150e78b6 | 1317 | { |
bwang | 0:941e150e78b6 | 1318 | FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1319 | |
bwang | 0:941e150e78b6 | 1320 | /* Set the OPTSTRT bit in OPTCR register */ |
bwang | 0:941e150e78b6 | 1321 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= FLASH_OPTCR_OPTSTRT; |
bwang | 0:941e150e78b6 | 1322 | |
bwang | 0:941e150e78b6 | 1323 | /* Wait for last operation to be completed */ |
bwang | 0:941e150e78b6 | 1324 | status = FLASH_WaitForLastOperation2(); |
bwang | 0:941e150e78b6 | 1325 | |
bwang | 0:941e150e78b6 | 1326 | return status; |
bwang | 0:941e150e78b6 | 1327 | } |
bwang | 0:941e150e78b6 | 1328 | |
bwang | 0:941e150e78b6 | 1329 | /** |
bwang | 0:941e150e78b6 | 1330 | * @brief Returns the FLASH User Option Bytes values. |
bwang | 0:941e150e78b6 | 1331 | * @param None |
bwang | 0:941e150e78b6 | 1332 | * @retval The FLASH User Option Bytes values: IWDG_SW(Bit0), RST_STOP(Bit1) |
bwang | 0:941e150e78b6 | 1333 | * and RST_STDBY(Bit2). |
bwang | 0:941e150e78b6 | 1334 | */ |
bwang | 0:941e150e78b6 | 1335 | uint8_t FLASH_OB_GetUser(void) |
bwang | 0:941e150e78b6 | 1336 | { |
bwang | 0:941e150e78b6 | 1337 | /* Return the User Option Byte */ |
bwang | 0:941e150e78b6 | 1338 | return (uint8_t)(FLASH->OPTCR >> 5); |
bwang | 0:941e150e78b6 | 1339 | } |
bwang | 0:941e150e78b6 | 1340 | |
bwang | 0:941e150e78b6 | 1341 | /** |
bwang | 0:941e150e78b6 | 1342 | * @brief Returns the FLASH Write Protection Option Bytes value. |
bwang | 0:941e150e78b6 | 1343 | * @param None |
bwang | 0:941e150e78b6 | 1344 | * @retval The FLASH Write Protection Option Bytes value |
bwang | 0:941e150e78b6 | 1345 | */ |
bwang | 0:941e150e78b6 | 1346 | uint16_t FLASH_OB_GetWRP(void) |
bwang | 0:941e150e78b6 | 1347 | { |
bwang | 0:941e150e78b6 | 1348 | /* Return the FLASH write protection Register value */ |
bwang | 0:941e150e78b6 | 1349 | return (*(__IO uint16_t *)(OPTCR_BYTE2_ADDRESS)); |
bwang | 0:941e150e78b6 | 1350 | } |
bwang | 0:941e150e78b6 | 1351 | |
bwang | 0:941e150e78b6 | 1352 | /** |
bwang | 0:941e150e78b6 | 1353 | * @brief Returns the FLASH Write Protection Option Bytes value. |
bwang | 0:941e150e78b6 | 1354 | * |
bwang | 0:941e150e78b6 | 1355 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 1356 | * |
bwang | 0:941e150e78b6 | 1357 | * @param None |
bwang | 0:941e150e78b6 | 1358 | * @retval The FLASH Write Protection Option Bytes value |
bwang | 0:941e150e78b6 | 1359 | */ |
bwang | 0:941e150e78b6 | 1360 | uint16_t FLASH_OB_GetWRP1(void) |
bwang | 0:941e150e78b6 | 1361 | { |
bwang | 0:941e150e78b6 | 1362 | /* Return the FLASH write protection Register value */ |
bwang | 0:941e150e78b6 | 1363 | return (*(__IO uint16_t *)(OPTCR1_BYTE2_ADDRESS)); |
bwang | 0:941e150e78b6 | 1364 | } |
bwang | 0:941e150e78b6 | 1365 | |
bwang | 0:941e150e78b6 | 1366 | /** |
bwang | 0:941e150e78b6 | 1367 | * @brief Returns the FLASH PC Read/Write Protection Option Bytes value. |
bwang | 0:941e150e78b6 | 1368 | * |
bwang | 0:941e150e78b6 | 1369 | * @note This function can be used only for STM32F42xxx/43xxx devices and STM32F401xx/411xE devices. |
bwang | 0:941e150e78b6 | 1370 | * |
bwang | 0:941e150e78b6 | 1371 | * @param None |
bwang | 0:941e150e78b6 | 1372 | * @retval The FLASH PC Read/Write Protection Option Bytes value |
bwang | 0:941e150e78b6 | 1373 | */ |
bwang | 0:941e150e78b6 | 1374 | uint16_t FLASH_OB_GetPCROP(void) |
bwang | 0:941e150e78b6 | 1375 | { |
bwang | 0:941e150e78b6 | 1376 | /* Return the FLASH PC Read/write protection Register value */ |
bwang | 0:941e150e78b6 | 1377 | return (*(__IO uint16_t *)(OPTCR_BYTE2_ADDRESS)); |
bwang | 0:941e150e78b6 | 1378 | } |
bwang | 0:941e150e78b6 | 1379 | |
bwang | 0:941e150e78b6 | 1380 | /** |
bwang | 0:941e150e78b6 | 1381 | * @brief Returns the FLASH PC Read/Write Protection Option Bytes value. |
bwang | 0:941e150e78b6 | 1382 | * |
bwang | 0:941e150e78b6 | 1383 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
bwang | 0:941e150e78b6 | 1384 | * |
bwang | 0:941e150e78b6 | 1385 | * @param None |
bwang | 0:941e150e78b6 | 1386 | * @retval The FLASH PC Read/Write Protection Option Bytes value |
bwang | 0:941e150e78b6 | 1387 | */ |
bwang | 0:941e150e78b6 | 1388 | uint16_t FLASH_OB_GetPCROP1(void) |
bwang | 0:941e150e78b6 | 1389 | { |
bwang | 0:941e150e78b6 | 1390 | /* Return the FLASH write protection Register value */ |
bwang | 0:941e150e78b6 | 1391 | return (*(__IO uint16_t *)(OPTCR1_BYTE2_ADDRESS)); |
bwang | 0:941e150e78b6 | 1392 | } |
bwang | 0:941e150e78b6 | 1393 | |
bwang | 0:941e150e78b6 | 1394 | /** |
bwang | 0:941e150e78b6 | 1395 | * @brief Returns the FLASH Read Protection level. |
bwang | 0:941e150e78b6 | 1396 | * @param None |
bwang | 0:941e150e78b6 | 1397 | * @retval FLASH ReadOut Protection Status: |
bwang | 0:941e150e78b6 | 1398 | * - SET, when OB_RDP_Level_1 or OB_RDP_Level_2 is set |
bwang | 0:941e150e78b6 | 1399 | * - RESET, when OB_RDP_Level_0 is set |
bwang | 0:941e150e78b6 | 1400 | */ |
bwang | 0:941e150e78b6 | 1401 | FlagStatus FLASH_OB_GetRDP(void) |
bwang | 0:941e150e78b6 | 1402 | { |
bwang | 0:941e150e78b6 | 1403 | FlagStatus readstatus = RESET; |
bwang | 0:941e150e78b6 | 1404 | |
bwang | 0:941e150e78b6 | 1405 | if ((*(__IO uint8_t*)(OPTCR_BYTE1_ADDRESS) != (uint8_t)OB_RDP_Level_0)) |
bwang | 0:941e150e78b6 | 1406 | { |
bwang | 0:941e150e78b6 | 1407 | readstatus = SET; |
bwang | 0:941e150e78b6 | 1408 | } |
bwang | 0:941e150e78b6 | 1409 | else |
bwang | 0:941e150e78b6 | 1410 | { |
bwang | 0:941e150e78b6 | 1411 | readstatus = RESET; |
bwang | 0:941e150e78b6 | 1412 | } |
bwang | 0:941e150e78b6 | 1413 | return readstatus; |
bwang | 0:941e150e78b6 | 1414 | } |
bwang | 0:941e150e78b6 | 1415 | |
bwang | 0:941e150e78b6 | 1416 | /** |
bwang | 0:941e150e78b6 | 1417 | * @brief Returns the FLASH BOR level. |
bwang | 0:941e150e78b6 | 1418 | * @param None |
bwang | 0:941e150e78b6 | 1419 | * @retval The FLASH BOR level: |
bwang | 0:941e150e78b6 | 1420 | * - OB_BOR_LEVEL3: Supply voltage ranges from 2.7 to 3.6 V |
bwang | 0:941e150e78b6 | 1421 | * - OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V |
bwang | 0:941e150e78b6 | 1422 | * - OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V |
bwang | 0:941e150e78b6 | 1423 | * - OB_BOR_OFF : Supply voltage ranges from 1.62 to 2.1 V |
bwang | 0:941e150e78b6 | 1424 | */ |
bwang | 0:941e150e78b6 | 1425 | uint8_t FLASH_OB_GetBOR(void) |
bwang | 0:941e150e78b6 | 1426 | { |
bwang | 0:941e150e78b6 | 1427 | /* Return the FLASH BOR level */ |
bwang | 0:941e150e78b6 | 1428 | return (uint8_t)(*(__IO uint8_t *)(OPTCR_BYTE0_ADDRESS) & (uint8_t)0x0C); |
bwang | 0:941e150e78b6 | 1429 | } |
bwang | 0:941e150e78b6 | 1430 | |
bwang | 0:941e150e78b6 | 1431 | /** |
bwang | 0:941e150e78b6 | 1432 | * @} |
bwang | 0:941e150e78b6 | 1433 | */ |
bwang | 0:941e150e78b6 | 1434 | |
bwang | 0:941e150e78b6 | 1435 | /** @defgroup FLASH_Group4 Interrupts and flags management functions |
bwang | 0:941e150e78b6 | 1436 | * @brief Interrupts and flags management functions |
bwang | 0:941e150e78b6 | 1437 | * |
bwang | 0:941e150e78b6 | 1438 | @verbatim |
bwang | 0:941e150e78b6 | 1439 | =============================================================================== |
bwang | 0:941e150e78b6 | 1440 | ##### Interrupts and flags management functions ##### |
bwang | 0:941e150e78b6 | 1441 | =============================================================================== |
bwang | 0:941e150e78b6 | 1442 | @endverbatim |
bwang | 0:941e150e78b6 | 1443 | * @{ |
bwang | 0:941e150e78b6 | 1444 | */ |
bwang | 0:941e150e78b6 | 1445 | |
bwang | 0:941e150e78b6 | 1446 | /** |
bwang | 0:941e150e78b6 | 1447 | * @brief Enables or disables the specified FLASH interrupts. |
bwang | 0:941e150e78b6 | 1448 | * @param FLASH_IT: specifies the FLASH interrupt sources to be enabled or disabled. |
bwang | 0:941e150e78b6 | 1449 | * This parameter can be any combination of the following values: |
bwang | 0:941e150e78b6 | 1450 | * @arg FLASH_IT_ERR: FLASH Error Interrupt |
bwang | 0:941e150e78b6 | 1451 | * @arg FLASH_IT_EOP: FLASH end of operation Interrupt |
bwang | 0:941e150e78b6 | 1452 | * @retval None |
bwang | 0:941e150e78b6 | 1453 | */ |
bwang | 0:941e150e78b6 | 1454 | void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState) |
bwang | 0:941e150e78b6 | 1455 | { |
bwang | 0:941e150e78b6 | 1456 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1457 | assert_param(IS_FLASH_IT(FLASH_IT)); |
bwang | 0:941e150e78b6 | 1458 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
bwang | 0:941e150e78b6 | 1459 | |
bwang | 0:941e150e78b6 | 1460 | if(NewState != DISABLE) |
bwang | 0:941e150e78b6 | 1461 | { |
bwang | 0:941e150e78b6 | 1462 | /* Enable the interrupt sources */ |
bwang | 0:941e150e78b6 | 1463 | FLASH->CR |= FLASH_IT; |
bwang | 0:941e150e78b6 | 1464 | } |
bwang | 0:941e150e78b6 | 1465 | else |
bwang | 0:941e150e78b6 | 1466 | { |
bwang | 0:941e150e78b6 | 1467 | /* Disable the interrupt sources */ |
bwang | 0:941e150e78b6 | 1468 | FLASH->CR &= ~(uint32_t)FLASH_IT; |
bwang | 0:941e150e78b6 | 1469 | } |
bwang | 0:941e150e78b6 | 1470 | } |
bwang | 0:941e150e78b6 | 1471 | |
bwang | 0:941e150e78b6 | 1472 | /** |
bwang | 0:941e150e78b6 | 1473 | * @brief Checks whether the specified FLASH flag is set or not. |
bwang | 0:941e150e78b6 | 1474 | * @param FLASH_FLAG: specifies the FLASH flag to check. |
bwang | 0:941e150e78b6 | 1475 | * This parameter can be one of the following values: |
bwang | 0:941e150e78b6 | 1476 | * @arg FLASH_FLAG_EOP: FLASH End of Operation flag |
bwang | 0:941e150e78b6 | 1477 | * @arg FLASH_FLAG_OPERR: FLASH operation Error flag |
bwang | 0:941e150e78b6 | 1478 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag |
bwang | 0:941e150e78b6 | 1479 | * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag |
bwang | 0:941e150e78b6 | 1480 | * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag |
bwang | 0:941e150e78b6 | 1481 | * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag |
bwang | 0:941e150e78b6 | 1482 | * @arg FLASH_FLAG_RDERR: FLASH (PCROP) Read Protection error flag (STM32F42xx/43xxx and STM32F401xx/411xE devices) |
bwang | 0:941e150e78b6 | 1483 | * @arg FLASH_FLAG_BSY: FLASH Busy flag |
bwang | 0:941e150e78b6 | 1484 | * @retval The new state of FLASH_FLAG (SET or RESET). |
bwang | 0:941e150e78b6 | 1485 | */ |
bwang | 0:941e150e78b6 | 1486 | FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG) |
bwang | 0:941e150e78b6 | 1487 | { |
bwang | 0:941e150e78b6 | 1488 | FlagStatus bitstatus = RESET; |
bwang | 0:941e150e78b6 | 1489 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1490 | assert_param(IS_FLASH_GET_FLAG(FLASH_FLAG)); |
bwang | 0:941e150e78b6 | 1491 | |
bwang | 0:941e150e78b6 | 1492 | if((FLASH->SR & FLASH_FLAG) != (uint32_t)RESET) |
bwang | 0:941e150e78b6 | 1493 | { |
bwang | 0:941e150e78b6 | 1494 | bitstatus = SET; |
bwang | 0:941e150e78b6 | 1495 | } |
bwang | 0:941e150e78b6 | 1496 | else |
bwang | 0:941e150e78b6 | 1497 | { |
bwang | 0:941e150e78b6 | 1498 | bitstatus = RESET; |
bwang | 0:941e150e78b6 | 1499 | } |
bwang | 0:941e150e78b6 | 1500 | /* Return the new state of FLASH_FLAG (SET or RESET) */ |
bwang | 0:941e150e78b6 | 1501 | return bitstatus; |
bwang | 0:941e150e78b6 | 1502 | } |
bwang | 0:941e150e78b6 | 1503 | |
bwang | 0:941e150e78b6 | 1504 | /** |
bwang | 0:941e150e78b6 | 1505 | * @brief Clears the FLASH's pending flags. |
bwang | 0:941e150e78b6 | 1506 | * @param FLASH_FLAG: specifies the FLASH flags to clear. |
bwang | 0:941e150e78b6 | 1507 | * This parameter can be any combination of the following values: |
bwang | 0:941e150e78b6 | 1508 | * @arg FLASH_FLAG_EOP: FLASH End of Operation flag |
bwang | 0:941e150e78b6 | 1509 | * @arg FLASH_FLAG_OPERR: FLASH operation Error flag |
bwang | 0:941e150e78b6 | 1510 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag |
bwang | 0:941e150e78b6 | 1511 | * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag |
bwang | 0:941e150e78b6 | 1512 | * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag |
bwang | 0:941e150e78b6 | 1513 | * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag |
bwang | 0:941e150e78b6 | 1514 | * @arg FLASH_FLAG_RDERR: FLASH Read Protection error flag (STM32F42xx/43xxx and STM32F401xx/411xE devices) |
bwang | 0:941e150e78b6 | 1515 | * @retval None |
bwang | 0:941e150e78b6 | 1516 | */ |
bwang | 0:941e150e78b6 | 1517 | void FLASH_ClearFlag(uint32_t FLASH_FLAG) |
bwang | 0:941e150e78b6 | 1518 | { |
bwang | 0:941e150e78b6 | 1519 | /* Check the parameters */ |
bwang | 0:941e150e78b6 | 1520 | assert_param(IS_FLASH_CLEAR_FLAG(FLASH_FLAG)); |
bwang | 0:941e150e78b6 | 1521 | |
bwang | 0:941e150e78b6 | 1522 | /* Clear the flags */ |
bwang | 0:941e150e78b6 | 1523 | FLASH->SR = FLASH_FLAG; |
bwang | 0:941e150e78b6 | 1524 | } |
bwang | 0:941e150e78b6 | 1525 | |
bwang | 0:941e150e78b6 | 1526 | /** |
bwang | 0:941e150e78b6 | 1527 | * @brief Returns the FLASH Status. |
bwang | 0:941e150e78b6 | 1528 | * @param None |
bwang | 0:941e150e78b6 | 1529 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 1530 | * FLASH_ERROR_WRP2, FLASH_ERROR_RD2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 1531 | */ |
bwang | 0:941e150e78b6 | 1532 | FLASH_Status FLASH_GetStatus(void) |
bwang | 0:941e150e78b6 | 1533 | { |
bwang | 0:941e150e78b6 | 1534 | FLASH_Status flashstatus = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1535 | |
bwang | 0:941e150e78b6 | 1536 | if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY) |
bwang | 0:941e150e78b6 | 1537 | { |
bwang | 0:941e150e78b6 | 1538 | flashstatus = FLASH_BUSY2; |
bwang | 0:941e150e78b6 | 1539 | } |
bwang | 0:941e150e78b6 | 1540 | else |
bwang | 0:941e150e78b6 | 1541 | { |
bwang | 0:941e150e78b6 | 1542 | if((FLASH->SR & FLASH_FLAG_WRPERR) != (uint32_t)0x00) |
bwang | 0:941e150e78b6 | 1543 | { |
bwang | 0:941e150e78b6 | 1544 | flashstatus = FLASH_ERROR_WRP2; |
bwang | 0:941e150e78b6 | 1545 | } |
bwang | 0:941e150e78b6 | 1546 | else |
bwang | 0:941e150e78b6 | 1547 | { |
bwang | 0:941e150e78b6 | 1548 | if((FLASH->SR & FLASH_FLAG_RDERR) != (uint32_t)0x00) |
bwang | 0:941e150e78b6 | 1549 | { |
bwang | 0:941e150e78b6 | 1550 | flashstatus = FLASH_ERROR_RD2; |
bwang | 0:941e150e78b6 | 1551 | } |
bwang | 0:941e150e78b6 | 1552 | else |
bwang | 0:941e150e78b6 | 1553 | { |
bwang | 0:941e150e78b6 | 1554 | if((FLASH->SR & (uint32_t)0xE0) != (uint32_t)0x00) |
bwang | 0:941e150e78b6 | 1555 | { |
bwang | 0:941e150e78b6 | 1556 | flashstatus = FLASH_ERROR_PROGRAM2; |
bwang | 0:941e150e78b6 | 1557 | } |
bwang | 0:941e150e78b6 | 1558 | else |
bwang | 0:941e150e78b6 | 1559 | { |
bwang | 0:941e150e78b6 | 1560 | if((FLASH->SR & FLASH_FLAG_OPERR) != (uint32_t)0x00) |
bwang | 0:941e150e78b6 | 1561 | { |
bwang | 0:941e150e78b6 | 1562 | flashstatus = FLASH_ERROR_OPERATION2; |
bwang | 0:941e150e78b6 | 1563 | } |
bwang | 0:941e150e78b6 | 1564 | else |
bwang | 0:941e150e78b6 | 1565 | { |
bwang | 0:941e150e78b6 | 1566 | flashstatus = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1567 | } |
bwang | 0:941e150e78b6 | 1568 | } |
bwang | 0:941e150e78b6 | 1569 | } |
bwang | 0:941e150e78b6 | 1570 | } |
bwang | 0:941e150e78b6 | 1571 | } |
bwang | 0:941e150e78b6 | 1572 | /* Return the FLASH Status */ |
bwang | 0:941e150e78b6 | 1573 | return flashstatus; |
bwang | 0:941e150e78b6 | 1574 | } |
bwang | 0:941e150e78b6 | 1575 | |
bwang | 0:941e150e78b6 | 1576 | /** |
bwang | 0:941e150e78b6 | 1577 | * @brief Waits for a FLASH operation to complete. |
bwang | 0:941e150e78b6 | 1578 | * @param None |
bwang | 0:941e150e78b6 | 1579 | * @retval FLASH Status: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, |
bwang | 0:941e150e78b6 | 1580 | * FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2. |
bwang | 0:941e150e78b6 | 1581 | */ |
bwang | 0:941e150e78b6 | 1582 | FLASH_Status FLASH_WaitForLastOperation2(void) |
bwang | 0:941e150e78b6 | 1583 | { |
bwang | 0:941e150e78b6 | 1584 | __IO FLASH_Status status = FLASH_COMPLETE2; |
bwang | 0:941e150e78b6 | 1585 | |
bwang | 0:941e150e78b6 | 1586 | /* Check for the FLASH Status */ |
bwang | 0:941e150e78b6 | 1587 | status = FLASH_GetStatus(); |
bwang | 0:941e150e78b6 | 1588 | |
bwang | 0:941e150e78b6 | 1589 | /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset. |
bwang | 0:941e150e78b6 | 1590 | Even if the FLASH operation fails, the BUSY flag will be reset and an error |
bwang | 0:941e150e78b6 | 1591 | flag will be set */ |
bwang | 0:941e150e78b6 | 1592 | while(status == FLASH_BUSY2) |
bwang | 0:941e150e78b6 | 1593 | { |
bwang | 0:941e150e78b6 | 1594 | status = FLASH_GetStatus(); |
bwang | 0:941e150e78b6 | 1595 | } |
bwang | 0:941e150e78b6 | 1596 | /* Return the operation status */ |
bwang | 0:941e150e78b6 | 1597 | return status; |
bwang | 0:941e150e78b6 | 1598 | } |
bwang | 0:941e150e78b6 | 1599 | |
bwang | 0:941e150e78b6 | 1600 | /** |
bwang | 0:941e150e78b6 | 1601 | * @} |
bwang | 0:941e150e78b6 | 1602 | */ |
bwang | 0:941e150e78b6 | 1603 | |
bwang | 0:941e150e78b6 | 1604 | /** |
bwang | 0:941e150e78b6 | 1605 | * @} |
bwang | 0:941e150e78b6 | 1606 | */ |
bwang | 0:941e150e78b6 | 1607 | |
bwang | 0:941e150e78b6 | 1608 | /** |
bwang | 0:941e150e78b6 | 1609 | * @} |
bwang | 0:941e150e78b6 | 1610 | */ |
bwang | 0:941e150e78b6 | 1611 | |
bwang | 0:941e150e78b6 | 1612 | /** |
bwang | 0:941e150e78b6 | 1613 | * @} |
bwang | 0:941e150e78b6 | 1614 | */ |
bwang | 0:941e150e78b6 | 1615 | |
bwang | 0:941e150e78b6 | 1616 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |