Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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