/**************************************************************************** Copyright(c) 2024 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_SUNSOLAR_FLASH_H #define IOT_SUNSOLAR_FLASH_H /* os shim includes */ #include "os_types_api.h" #ifdef __cplusplus extern "C" { #endif /* custom flash total size */ #define IOT_SOLR_FLASH_TOTAL_SIZE custom_dev_query_rw_size() /* custom flash start position */ #define IOT_SOLR_FLASH_START_ADDR 0x00 /* define the size of flash erase unit: 4096 Byte */ #define IOT_SOLR_FLASH_ERASE_SIZE_4K (0x1000) /*------------------------------------------- * sta custom flash layout shows like below *------------------------------------------- * |-----------------------------| * | | * | non-volatile data region | 16k bytes * | | * |-----------------------------| * | | * | frozen data region | 68k bytes * | | * |-----------------------------| * | | * | reserve | 36k bytes * | | * |-----------------------------| */ #define IOT_SOLR_STA_NV_REGION_START IOT_SOLR_FLASH_START_ADDR #define IOT_SOLR_STA_NV_REGION_SIZE (16 * 1024) #define IOT_SOLR_STA_NV_REGION_END \ (IOT_SOLR_STA_NV_REGION_START + IOT_SOLR_STA_NV_REGION_SIZE) #define IOT_SOLR_STA_FROZEN_REGION_START IOT_SOLR_STA_NV_REGION_END #define IOT_SOLR_STA_FROZEN_REGION_SIZE (68 * 1024) #define IOT_SOLR_STA_FROZEN_REGION_END \ (IOT_SOLR_STA_FROZEN_REGION_START + IOT_SOLR_STA_FROZEN_REGION_SIZE) /** * @brief iot_sunsolar_flash_read - read data from customer flash area. * @param read_offset: read data offset. * @param read_len: length of read data. * @param p_read_buf: the pointer to read data cache. * @retval: ERR_OK - for success case. * @retval: otherwise - error code. */ uint32_t iot_sunsolar_flash_read(uint32_t read_offset, uint32_t read_len, void *p_read_buf); /** * @brief iot_sunsolar_flash_write - write data into customer flash area. * @param write_offset: write data offset. * @param write_len: length of write data. * @param p_write_buf: the pointer to write data. * @retval: ERR_OK - for success case. * @retval: otherwise - error code. */ uint32_t iot_sunsolar_flash_write(uint32_t write_offset, uint32_t write_len, void *p_write_buf); /** * @brief iot_sunsolar_flash_erase - erase customer flash area. * @param erase_offset: erase offset. * @param erase_len: length of erase data. * @retval: ERR_OK - for success case. * @retval: otherwise - error code. */ uint32_t iot_sunsolar_flash_erase(uint32_t erase_offset, uint32_t erase_len); /** * @brief iot_sunsolar_flash_write - write data into customer flash area without * erase. * @param write_offset: write data offset. * @param write_len: length of write data. * @param p_write_buf: the pointer to write data. * @retval: ERR_OK - for success case. * @retval: otherwise - error code. */ uint32_t iot_sunsolar_flash_write_without_erase(uint32_t write_offset, uint32_t write_len, uint8_t *p_write_buf); /** * @brief iot_sunsolar_flash_data_erase_check - erase check for the data to be * writen. * @param offset: write data offset. * @param data_len: length of write data. * @retval: ERR_OK - for success case, already erased. * @retval: otherwise - error code. */ uint32_t iot_sunsolar_flash_data_erase_check(uint32_t offset, uint32_t data_len); /** * @brief iot_sunsolar_flash_data_erase_handle - check if sector is need to * erase, if so, erase it * @param write_offset: write data offset. * @param write_len: length of write data. * @param p_write_buf: the pointer to write data. * @retval: ERR_OK - for success case. * @retval: otherwise - error code. */ uint32_t iot_sunsolar_flash_data_erase_handle(uint32_t offset, uint32_t data_len); /** * @brief iot_sunsolar_flash_init() - init sunsolar flash. * @return: 0 - for success case * @return: otherwise - error number */ uint32_t iot_sunsolar_flash_init(void); /** * @brief iot_sunsolar_flash_deinit() - deinit sunsolar flash. */ void iot_sunsolar_flash_deinit(void); #ifdef __cplusplus } #endif #endif /* IOT_SUNSOLAR_FLASH_H */