Files
kunlun/export/inc/bsp/iot_ext_flash_api.h
2024-09-28 14:24:04 +08:00

155 lines
5.4 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef IOT_EXT_FLASH_DATA_H
#define IOT_EXT_FLASH_DATA_H
#ifdef __cplusplus
extern "C" {
#endif
/* first falsh device fd. */
#define EXT_FLASH_DEV0 0
/* ******************** Flash export API ********************** */
/**
* @brief custom_ext_dev_resize() - config custom extern flash part layout
*
* @param offset the offset address
* @param size the flash port max size
* @return 0 means successful, 1 means failed
*/
int32_t custom_ext_dev_resize(uint32_t offset, uint32_t size);
/**
* @brief custom_ext_dev_query_offset() - query custom extern flash chip offset
* @param fd: custom extern flash device fd.
* @return the built-in flash address.
*/
int32_t custom_ext_dev_query_offset(int32_t fd);
/**
* @brief custom_ext_dev_query_rw_size() - query custom extern flash chip size
* @param fd: custom extern flash device fd.
* @return the built-in flash size allocated for customer
* application use
*
*/
int32_t custom_ext_dev_query_rw_size(int32_t fd);
/**
* @brief custom_ext_dev_open() - open custom extern flash part
* @param id: custom extern flash device fd.
* @return -1 -- open custom flash part failed
* @return other -- open custom flash part successfully
*
*/
int32_t custom_ext_dev_open(uint8_t id);
/**
* @brief custom_ext_dev_close() - close custom extern flash part
* @param fd: custom extern flash device fd.
*
* @return -1 -- close custom flash part failed
* @return 0 -- close custom flash part successfully
*
*/
int32_t custom_ext_dev_close(int32_t fd);
/**
* @brief custom_ext_dev_seek() - set the position indicator for the file pointed
* @param fd: custom extern flash device fd.
* @param offset: the new position specified by fromwhere,
* "offset" is below the built-in flash size
* @param fromwhere: it is set to DEV_SEEK_SET, DEV_SEEK, CUR DEV_SEEK_END,
* and it means the start, the current, the end of part
*
* @return -1 -- set custom flash part position failed
* @return other -- the new position set
*
*/
int32_t custom_ext_dev_seek(int32_t fd, uint32_t offset, uint8_t fromwhere);
/**
* @brief custom_ext_dev_erase() - erase falsh.
* @param fd: custom extern flash device fd.
* @param offset: start address of the erase data.
* @param count: bytes to erase.
*
* @return -1 -- erase falsh failed.
* @return other -- erase falsh ok.
*
*/
int32_t custom_ext_dev_erase(int32_t fd, uint32_t offset, size_t count);
/**
* @brief custom_ext_dev_read() - read custom extern flash part data
* @param fd: custom extern flash device fd.
* @param buf: store the data at the location
* @param count: the size of data to read
* "count" is below the built-in flash size
*
* @return -1 -- read custom flash part data failed
* @return other -- return the read size
*
*/
int32_t custom_ext_dev_read(int32_t fd, void* buf, size_t count);
/**
* @brief custom_ext_dev_write() - write custom extern flash part data
* @param fd: custom extern flash device fd.
* @param buf: the pointer of data to be written
* @param count: the size of data to be written
* "count" is below the built-in flash size
*
* @return -1 -- write custom flash part data failed
* @return other -- return the written size
*
*/
int32_t custom_ext_dev_write(int32_t fd, void*buf, size_t count);
/**
* @brief custom_ext_dev_get_size_of_erase_once() - get once erase operation size
* @param fd: custom extern flash device fd.
*
* @return -1 -- write custom flash part data failed
* @return other -- return the erase operation size
*
*/
int32_t custom_ext_dev_get_size_of_erase_once(int32_t fd);
/**
* @brief custom_ext_dev_write_without_erase() - write custom extern flash part
* data without erase.
* @param fd: custom extern flash device fd.
* @param buf: the pointer of data to be written
* @param count: the size of data to be written
* "count" is below the built-in flash size
*
* @return -1 -- write custom flash part data failed
* @return other -- return the written size
*
*/
int32_t custom_ext_dev_write_without_erase(int32_t fd, void*buf,
size_t count);
#ifdef __cplusplus
}
#endif
#endif