1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup IotHardware 18 * @{ 19 * 20 * @brief Provides APIs for operating devices, 21 * including flash, GPIO, I2C, PWM, UART, and watchdog APIs. 22 * 23 * 24 * 25 * @since 2.2 26 * @version 2.2 27 */ 28 29 /** 30 * @file iot_flash.h 31 * 32 * @brief Declares flash functions. 33 * 34 * These functions are used to initialize or deinitialize a flash device, 35 * and read data from or write data to a flash memory. \n 36 * 37 * @since 2.2 38 * @version 2.2 39 */ 40 41 #ifndef IOT_FLASH_H 42 #define IOT_FLASH_H 43 44 /** 45 * @brief Reads data from a flash memory address. 46 * 47 * This function reads a specified length of data from a specified flash memory address. 48 * 49 * @param flashOffset Indicates the address of the flash memory from which data is to read. 50 * @param size Indicates the length of the data to read. 51 * @param ramData Indicates the pointer to the RAM for storing the read data. 52 * @return Returns {@link IOT_SUCCESS} if the data is read successfully; 53 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 54 * @since 2.2 55 * @version 2.2 56 */ 57 unsigned int IoTFlashRead(unsigned int flashOffset, unsigned int size, unsigned char *ramData); 58 59 /** 60 * @brief Writes data to a flash memory address. 61 * 62 * This function writes a specified length of data to a specified flash memory address. 63 * 64 * @param flashOffset Indicates the address of the flash memory to which data is to be written. 65 * @param size Indicates the length of the data to write. 66 * @param ramData Indicates the pointer to the RAM for storing the data to write. 67 * @param doErase Specifies whether to automatically erase existing data. 68 * @return Returns {@link IOT_SUCCESS} if the data is written successfully; 69 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 70 * @since 2.2 71 * @version 2.2 72 */ 73 unsigned int IoTFlashWrite(unsigned int flashOffset, unsigned int size, 74 const unsigned char *ramData, unsigned char doErase); 75 76 /** 77 * @brief Erases data in a specified flash memory address. 78 * 79 * @param flashOffset Indicates the flash memory address. 80 * @param size Indicates the data length in bytes. 81 * @return Returns {@link IOT_SUCCESS} if the data is erased successfully; 82 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 83 * @since 2.2 84 * @version 2.2 85 */ 86 unsigned int IoTFlashErase(unsigned int flashOffset, unsigned int size); 87 88 /** 89 * @brief Initializes a flash device. 90 * 91 * @return Returns {@link IOT_SUCCESS} if the flash device is initialized; 92 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 93 * @since 2.2 94 * @version 2.2 95 */ 96 unsigned int IoTFlashInit(void); 97 98 /** 99 * @brief Deinitializes a flash device. 100 * 101 * @return Returns {@link IOT_SUCCESS} if the flash device is deinitialized; 102 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 103 * @since 2.2 104 * @version 2.2 105 */ 106 unsigned int IoTFlashDeinit(void); 107 108 #endif // IOT_FLASH_H 109 /** @} */ 110