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

« Back to documentation index

Show/hide line numbers FlashPrg.h Source File

FlashPrg.h

Go to the documentation of this file.
00001 /**
00002  * @file    FlashPrg.h
00003  * @brief
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2016, 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 FLASHPRG_H
00023 #define FLASHPRG_H
00024 
00025 #include <stdint.h>
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 /** Initialize programming functions
00032  *  @param adr device base address
00033  *  @param clk clock frequency (Hz)
00034  *  @param fnc function code (1 - Erase, 2 - Program, 3 - Verify)
00035  *  @return 0 on success, an error code otherwise
00036  */
00037 uint32_t Init(uint32_t adr, uint32_t clk, uint32_t fnc);
00038 
00039 /** De-Initialize programming functions [optional]
00040  *  @param fnc function code (1 - Erase, 2 - Program, 3 - Verify)
00041  *  @return 0 on success, an error code otherwise
00042  */
00043 uint32_t UnInit(uint32_t fnc);
00044 
00045 /** Check region for erased memory
00046  *  @param adr address to start from
00047  *  @param sz the amount of memory to check
00048  *  @param pat the pattern of erased memory (usually 0xff)
00049  *  @return 0 on success, an error code otherwise
00050  */
00051 uint32_t BlankCheck(uint32_t adr, uint32_t sz, uint8_t pat);
00052 
00053 /** Perform a full chip erase
00054  *  @return 0 on success, an error code otherwise
00055  */
00056 uint32_t EraseChip(void);
00057 
00058 /** Erase a single sector of memory
00059  *  @param adr address of a sector to erase
00060  *  @return 0 on success, an error code otherwise
00061  */
00062 uint32_t EraseSector(uint32_t adr);
00063 
00064 /** Program data into memory
00065  *  @param adr address to start programming from
00066  *  @param sz the amount of data to program
00067  *  @param buf memory contents to be programmed
00068  *  @return 0 on success, an error code otherwise
00069  */
00070 uint32_t ProgramPage(uint32_t adr, uint32_t sz, uint32_t *buf);
00071 
00072 /** Verify contents in memory
00073  *  @param adr start address of the verification
00074  *  @param sz the amount of data to be verified
00075  *  @param buf memory contents to be compared against
00076  *  @return 0 on success, an error code otherwise
00077  */
00078 uint32_t Verify(uint32_t adr, uint32_t sz, uint32_t *buf);
00079 
00080 #ifdef __cplusplus
00081 }
00082 #endif
00083 
00084 #endif