Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers flash_intf.h Source File

flash_intf.h

Go to the documentation of this file.
00001 /**
00002  * @file    flash_intf.h
00003  * @brief   Interface for implementing differet ways to write an image into memory
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #ifndef FLASH_INTF_H
00023 #define FLASH_INTF_H
00024 
00025 #include <stdint.h>
00026 
00027 #include "error.h"
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 typedef enum {
00034     FLASH_FUNC_NOP,
00035     FLASH_FUNC_ERASE,
00036     FLASH_FUNC_PROGRAM,
00037     FLASH_FUNC_VERIFY
00038 } flash_func_t;
00039 
00040 typedef error_t (*flash_intf_init_cb_t)(void);
00041 typedef error_t (*flash_intf_uninit_cb_t)(void);
00042 typedef error_t (*flash_intf_program_page_cb_t)(uint32_t addr, const uint8_t *buf, uint32_t size);
00043 typedef error_t (*flash_intf_erase_sector_cb_t)(uint32_t sector);
00044 typedef error_t (*flash_intf_erase_chip_cb_t)(void);
00045 typedef uint32_t (*flash_program_page_min_size_cb_t)(uint32_t addr);
00046 typedef uint32_t (*flash_erase_sector_size_cb_t)(uint32_t addr);
00047 typedef uint8_t (*flash_busy_cb_t)(void);
00048 typedef error_t (*flash_algo_set_cb_t)(uint32_t addr);
00049 
00050 typedef struct {
00051     flash_intf_init_cb_t init;
00052     flash_intf_uninit_cb_t uninit;
00053     flash_intf_program_page_cb_t program_page;
00054     flash_intf_erase_sector_cb_t erase_sector;
00055     flash_intf_erase_chip_cb_t erase_chip;
00056     flash_program_page_min_size_cb_t program_page_min_size;
00057     flash_erase_sector_size_cb_t erase_sector_size;
00058     flash_busy_cb_t flash_busy;
00059     flash_algo_set_cb_t flash_algo_set;
00060 } flash_intf_t;
00061 
00062 // All flash interfaces.  Unsupported interfaces are NULL.
00063 extern const flash_intf_t *const flash_intf_iap_protected;
00064 extern const flash_intf_t *const flash_intf_target;
00065 extern const flash_intf_t *const flash_intf_target_custom;
00066 
00067 #ifdef __cplusplus
00068 }
00069 #endif
00070 
00071 #endif