Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:02dd72d1d465 1 /** \addtogroup hal */
borlanic 0:02dd72d1d465 2 /** @{*/
borlanic 0:02dd72d1d465 3
borlanic 0:02dd72d1d465 4 /* mbed Microcontroller Library
borlanic 0:02dd72d1d465 5 * Copyright (c) 2017 ARM Limited
borlanic 0:02dd72d1d465 6 *
borlanic 0:02dd72d1d465 7 * Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:02dd72d1d465 8 * you may not use this file except in compliance with the License.
borlanic 0:02dd72d1d465 9 * You may obtain a copy of the License at
borlanic 0:02dd72d1d465 10 *
borlanic 0:02dd72d1d465 11 * http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:02dd72d1d465 12 *
borlanic 0:02dd72d1d465 13 * Unless required by applicable law or agreed to in writing, software
borlanic 0:02dd72d1d465 14 * distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:02dd72d1d465 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:02dd72d1d465 16 * See the License for the specific language governing permissions and
borlanic 0:02dd72d1d465 17 * limitations under the License.
borlanic 0:02dd72d1d465 18 */
borlanic 0:02dd72d1d465 19 #ifndef MBED_FLASH_API_H
borlanic 0:02dd72d1d465 20 #define MBED_FLASH_API_H
borlanic 0:02dd72d1d465 21
borlanic 0:02dd72d1d465 22 #include "device.h"
borlanic 0:02dd72d1d465 23 #include <stdint.h>
borlanic 0:02dd72d1d465 24
borlanic 0:02dd72d1d465 25 #if DEVICE_FLASH
borlanic 0:02dd72d1d465 26
borlanic 0:02dd72d1d465 27 #define MBED_FLASH_INVALID_SIZE 0xFFFFFFFF
borlanic 0:02dd72d1d465 28
borlanic 0:02dd72d1d465 29 typedef struct flash_s flash_t;
borlanic 0:02dd72d1d465 30
borlanic 0:02dd72d1d465 31 #if TARGET_FLASH_CMSIS_ALGO
borlanic 0:02dd72d1d465 32 #include "flash_data.h"
borlanic 0:02dd72d1d465 33 #endif
borlanic 0:02dd72d1d465 34
borlanic 0:02dd72d1d465 35 #ifdef __cplusplus
borlanic 0:02dd72d1d465 36 extern "C" {
borlanic 0:02dd72d1d465 37 #endif
borlanic 0:02dd72d1d465 38
borlanic 0:02dd72d1d465 39 /**
borlanic 0:02dd72d1d465 40 * \defgroup flash_hal Flash HAL API
borlanic 0:02dd72d1d465 41 * @{
borlanic 0:02dd72d1d465 42 */
borlanic 0:02dd72d1d465 43
borlanic 0:02dd72d1d465 44 /** Initialize the flash peripheral and the flash_t object
borlanic 0:02dd72d1d465 45 *
borlanic 0:02dd72d1d465 46 * @param obj The flash object
borlanic 0:02dd72d1d465 47 * @return 0 for success, -1 for error
borlanic 0:02dd72d1d465 48 */
borlanic 0:02dd72d1d465 49 int32_t flash_init(flash_t *obj);
borlanic 0:02dd72d1d465 50
borlanic 0:02dd72d1d465 51 /** Uninitialize the flash peripheral and the flash_t object
borlanic 0:02dd72d1d465 52 *
borlanic 0:02dd72d1d465 53 * @param obj The flash object
borlanic 0:02dd72d1d465 54 * @return 0 for success, -1 for error
borlanic 0:02dd72d1d465 55 */
borlanic 0:02dd72d1d465 56 int32_t flash_free(flash_t *obj);
borlanic 0:02dd72d1d465 57
borlanic 0:02dd72d1d465 58 /** Erase one sector starting at defined address
borlanic 0:02dd72d1d465 59 *
borlanic 0:02dd72d1d465 60 * The address should be at sector boundary. This function does not do any check for address alignments
borlanic 0:02dd72d1d465 61 * @param obj The flash object
borlanic 0:02dd72d1d465 62 * @param address The sector starting address
borlanic 0:02dd72d1d465 63 * @return 0 for success, -1 for error
borlanic 0:02dd72d1d465 64 */
borlanic 0:02dd72d1d465 65 int32_t flash_erase_sector(flash_t *obj, uint32_t address);
borlanic 0:02dd72d1d465 66
borlanic 0:02dd72d1d465 67 /** Read data starting at defined address
borlanic 0:02dd72d1d465 68 *
borlanic 0:02dd72d1d465 69 * This function has a WEAK implementation using memcpy for backwards compatibility.
borlanic 0:02dd72d1d465 70 * @param obj The flash object
borlanic 0:02dd72d1d465 71 * @param address Address to begin reading from
borlanic 0:02dd72d1d465 72 * @param data The buffer to read data into
borlanic 0:02dd72d1d465 73 * @param size The number of bytes to read
borlanic 0:02dd72d1d465 74 * @return 0 for success, -1 for error
borlanic 0:02dd72d1d465 75 */
borlanic 0:02dd72d1d465 76 int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size);
borlanic 0:02dd72d1d465 77
borlanic 0:02dd72d1d465 78 /** Program pages starting at defined address
borlanic 0:02dd72d1d465 79 *
borlanic 0:02dd72d1d465 80 * The pages should not cross multiple sectors.
borlanic 0:02dd72d1d465 81 * This function does not do any check for address alignments or if size is aligned to a page size.
borlanic 0:02dd72d1d465 82 * @param obj The flash object
borlanic 0:02dd72d1d465 83 * @param address The sector starting address
borlanic 0:02dd72d1d465 84 * @param data The data buffer to be programmed
borlanic 0:02dd72d1d465 85 * @param size The number of bytes to program
borlanic 0:02dd72d1d465 86 * @return 0 for success, -1 for error
borlanic 0:02dd72d1d465 87 */
borlanic 0:02dd72d1d465 88 int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size);
borlanic 0:02dd72d1d465 89
borlanic 0:02dd72d1d465 90 /** Get sector size
borlanic 0:02dd72d1d465 91 *
borlanic 0:02dd72d1d465 92 * @param obj The flash object
borlanic 0:02dd72d1d465 93 * @param address The sector starting address
borlanic 0:02dd72d1d465 94 * @return The size of a sector
borlanic 0:02dd72d1d465 95 */
borlanic 0:02dd72d1d465 96 uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address);
borlanic 0:02dd72d1d465 97
borlanic 0:02dd72d1d465 98 /** Get page size
borlanic 0:02dd72d1d465 99 *
borlanic 0:02dd72d1d465 100 * The page size defines the writable page size
borlanic 0:02dd72d1d465 101 * @param obj The flash object
borlanic 0:02dd72d1d465 102 * @return The size of a page
borlanic 0:02dd72d1d465 103 */
borlanic 0:02dd72d1d465 104 uint32_t flash_get_page_size(const flash_t *obj);
borlanic 0:02dd72d1d465 105
borlanic 0:02dd72d1d465 106 /** Get start address for the flash region
borlanic 0:02dd72d1d465 107 *
borlanic 0:02dd72d1d465 108 * @param obj The flash object
borlanic 0:02dd72d1d465 109 * @return The start address for the flash region
borlanic 0:02dd72d1d465 110 */
borlanic 0:02dd72d1d465 111 uint32_t flash_get_start_address(const flash_t *obj);
borlanic 0:02dd72d1d465 112
borlanic 0:02dd72d1d465 113 /** Get the flash region size
borlanic 0:02dd72d1d465 114 *
borlanic 0:02dd72d1d465 115 * @param obj The flash object
borlanic 0:02dd72d1d465 116 * @return The flash region size
borlanic 0:02dd72d1d465 117 */
borlanic 0:02dd72d1d465 118 uint32_t flash_get_size(const flash_t *obj);
borlanic 0:02dd72d1d465 119
borlanic 0:02dd72d1d465 120 /**@}*/
borlanic 0:02dd72d1d465 121
borlanic 0:02dd72d1d465 122 #ifdef __cplusplus
borlanic 0:02dd72d1d465 123 }
borlanic 0:02dd72d1d465 124 #endif
borlanic 0:02dd72d1d465 125
borlanic 0:02dd72d1d465 126 #endif
borlanic 0:02dd72d1d465 127
borlanic 0:02dd72d1d465 128 #endif
borlanic 0:02dd72d1d465 129
borlanic 0:02dd72d1d465 130 /** @}*/