Files
kunlun/app/bsrm/iot_bsrm_flash.h
2024-09-28 14:24:04 +08:00

125 lines
4.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_BSRM_FLASH_H
#define __IOT_BSRM_FLASH_H
/* os shim includes */
#include "os_types_api.h"
/* iot common header files */
#include "iot_config_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------
* bsrm flash layout shows like below
*----------------------------------------
* |------------------------------|
* | |
* | non-volatile data | 4k bytes
* | |
* |------------------------------|
* | |
* | branch info recording region | 256k bytes
* | |
* |------------------------------|
* | |
* | reserved | 32k bytes
* | |
* |------------------------------|
* | |
* | branch event region | 256k bytes
* | |
* |------------------------------|
*/
#if (IOT_BSRM_MODE == IOT_BSRM_MODE_CUS_APP)
/* define the start, size, and end of sg app region */
#define IOT_BSRM_SG_REGION_START 0x00
#define IOT_BSRM_SG_REGION_SIZE (256 * 1024)
#define IOT_BSRM_SG_REGION_END \
IOT_BSRM_SG_REGION_START + IOT_BSRM_SG_REGION_SIZE
#else
#define IOT_BSRM_SG_REGION_END 0
#endif
/* define the start, size, and end of non-volatile data region */
#define IOT_BSRM_NV_REGION_START IOT_BSRM_SG_REGION_END
#define IOT_BSRM_NV_REGION_SIZE (4 * 1024)
#define IOT_BSRM_NV_REGION_END \
IOT_BSRM_NV_REGION_START + IOT_BSRM_NV_REGION_SIZE
/* define the start, size, and end of information recode region */
#define IOT_BSRM_INFO_REC_REGION_START IOT_BSRM_NV_REGION_END
#define IOT_BSRM_INFO_REC_REGION_SIZE (256 * 1024)
#define IOT_BSRM_INFO_REC_REGION_END \
IOT_BSRM_INFO_REC_REGION_START + IOT_BSRM_INFO_REC_REGION_SIZE
/* reserved */
#define IOT_BSRM_RESERVED_REGION_START IOT_BSRM_INFO_REC_REGION_END
#define IOT_BSRM_RESERVED_REGION_SIZE (32 * 1024)
#define IOT_BSRM_RESERVED_REGION_END \
IOT_BSRM_RESERVED_REGION_START + IOT_BSRM_RESERVED_REGION_SIZE
/* define the start, size, and end of information recode region */
#define IOT_BSRM_BRANCH_EVT_REGION_START IOT_BSRM_RESERVED_REGION_END
#define IOT_BSRM_BRANCH_EVT_REGION_SIZE (256 * 1024)
#define IOT_BSRM_BRANCH_EVT_REGION_END \
IOT_BSRM_BRANCH_EVT_REGION_START + IOT_BSRM_BRANCH_EVT_REGION_SIZE
#if IOT_BSRM_MODE
/**
* @brief: iot_bsrm_flash_init() - initialization flash.
* @retval: ERR_OK - success, otherwise - see eeeor code.
*/
uint8_t iot_bsrm_flash_init(void);
/**
* @brief: iot_bsrm_flash_deinit() - deinitialization flash.
*/
void iot_bsrm_flash_deinit(void);
/**
* @brief: iot_bsrm_flash_read() - read data from flash.
* @param pos: the starting position of reading.
* @param buf: data buffer used to return read data.
* @param cnt: number of data to be read, uint is byte.
* @retval: ERR_OK - success, otherwise - see eeeor code.
*/
uint8_t iot_bsrm_flash_read(uint32_t pos, uint8_t *buf,
uint32_t cnt);
/**
* @brief: iot_bsrm_flash_write() - write data to flash.
* @param pos: the starting position of write.
* @param buf: pointer to the data buffer to be written.
* @param cnt: number of data to be written, uint is byte.
* @retval: ERR_OK - success, otherwise - see eeeor code.
*/
uint8_t iot_bsrm_flash_write(uint32_t pos, uint8_t *buf,
uint32_t cnt);
#endif /* IOT_BSRM_MODE */
#ifdef __cplusplus
}
#endif
#endif /* __IOT_BSRM_FLASH_H */