helpfor studient
Dependents: STM32_F103-C8T6basecanblink_led
Fork of mbed-dev by
targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c@163:74e0ce7f98e8, 2017-04-28 (annotated)
- Committer:
- Anna Bridge
- Date:
- Fri Apr 28 14:04:18 2017 +0100
- Revision:
- 163:74e0ce7f98e8
- Child:
- 185:08ed48f1de7f
This updates the lib to the mbed lib v141
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
163:74e0ce7f98e8 | 1 | /* mbed Microcontroller Library |
Anna Bridge |
163:74e0ce7f98e8 | 2 | * Copyright (c) 2015-2016 Nuvoton |
Anna Bridge |
163:74e0ce7f98e8 | 3 | * |
Anna Bridge |
163:74e0ce7f98e8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Anna Bridge |
163:74e0ce7f98e8 | 5 | * you may not use this file except in compliance with the License. |
Anna Bridge |
163:74e0ce7f98e8 | 6 | * You may obtain a copy of the License at |
Anna Bridge |
163:74e0ce7f98e8 | 7 | * |
Anna Bridge |
163:74e0ce7f98e8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Anna Bridge |
163:74e0ce7f98e8 | 9 | * |
Anna Bridge |
163:74e0ce7f98e8 | 10 | * Unless required by applicable law or agreed to in writing, software |
Anna Bridge |
163:74e0ce7f98e8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Anna Bridge |
163:74e0ce7f98e8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Anna Bridge |
163:74e0ce7f98e8 | 13 | * See the License for the specific language governing permissions and |
Anna Bridge |
163:74e0ce7f98e8 | 14 | * limitations under the License. |
Anna Bridge |
163:74e0ce7f98e8 | 15 | */ |
Anna Bridge |
163:74e0ce7f98e8 | 16 | |
Anna Bridge |
163:74e0ce7f98e8 | 17 | #include "flash_api.h" |
Anna Bridge |
163:74e0ce7f98e8 | 18 | #include "flash_data.h" |
Anna Bridge |
163:74e0ce7f98e8 | 19 | #include "mbed_critical.h" |
Anna Bridge |
163:74e0ce7f98e8 | 20 | |
Anna Bridge |
163:74e0ce7f98e8 | 21 | // This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM |
Anna Bridge |
163:74e0ce7f98e8 | 22 | // NOTE: On ARMv7-M/ARMv8-M, instruction fetches are always little-endian. |
Anna Bridge |
163:74e0ce7f98e8 | 23 | static uint32_t FLASH_ALGO[] = { |
Anna Bridge |
163:74e0ce7f98e8 | 24 | 0x4603b530, 0x2164460c, 0x4de72059, 0x20166028, 0xf8c5070d, 0x20880100, 0x0100f8c5, 0xf8d006c0, |
Anna Bridge |
163:74e0ce7f98e8 | 25 | 0xf0000100, 0xb9080001, 0xbd302001, 0x680048df, 0x0004f040, 0x4580f04f, 0x0200f8c5, 0xf8d04628, |
Anna Bridge |
163:74e0ce7f98e8 | 26 | 0xf0400204, 0xf8c50004, 0xbf000204, 0xf1a11e08, 0xd1fb0101, 0x680048d6, 0x0029f040, 0x60284dd4, |
Anna Bridge |
163:74e0ce7f98e8 | 27 | 0x68004628, 0x0001f000, 0x2001b908, 0xf04fe7dd, 0x4dcf30ff, 0x46286468, 0x1c406c40, 0x2001b108, |
Anna Bridge |
163:74e0ce7f98e8 | 28 | 0x48cbe7d3, 0xf0406800, 0x4dc90040, 0x20006028, 0x4601e7cb, 0x48c6bf00, 0xf0006900, 0x28000001, |
Anna Bridge |
163:74e0ce7f98e8 | 29 | 0x48c3d1f9, 0xf0206800, 0x4ac10029, 0x20006010, 0x60104abd, 0x46014770, 0x48bdbf00, 0xf0006900, |
Anna Bridge |
163:74e0ce7f98e8 | 30 | 0x28000001, 0x48bad1f9, 0xf0406800, 0x4ab80040, 0x20226010, 0xf02160d0, 0x60500003, 0x61102001, |
Anna Bridge |
163:74e0ce7f98e8 | 31 | 0x8f60f3bf, 0x48b2bf00, 0xf0006900, 0x28000001, 0x48afd1f9, 0xf0006800, 0xb1380040, 0x680048ac, |
Anna Bridge |
163:74e0ce7f98e8 | 32 | 0x0040f040, 0x60104aaa, 0x47702001, 0xe7fc2000, 0x4603b570, 0x2500460c, 0x4629e009, 0xf8531c6d, |
Anna Bridge |
163:74e0ce7f98e8 | 33 | 0xf7ff0021, 0x1e06ffc8, 0x4630d001, 0x42a5bd70, 0x2000d3f3, 0xb570e7fa, 0x460b4604, 0x22004615, |
Anna Bridge |
163:74e0ce7f98e8 | 34 | 0xf1034629, 0xf020000f, 0xbf00030f, 0x69004898, 0x0001f000, 0xd1f92800, 0x68004895, 0x0040f040, |
Anna Bridge |
163:74e0ce7f98e8 | 35 | 0x60304e93, 0x000ff024, 0x20276070, 0x461060f0, 0xf8511c52, 0x4e8e0020, 0x60303680, 0x1c524610, |
Anna Bridge |
163:74e0ce7f98e8 | 36 | 0x0020f851, 0xf8c64e8a, 0x46100084, 0xf8511c52, 0x4e870020, 0x60303688, 0x1c524610, 0x0020f851, |
Anna Bridge |
163:74e0ce7f98e8 | 37 | 0x60301d36, 0x4e822001, 0x3b106130, 0xbf00e02c, 0x30c0487f, 0xf0006800, 0x28000030, 0x4610d1f8, |
Anna Bridge |
163:74e0ce7f98e8 | 38 | 0xf8511c52, 0x4e7a0020, 0x60303680, 0x1c524610, 0x0020f851, 0xf8c64e76, 0xbf000084, 0x30c04874, |
Anna Bridge |
163:74e0ce7f98e8 | 39 | 0xf0006800, 0x280000c0, 0x4610d1f8, 0xf8511c52, 0x4e6f0020, 0x60303688, 0x1c524610, 0x0020f851, |
Anna Bridge |
163:74e0ce7f98e8 | 40 | 0xf8c64e6b, 0x3b10008c, 0xd1d02b00, 0x4868bf00, 0xf0006900, 0x28000001, 0xbd70d1f9, 0x4603b510, |
Anna Bridge |
163:74e0ce7f98e8 | 41 | 0xf0201cc8, 0xbf000103, 0x69004861, 0x0001f000, 0xd1f92800, 0x6800485e, 0x0040f040, 0x60204c5c, |
Anna Bridge |
163:74e0ce7f98e8 | 42 | 0x60e02021, 0xf023e020, 0x4c590003, 0x68106060, 0x200160a0, 0xf3bf6120, 0xbf008f60, 0x69004854, |
Anna Bridge |
163:74e0ce7f98e8 | 43 | 0x0001f000, 0xd1f92800, 0x68004851, 0x0040f000, 0x484fb138, 0xf0406800, 0x4c4d0040, 0x20016020, |
Anna Bridge |
163:74e0ce7f98e8 | 44 | 0x1d1bbd10, 0x1f091d12, 0xd1dc2900, 0xe7f72000, 0x47f0e92d, 0x460c4605, 0xf04f4616, 0x46c20800, |
Anna Bridge |
163:74e0ce7f98e8 | 45 | 0x4843bf00, 0xf0006900, 0x28000001, 0x4840d1f9, 0xf0406800, 0x493e0040, 0x1ce06008, 0x0403f020, |
Anna Bridge |
163:74e0ce7f98e8 | 46 | 0xf3c5e02f, 0xb9600008, 0x7f00f5b4, 0xf44fd309, 0xeb067700, 0x46390208, 0xf7ff4628, 0x4682ff2c, |
Anna Bridge |
163:74e0ce7f98e8 | 47 | 0xf3c5e016, 0xb9580008, 0xd3092c10, 0x070ff024, 0x0208eb06, 0x46284639, 0xff1df7ff, 0xe0074682, |
Anna Bridge |
163:74e0ce7f98e8 | 48 | 0xeb064627, 0x46390208, 0xf7ff4628, 0x4682ff87, 0x44b8443d, 0xf1ba1be4, 0xd0020f00, 0xe8bd2001, |
Anna Bridge |
163:74e0ce7f98e8 | 49 | 0x2c0087f0, 0x2000d1cd, 0xb510e7f9, 0xf0231ccb, 0xbf000103, 0x691b4b1e, 0x0301f003, 0xd1f92b00, |
Anna Bridge |
163:74e0ce7f98e8 | 50 | 0x681b4b1b, 0x0340f043, 0x60234c19, 0x60e32300, 0xf020e025, 0x4c160303, 0x23006063, 0x230160a3, |
Anna Bridge |
163:74e0ce7f98e8 | 51 | 0xf3bf6123, 0xbf008f60, 0x691b4b11, 0x0301f003, 0xd1f92b00, 0x681b4b0e, 0x0340f003, 0x4b0cb133, |
Anna Bridge |
163:74e0ce7f98e8 | 52 | 0xf043681b, 0x4c0a0340, 0xbd106023, 0x689b4b08, 0x42a36814, 0xe7f8d000, 0x1d121d00, 0x29001f09, |
Anna Bridge |
163:74e0ce7f98e8 | 53 | 0xbf00d1d7, 0x0000e7f1, 0x40000100, 0x40000200, 0x4000c000, 0x00000000, |
Anna Bridge |
163:74e0ce7f98e8 | 54 | }; |
Anna Bridge |
163:74e0ce7f98e8 | 55 | |
Anna Bridge |
163:74e0ce7f98e8 | 56 | static const flash_algo_t flash_algo_config = { |
Anna Bridge |
163:74e0ce7f98e8 | 57 | .init = 0x00000001, |
Anna Bridge |
163:74e0ce7f98e8 | 58 | .uninit = 0x00000093, |
Anna Bridge |
163:74e0ce7f98e8 | 59 | .erase_sector = 0x000000b7, |
Anna Bridge |
163:74e0ce7f98e8 | 60 | .program_page = 0x00000291, |
Anna Bridge |
163:74e0ce7f98e8 | 61 | .static_base = 0x000003b4, |
Anna Bridge |
163:74e0ce7f98e8 | 62 | .algo_blob = FLASH_ALGO |
Anna Bridge |
163:74e0ce7f98e8 | 63 | }; |
Anna Bridge |
163:74e0ce7f98e8 | 64 | |
Anna Bridge |
163:74e0ce7f98e8 | 65 | static const sector_info_t sectors_info[] = { |
Anna Bridge |
163:74e0ce7f98e8 | 66 | {0x0, 0x800}, // (start, sector size) |
Anna Bridge |
163:74e0ce7f98e8 | 67 | }; |
Anna Bridge |
163:74e0ce7f98e8 | 68 | |
Anna Bridge |
163:74e0ce7f98e8 | 69 | static const flash_target_config_t flash_target_config = { |
Anna Bridge |
163:74e0ce7f98e8 | 70 | .page_size = 0x800, // 2 KB |
Anna Bridge |
163:74e0ce7f98e8 | 71 | .flash_start = 0x0, |
Anna Bridge |
163:74e0ce7f98e8 | 72 | .flash_size = 0x80000, // 512 KB |
Anna Bridge |
163:74e0ce7f98e8 | 73 | .sectors = sectors_info, |
Anna Bridge |
163:74e0ce7f98e8 | 74 | .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) |
Anna Bridge |
163:74e0ce7f98e8 | 75 | }; |
Anna Bridge |
163:74e0ce7f98e8 | 76 | |
Anna Bridge |
163:74e0ce7f98e8 | 77 | void flash_set_target_config(flash_t *obj) |
Anna Bridge |
163:74e0ce7f98e8 | 78 | { |
Anna Bridge |
163:74e0ce7f98e8 | 79 | obj->flash_algo = &flash_algo_config; |
Anna Bridge |
163:74e0ce7f98e8 | 80 | obj->target_config = &flash_target_config; |
Anna Bridge |
163:74e0ce7f98e8 | 81 | } |