BA / Mbed OS BaBoRo1
Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

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