The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
hal/flash_data.h@166:5aab5a7997ee, 2018-04-20 (annotated)
- Committer:
- Anna Bridge
- Date:
- Fri Apr 20 11:08:29 2018 +0100
- Revision:
- 166:5aab5a7997ee
- Parent:
- 165:d1b4690b3f8b
- Child:
- 169:a7c7b631e539
Updating mbed 2 version number
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 138:093f2bd7b9eb | 1 | /* mbed Microcontroller Library |
<> | 138:093f2bd7b9eb | 2 | * Copyright (c) 2017 ARM Limited |
<> | 138:093f2bd7b9eb | 3 | * |
<> | 138:093f2bd7b9eb | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 138:093f2bd7b9eb | 5 | * you may not use this file except in compliance with the License. |
<> | 138:093f2bd7b9eb | 6 | * You may obtain a copy of the License at |
<> | 138:093f2bd7b9eb | 7 | * |
<> | 138:093f2bd7b9eb | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 138:093f2bd7b9eb | 9 | * |
<> | 138:093f2bd7b9eb | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 138:093f2bd7b9eb | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 138:093f2bd7b9eb | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 138:093f2bd7b9eb | 13 | * See the License for the specific language governing permissions and |
<> | 138:093f2bd7b9eb | 14 | * limitations under the License. |
<> | 138:093f2bd7b9eb | 15 | */ |
<> | 138:093f2bd7b9eb | 16 | #ifndef MBED_FLASH_DATA_H |
<> | 138:093f2bd7b9eb | 17 | #define MBED_FLASH_DATA_H |
<> | 138:093f2bd7b9eb | 18 | |
<> | 138:093f2bd7b9eb | 19 | #include <stdint.h> |
<> | 138:093f2bd7b9eb | 20 | |
AnnaBridge | 165:d1b4690b3f8b | 21 | /** Target flash algorithm structure |
AnnaBridge | 165:d1b4690b3f8b | 22 | */ |
<> | 138:093f2bd7b9eb | 23 | typedef struct { |
AnnaBridge | 165:d1b4690b3f8b | 24 | const uint32_t init; /**< Init function address */ |
AnnaBridge | 165:d1b4690b3f8b | 25 | const uint32_t uninit; /**< Uninit function address */ |
AnnaBridge | 165:d1b4690b3f8b | 26 | const uint32_t erase_sector; /**< Erase sector function address */ |
AnnaBridge | 165:d1b4690b3f8b | 27 | const uint32_t program_page; /**< Program page function address */ |
AnnaBridge | 165:d1b4690b3f8b | 28 | const uint32_t static_base; /**< Static base address */ |
AnnaBridge | 165:d1b4690b3f8b | 29 | uint32_t *algo_blob; /**< Pointer to flash algo binary blob */ |
<> | 138:093f2bd7b9eb | 30 | } flash_algo_t; |
<> | 138:093f2bd7b9eb | 31 | |
AnnaBridge | 165:d1b4690b3f8b | 32 | /** Sector information structure |
AnnaBridge | 165:d1b4690b3f8b | 33 | */ |
<> | 138:093f2bd7b9eb | 34 | typedef struct { |
AnnaBridge | 165:d1b4690b3f8b | 35 | const uint32_t start; /**< Sector start address */ |
AnnaBridge | 165:d1b4690b3f8b | 36 | const uint32_t size; /**< Sector size */ |
<> | 138:093f2bd7b9eb | 37 | } sector_info_t; |
<> | 138:093f2bd7b9eb | 38 | |
AnnaBridge | 165:d1b4690b3f8b | 39 | /** Flash configuration structure |
AnnaBridge | 165:d1b4690b3f8b | 40 | */ |
<> | 138:093f2bd7b9eb | 41 | typedef struct { |
AnnaBridge | 165:d1b4690b3f8b | 42 | const uint32_t page_size; /**< The minimum program page size that can be written */ |
AnnaBridge | 165:d1b4690b3f8b | 43 | const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */ |
AnnaBridge | 165:d1b4690b3f8b | 44 | const uint32_t flash_size; /**< Flash size. The size is accumulative sum of all sector sizes */ |
AnnaBridge | 165:d1b4690b3f8b | 45 | const sector_info_t *sectors; /**< List of sectors - sector can vary in sizes */ |
AnnaBridge | 165:d1b4690b3f8b | 46 | const uint32_t sector_info_count; /**< Number of sectors */ |
<> | 138:093f2bd7b9eb | 47 | } flash_target_config_t; |
<> | 138:093f2bd7b9eb | 48 | |
AnnaBridge | 165:d1b4690b3f8b | 49 | /** Target flash configuration |
AnnaBridge | 165:d1b4690b3f8b | 50 | */ |
<> | 138:093f2bd7b9eb | 51 | struct flash_s { |
<> | 138:093f2bd7b9eb | 52 | const flash_target_config_t *target_config; |
<> | 138:093f2bd7b9eb | 53 | const flash_algo_t *flash_algo; |
<> | 138:093f2bd7b9eb | 54 | }; |
<> | 138:093f2bd7b9eb | 55 | |
AnnaBridge | 165:d1b4690b3f8b | 56 | /** Flash algo argument structure |
AnnaBridge | 165:d1b4690b3f8b | 57 | * Contains all registers that should be preserved |
AnnaBridge | 165:d1b4690b3f8b | 58 | */ |
<> | 138:093f2bd7b9eb | 59 | typedef struct { |
<> | 138:093f2bd7b9eb | 60 | uint32_t r0; |
<> | 138:093f2bd7b9eb | 61 | uint32_t r1; |
<> | 138:093f2bd7b9eb | 62 | uint32_t r2; |
<> | 138:093f2bd7b9eb | 63 | uint32_t r3; |
<> | 138:093f2bd7b9eb | 64 | uint32_t r9; |
<> | 138:093f2bd7b9eb | 65 | uint32_t pc; |
<> | 138:093f2bd7b9eb | 66 | } args_t; |
<> | 138:093f2bd7b9eb | 67 | |
<> | 138:093f2bd7b9eb | 68 | typedef int32_t (*flash_algo_jump_t)(args_t*); |
<> | 138:093f2bd7b9eb | 69 | |
<> | 138:093f2bd7b9eb | 70 | // prototypes for flash algo CMSIS API |
<> | 138:093f2bd7b9eb | 71 | |
<> | 138:093f2bd7b9eb | 72 | typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc); |
<> | 138:093f2bd7b9eb | 73 | typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc); |
<> | 138:093f2bd7b9eb | 74 | typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr); |
<> | 138:093f2bd7b9eb | 75 | typedef int (*CMSIS_Algo_Function_EraseChip)(void); |
<> | 138:093f2bd7b9eb | 76 | typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf); |
<> | 138:093f2bd7b9eb | 77 | typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf); |
<> | 138:093f2bd7b9eb | 78 | |
<> | 138:093f2bd7b9eb | 79 | #ifdef __cplusplus |
<> | 138:093f2bd7b9eb | 80 | extern "C" { |
<> | 138:093f2bd7b9eb | 81 | #endif |
<> | 138:093f2bd7b9eb | 82 | |
<> | 138:093f2bd7b9eb | 83 | /* Set target configuration |
<> | 138:093f2bd7b9eb | 84 | */ |
<> | 138:093f2bd7b9eb | 85 | void flash_set_target_config(flash_t *obj); |
<> | 138:093f2bd7b9eb | 86 | |
<> | 138:093f2bd7b9eb | 87 | #ifdef __cplusplus |
<> | 138:093f2bd7b9eb | 88 | }; |
<> | 138:093f2bd7b9eb | 89 | #endif |
<> | 138:093f2bd7b9eb | 90 | |
<> | 138:093f2bd7b9eb | 91 | |
<> | 138:093f2bd7b9eb | 92 | #endif |