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