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