helpfor studient

Dependents:   STM32_F103-C8T6basecanblink_led

Fork of mbed-dev by mbed official

Committer:
AnnaBridge
Date:
Thu Apr 19 17:12:19 2018 +0100
Revision:
185:08ed48f1de7f
Parent:
160:d5399cc887bb
mbed-dev library. Release version 161

Who changed what in which revision?

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