mbed library sources. Supersedes mbed-src.

Dependents:   BREAK_SENSOR_LED

Fork of mbed-dev by mbed official

Committer:
Kojto
Date:
Wed Jul 19 17:31:21 2017 +0100
Revision:
169:e3b6fe271b81
Parent:
160:d5399cc887bb
Child:
172:7d866c31b3c5
This updates the lib to the mbed lib v 147

Who changed what in which revision?

UserRevisionLine numberNew 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
Kojto 169:e3b6fe271b81 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
Kojto 169:e3b6fe271b81 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
Kojto 169:e3b6fe271b81 67 /** Read data starting at defined address
Kojto 169:e3b6fe271b81 68 *
Kojto 169:e3b6fe271b81 69 * This function has a WEAK implementation using memcpy for backwards compatibility.
Kojto 169:e3b6fe271b81 70 * @param obj The flash object
Kojto 169:e3b6fe271b81 71 * @param address Address to begin reading from
Kojto 169:e3b6fe271b81 72 * @param data The buffer to read data into
Kojto 169:e3b6fe271b81 73 * @param size The number of bytes to read
Kojto 169:e3b6fe271b81 74 * @return 0 for success, -1 for error
Kojto 169:e3b6fe271b81 75 */
Kojto 169:e3b6fe271b81 76 int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size);
Kojto 169:e3b6fe271b81 77
<> 160:d5399cc887bb 78 /** Program one page starting at defined address
Kojto 169:e3b6fe271b81 79 *
Kojto 169:e3b6fe271b81 80 * The page should be at page boundary, should not cross multiple sectors.
<> 160:d5399cc887bb 81 * This function does not do any check for address alignments or if size is aligned to a page size.
<> 160:d5399cc887bb 82 * @param obj The flash object
<> 160:d5399cc887bb 83 * @param address The sector starting address
<> 160:d5399cc887bb 84 * @param data The data buffer to be programmed
<> 160:d5399cc887bb 85 * @param size The number of bytes to program
<> 160:d5399cc887bb 86 * @return 0 for success, -1 for error
<> 160:d5399cc887bb 87 */
<> 160:d5399cc887bb 88 int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size);
<> 160:d5399cc887bb 89
<> 160:d5399cc887bb 90 /** Get sector size
Kojto 169:e3b6fe271b81 91 *
<> 160:d5399cc887bb 92 * @param obj The flash object
<> 160:d5399cc887bb 93 * @param address The sector starting address
<> 160:d5399cc887bb 94 * @return The size of a sector
<> 160:d5399cc887bb 95 */
<> 160:d5399cc887bb 96 uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address);
<> 160:d5399cc887bb 97
<> 160:d5399cc887bb 98 /** Get page size
Kojto 169:e3b6fe271b81 99 *
<> 160:d5399cc887bb 100 * @param obj The flash object
<> 160:d5399cc887bb 101 * @param address The page starting address
<> 160:d5399cc887bb 102 * @return The size of a page
<> 160:d5399cc887bb 103 */
<> 160:d5399cc887bb 104 uint32_t flash_get_page_size(const flash_t *obj);
<> 160:d5399cc887bb 105
<> 160:d5399cc887bb 106 /** Get start address for the flash region
Kojto 169:e3b6fe271b81 107 *
<> 160:d5399cc887bb 108 * @param obj The flash object
<> 160:d5399cc887bb 109 * @return The start address for the flash region
<> 160:d5399cc887bb 110 */
<> 160:d5399cc887bb 111 uint32_t flash_get_start_address(const flash_t *obj);
<> 160:d5399cc887bb 112
<> 160:d5399cc887bb 113 /** Get the flash region size
Kojto 169:e3b6fe271b81 114 *
<> 160:d5399cc887bb 115 * @param obj The flash object
<> 160:d5399cc887bb 116 * @return The flash region size
<> 160:d5399cc887bb 117 */
<> 160:d5399cc887bb 118 uint32_t flash_get_size(const flash_t *obj);
<> 160:d5399cc887bb 119
<> 160:d5399cc887bb 120 /**@}*/
<> 160:d5399cc887bb 121
<> 160:d5399cc887bb 122 #ifdef __cplusplus
<> 160:d5399cc887bb 123 }
<> 160:d5399cc887bb 124 #endif
<> 160:d5399cc887bb 125
<> 160:d5399cc887bb 126 #endif
<> 160:d5399cc887bb 127
<> 160:d5399cc887bb 128 #endif
<> 160:d5399cc887bb 129
<> 160:d5399cc887bb 130 /** @}*/