Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_uc_pal_flashiap_platform.h Source File

arm_uc_pal_flashiap_platform.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #ifndef ARM_UC_PAL_FLASHIAP_PLATFORM_H
00020 #define ARM_UC_PAL_FLASHIAP_PLATFORM_H
00021 
00022 #include <stdint.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 enum {
00029     ARM_UC_FLASHIAP_SUCCESS = 0,
00030     ARM_UC_FLASHIAP_FAIL    = -1
00031 };
00032 
00033 /** Initialize a flash IAP device
00034  *
00035  *  Should be called once per lifetime of the object.
00036  *  @return 0 on success or a negative error code on failure
00037  */
00038 int32_t arm_uc_flashiap_init();
00039 
00040 /** Erase sectors
00041  *
00042  *  The state of an erased sector is undefined until it has been programmed
00043  *
00044  *  @param address  Address of a sector to begin erasing, must be a multiple of the sector size
00045  *  @param size     Size to erase in bytes, must be a multiple of the sector size
00046  *  @return         0 on success, negative error code on failure
00047  */
00048 int32_t arm_uc_flashiap_erase(uint32_t address, uint32_t size);
00049 
00050 /** Program data to pages
00051  *
00052  *  The sectors must have been erased prior to being programmed
00053  *
00054  *  @param buffer   Buffer of data to be written
00055  *  @param address  Address of a page to begin writing to, must be a multiple of program and sector sizes
00056  *  @param size     Size to write in bytes, must be a multiple of program and sector sizes
00057  *  @return         0 on success, negative error code on failure
00058  */
00059 int32_t arm_uc_flashiap_program(const uint8_t* buffer,
00060                                 uint32_t address,
00061                                 uint32_t size);
00062 
00063 /** Read data from a flash device.
00064  *
00065  *  This method invokes memcpy - reads number of bytes from the address
00066  *
00067  *  @param buffer   Buffer to write to
00068  *  @param address  Flash address to begin reading from
00069  *  @param size     Size to read in bytes
00070  *  @return         0 on success, negative error code on failure
00071  */
00072 int32_t arm_uc_flashiap_read(uint8_t* buffer,
00073                              uint32_t address,
00074                              uint32_t size);
00075 
00076 /** Get the program page size
00077  *
00078  *  @return Size of a program page in bytes
00079  */
00080 uint32_t arm_uc_flashiap_get_page_size(void);
00081 
00082 /** Get the sector size at the defined address
00083  *
00084  *  Sector size might differ at address ranges.
00085  *  An example <0-0x1000, sector size=1024; 0x10000-0x20000, size=2048>
00086  *
00087  *  @param address  Address of or inside the sector to query
00088  *  @return         Size of a sector in bytes
00089  */
00090 uint32_t arm_uc_flashiap_get_sector_size(uint32_t address);
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #endif