1
1
/* mbed Microcontroller Library
2
- * Copyright (c) 2017 ARM Limited
2
+ *******************************************************************************
3
+ * Copyright (c) 2017, STMicroelectronics
4
+ * All rights reserved.
3
5
*
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
7
8
*
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ * this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
15
+ * may be used to endorse or promote products derived from this software
16
+ * without specific prior written permission.
9
17
*
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *******************************************************************************
15
29
*/
16
30
17
31
#include "flash_api.h"
@@ -138,6 +152,7 @@ uint32_t flash_get_size(const flash_t *obj)
138
152
*/
139
153
static uint32_t GetSector (uint32_t address )
140
154
{
155
+ <<<<<<< HEAD
141
156
uint32_t sector = 0 ;
142
157
uint32_t tmp = address - ADDR_FLASH_SECTOR_0 ;
143
158
if (address & 0x100000 ) { // handle 2nd bank
@@ -153,6 +168,107 @@ static uint32_t GetSector(uint32_t address)
153
168
sector += 4 + (tmp >>17 );
154
169
}
155
170
printf ("address:0X%04x%04x, secteur: %d\n" , (address >>16 )& 0XFFFF , (address & 0XFFFF ), sector );
171
+ = == == ==
172
+ uint32_t sector = 0 ;
173
+
174
+ if ((address < ADDR_FLASH_SECTOR_1 ) && (address >= ADDR_FLASH_SECTOR_0 ))
175
+ {
176
+ sector = FLASH_SECTOR_0 ;
177
+ }
178
+ else if ((address < ADDR_FLASH_SECTOR_2 ) && (address >= ADDR_FLASH_SECTOR_1 ))
179
+ {
180
+ sector = FLASH_SECTOR_1 ;
181
+ }
182
+ else if ((address < ADDR_FLASH_SECTOR_3 ) && (address >= ADDR_FLASH_SECTOR_2 ))
183
+ {
184
+ sector = FLASH_SECTOR_2 ;
185
+ }
186
+ else if ((address < ADDR_FLASH_SECTOR_4 ) && (address >= ADDR_FLASH_SECTOR_3 ))
187
+ {
188
+ sector = FLASH_SECTOR_3 ;
189
+ }
190
+ else if ((address < ADDR_FLASH_SECTOR_5 ) && (address >= ADDR_FLASH_SECTOR_4 ))
191
+ {
192
+ sector = FLASH_SECTOR_4 ;
193
+ }
194
+ else if ((address < ADDR_FLASH_SECTOR_6 ) && (address >= ADDR_FLASH_SECTOR_5 ))
195
+ {
196
+ sector = FLASH_SECTOR_5 ;
197
+ }
198
+ else if ((address < ADDR_FLASH_SECTOR_7 ) && (address >= ADDR_FLASH_SECTOR_6 ))
199
+ {
200
+ sector = FLASH_SECTOR_6 ;
201
+ }
202
+ else if ((address < ADDR_FLASH_SECTOR_8 ) && (address >= ADDR_FLASH_SECTOR_7 ))
203
+ {
204
+ sector = FLASH_SECTOR_7 ;
205
+ }
206
+ else if ((address < ADDR_FLASH_SECTOR_9 ) && (address >= ADDR_FLASH_SECTOR_8 ))
207
+ {
208
+ sector = FLASH_SECTOR_8 ;
209
+ }
210
+ else if ((address < ADDR_FLASH_SECTOR_10 ) && (address >= ADDR_FLASH_SECTOR_9 ))
211
+ {
212
+ sector = FLASH_SECTOR_9 ;
213
+ }
214
+ else if ((address < ADDR_FLASH_SECTOR_11 ) && (address >= ADDR_FLASH_SECTOR_10 ))
215
+ {
216
+ sector = FLASH_SECTOR_10 ;
217
+ }
218
+ else if ((address < ADDR_FLASH_SECTOR_12 ) && (address >= ADDR_FLASH_SECTOR_11 ))
219
+ {
220
+ sector = FLASH_SECTOR_11 ;
221
+ }
222
+ else if ((address < ADDR_FLASH_SECTOR_13 ) && (address >= ADDR_FLASH_SECTOR_12 ))
223
+ {
224
+ sector = FLASH_SECTOR_12 ;
225
+ }
226
+ else if ((address < ADDR_FLASH_SECTOR_14 ) && (address >= ADDR_FLASH_SECTOR_13 ))
227
+ {
228
+ sector = FLASH_SECTOR_13 ;
229
+ }
230
+ else if ((address < ADDR_FLASH_SECTOR_15 ) && (address >= ADDR_FLASH_SECTOR_14 ))
231
+ {
232
+ sector = FLASH_SECTOR_14 ;
233
+ }
234
+ else if ((address < ADDR_FLASH_SECTOR_16 ) && (address >= ADDR_FLASH_SECTOR_15 ))
235
+ {
236
+ sector = FLASH_SECTOR_15 ;
237
+ }
238
+ else if ((address < ADDR_FLASH_SECTOR_17 ) && (address >= ADDR_FLASH_SECTOR_16 ))
239
+ {
240
+ sector = FLASH_SECTOR_16 ;
241
+ }
242
+ else if ((address < ADDR_FLASH_SECTOR_18 ) && (address >= ADDR_FLASH_SECTOR_17 ))
243
+ {
244
+ sector = FLASH_SECTOR_17 ;
245
+ }
246
+ else if ((address < ADDR_FLASH_SECTOR_19 ) && (address >= ADDR_FLASH_SECTOR_18 ))
247
+ {
248
+ sector = FLASH_SECTOR_18 ;
249
+ }
250
+ else if ((address < ADDR_FLASH_SECTOR_20 ) && (address >= ADDR_FLASH_SECTOR_19 ))
251
+ {
252
+ sector = FLASH_SECTOR_19 ;
253
+ }
254
+ else if ((address < ADDR_FLASH_SECTOR_21 ) && (address >= ADDR_FLASH_SECTOR_20 ))
255
+ {
256
+ sector = FLASH_SECTOR_20 ;
257
+ }
258
+ else if ((address < ADDR_FLASH_SECTOR_22 ) && (address >= ADDR_FLASH_SECTOR_21 ))
259
+ {
260
+ sector = FLASH_SECTOR_21 ;
261
+ }
262
+ else if ((address < ADDR_FLASH_SECTOR_23 ) && (address >= ADDR_FLASH_SECTOR_22 ))
263
+ {
264
+ sector = FLASH_SECTOR_22 ;
265
+ }
266
+ else /*(address < FLASH_END_ADDR) && (address >= ADDR_FLASH_SECTOR_23))*/
267
+ {
268
+ sector = FLASH_SECTOR_23 ;
269
+ }
270
+
271
+ >>>>>>> 634df 4142. .. fix STM32F439 flash HAL
156
272
return sector ;
157
273
}
158
274
@@ -163,6 +279,7 @@ static uint32_t GetSector(uint32_t address)
163
279
*/
164
280
static uint32_t GetSectorSize (uint32_t Sector )
165
281
{
282
+ <<<<<<< HEAD
166
283
uint32_t sectorsize = 0x00 ;
167
284
if ((Sector == FLASH_SECTOR_0 ) || (Sector == FLASH_SECTOR_1 ) || (Sector == FLASH_SECTOR_2 ) || \
168
285
(Sector == FLASH_SECTOR_3 ) || (Sector == FLASH_SECTOR_12 ) || (Sector == FLASH_SECTOR_13 ) || \
@@ -174,6 +291,24 @@ static uint32_t GetSectorSize(uint32_t Sector)
174
291
sectorsize = 128 * 1024 ;
175
292
}
176
293
return sectorsize ;
294
+ = == == ==
295
+ uint32_t sectorsize = 0x00 ;
296
+ if ((Sector == FLASH_SECTOR_0 ) || (Sector == FLASH_SECTOR_1 ) || (Sector == FLASH_SECTOR_2 ) || \
297
+ (Sector == FLASH_SECTOR_3 ) || (Sector == FLASH_SECTOR_12 ) || (Sector == FLASH_SECTOR_13 ) || \
298
+ (Sector == FLASH_SECTOR_14 ) || (Sector == FLASH_SECTOR_15 ))
299
+ {
300
+ sectorsize = 16 * 1024 ;
301
+ }
302
+ else if ((Sector == FLASH_SECTOR_4 ) || (Sector == FLASH_SECTOR_16 ))
303
+ {
304
+ sectorsize = 64 * 1024 ;
305
+ }
306
+ else
307
+ {
308
+ sectorsize = 128 * 1024 ;
309
+ }
310
+ return sectorsize ;
311
+ >>>>>>> 634df 4142. .. fix STM32F439 flash HAL
177
312
}
178
313
179
314
#endif
0 commit comments