helpfor studient

Dependents:   STM32_F103-C8T6basecanblink_led

Fork of mbed-dev by mbed official

hal/TARGET_FLASH_CMSIS_ALGO/flash_data.h

Committer:
AnnaBridge
Date:
2018-04-19
Revision:
185:08ed48f1de7f
Parent:
160:d5399cc887bb

File content as of revision 185:08ed48f1de7f:

/* mbed Microcontroller Library
 * Copyright (c) 2017 ARM Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef MBED_FLASH_DATA_H
#define MBED_FLASH_DATA_H

#include <stdint.h>

/** Target flash algorithm structure
 */
typedef struct {
    const uint32_t init; /**< Init function address */
    const uint32_t uninit; /**< Uninit function address */
    const uint32_t erase_sector; /**< Erase sector function address */
    const uint32_t program_page; /**< Program page function address */
    const uint32_t static_base; /**< Static base address */
    uint32_t *algo_blob; /**< Pointer to flash algo binary blob */
} flash_algo_t;

/** Sector information structure
 */
typedef struct {
    const uint32_t start; /**< Sector start address */
    const uint32_t size; /**< Sector size */
} sector_info_t;

/** Flash configuration structure
 */
typedef struct {
    const uint32_t page_size; /**< The minimum program page size that can be written */
    const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */
    const uint32_t flash_size; /**<  Flash size. The size is accumulative sum of all sector sizes */
    const sector_info_t *sectors; /**<  List of sectors - sector can vary in sizes */
    const uint32_t sector_info_count; /**< Number of sectors */
} flash_target_config_t;

/** Target flash configuration
 */
struct flash_s {
    const flash_target_config_t *target_config;
    const flash_algo_t *flash_algo;
};

/** Flash algo argument structure
 *  Contains all registers that should be preserved
 */
typedef struct {
    uint32_t r0;
    uint32_t r1;
    uint32_t r2;
    uint32_t r3;
    uint32_t r9;
    uint32_t pc;
} args_t;

typedef int32_t (*flash_algo_jump_t)(args_t*);

// prototypes for flash algo CMSIS API

typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc);
typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc);
typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr);
typedef int (*CMSIS_Algo_Function_EraseChip)(void);
typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf);
typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf);

#ifdef __cplusplus
extern "C" {
#endif

/* Set target configuration
 */
void flash_set_target_config(flash_t *obj);

#ifdef __cplusplus
};
#endif


#endif