Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

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 #define ARM_UC_FLASH_INVALID_SIZE 0xFFFFFFFF
00034 
00035 /** Initialize a flash IAP device
00036  *
00037  *  Should be called once per lifetime of the object.
00038  *  @return 0 on success or a negative error code on failure
00039  */
00040 int32_t arm_uc_flashiap_init(void);
00041 
00042 /** Erase sectors
00043  *
00044  *  The state of an erased sector is undefined until it has been programmed
00045  *
00046  *  @param address  Address of a sector to begin erasing, must be a multiple of the sector size
00047  *  @param size     Size to erase in bytes, must be a multiple of the sector size
00048  *  @return         0 on success, negative error code on failure
00049  */
00050 int32_t arm_uc_flashiap_erase(uint32_t address, uint32_t size);
00051 
00052 /** Program data to pages
00053  *
00054  *  The sectors must have been erased prior to being programmed
00055  *
00056  *  @param buffer   Buffer of data to be written
00057  *  @param address  Address of a page to begin writing to, must be a multiple of program and sector sizes
00058  *  @param size     Size to write in bytes, must be a multiple of program and sector sizes
00059  *  @return         0 on success, negative error code on failure
00060  */
00061 int32_t arm_uc_flashiap_program(const uint8_t* buffer,
00062                                 uint32_t address,
00063                                 uint32_t size);
00064 
00065 /** Read data from a flash device.
00066  *
00067  *  This method invokes memcpy - reads number of bytes from the address
00068  *
00069  *  @param buffer   Buffer to write to
00070  *  @param address  Flash address to begin reading from
00071  *  @param size     Size to read in bytes
00072  *  @return         0 on success, negative error code on failure
00073  */
00074 int32_t arm_uc_flashiap_read(uint8_t* buffer,
00075                              uint32_t address,
00076                              uint32_t size);
00077 
00078 /** Get the program page size
00079  *
00080  *  @return Size of a program page in bytes
00081  */
00082 uint32_t arm_uc_flashiap_get_page_size(void);
00083 
00084 /** Get the sector size at the defined address
00085  *
00086  *  Sector size might differ at address ranges.
00087  *  An example <0-0x1000, sector size=1024; 0x10000-0x20000, size=2048>
00088  *
00089  *  @param address  Address of or inside the sector to query
00090  *  @return         Size of a sector in bytes
00091  */
00092 uint32_t arm_uc_flashiap_get_sector_size(uint32_t address);
00093 
00094 /** Get the flash size
00095  *
00096  *  @return         Size of the flash in bytes
00097  */
00098 uint32_t arm_uc_flashiap_get_flash_size(void);
00099 
00100 
00101 /** Get the flash start address
00102  *
00103  *  @return         Start address of the flash
00104  */
00105 uint32_t arm_uc_flashiap_get_flash_start(void);
00106 #ifdef __cplusplus
00107 }
00108 #endif
00109 
00110 #endif