207 lines
7.7 KiB
C
207 lines
7.7 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_BRM_FLASH_H
|
|
#define IOT_BRM_FLASH_H
|
|
|
|
/* os shim includes */
|
|
#include "os_types_api.h"
|
|
|
|
/* iot common header files */
|
|
#include "iot_config_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*----------------------------------------
|
|
* brm flash layout shows like below
|
|
*----------------------------------------
|
|
* |-----------------------------|
|
|
* | |
|
|
* | reserve for sg app | 256k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | non-volatile data region | 32k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | frozen recording region | 54k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | reserve1 | 10k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | curve recording region | 370k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | misc recording region | 40k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | event recording region |
|
|
* | 1.qiedian - 4096 bytes |
|
|
* | 2.meter change - 4096 bytes |
|
|
* | 3.power down - 4096 bytes | 128k bytes
|
|
* | 4.phase A uv - 4096 bytes |
|
|
* | 5.phase B uv - 4096 bytes |
|
|
* | 6.phase C uv - 4096 bytes |
|
|
* | 7.phase A ov - 4096 bytes |
|
|
* | 8.phase B ov - 4096 bytes |
|
|
* | 9.phase C ov - 4096 bytes |
|
|
* | 10.phase A pf - 4096 bytes |
|
|
* | 11.phase B pf - 4096 bytes |
|
|
* | 12.phase C pf - 4096 bytes |
|
|
* | 13.phase A oc - 4096 bytes |
|
|
* | 14.phase B oc - 4096 bytes |
|
|
* | 15.phase C oc - 4096 bytes |
|
|
* | 16.unbalance v - 4096 bytes |
|
|
* | total use 65536 bytes |
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | reserve2 | 32k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | stat_region |
|
|
* | 1.day stat - 7680 bytes | 16k bytes
|
|
* | total use 7680 bytes |
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | debug info region | 18k bytes
|
|
* | 1.tsfm debug info - 4096 |
|
|
* | 2. todo |
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* |branch info recording region | 64k bytes
|
|
* | |
|
|
* | |
|
|
* | |
|
|
* |-----------------------------|
|
|
* | |
|
|
* | reserve3 | 4k bytes
|
|
* | |
|
|
* |-----------------------------|
|
|
*/
|
|
|
|
/* define the start, size, and end of sg app region */
|
|
#define IOT_BRM_SG_REGION_START 0x00
|
|
#define IOT_BRM_SG_REGION_SIZE (256 * 1024)
|
|
#define IOT_BRM_SG_REGION_END \
|
|
IOT_BRM_SG_REGION_START + IOT_BRM_SG_REGION_SIZE
|
|
|
|
/* define the start, size, and end of non-volatile data region */
|
|
#define IOT_BRM_NV_REGION_START IOT_BRM_SG_REGION_END
|
|
#define IOT_BRM_NV_REGION_SIZE (32 * 1024)
|
|
#define IOT_BRM_NV_REGION_END \
|
|
IOT_BRM_NV_REGION_START + IOT_BRM_NV_REGION_SIZE
|
|
|
|
/* define the start, size, and end of frozen recording region */
|
|
#define IOT_BRM_FROZEN_REGION_START IOT_BRM_NV_REGION_END
|
|
#define IOT_BRM_FROZEN_REGION_SIZE (54 *1024)
|
|
#define IOT_BRM_FROZEN_REGION_END \
|
|
IOT_BRM_FROZEN_REGION_START + IOT_BRM_FROZEN_REGION_SIZE
|
|
|
|
#define IOT_BRM_RESERVE_SIZE1 (10 * 1024)
|
|
|
|
/* define the start, size, and end of curve recording region */
|
|
#define IOT_BRM_CURVE_REGION_START \
|
|
IOT_BRM_FROZEN_REGION_END + IOT_BRM_RESERVE_SIZE1
|
|
#define IOT_BRM_CURVE_REGION_SIZE (370 *1024)
|
|
#define IOT_BRM_CURVE_REGION_END \
|
|
IOT_BRM_CURVE_REGION_START + IOT_BRM_CURVE_REGION_SIZE
|
|
|
|
/* define the start, size, and end of miscellaneous recording region */
|
|
#define IOT_BRM_MISC_REC_REGION_START IOT_BRM_CURVE_REGION_END
|
|
#define IOT_BRM_MISC_REC_REGION_SIZE (40 * 1024)
|
|
#define IOT_BRM_MISC_REC_REGION_END \
|
|
IOT_BRM_MISC_REC_REGION_START + IOT_BRM_MISC_REC_REGION_SIZE
|
|
|
|
/* define the start, size, and end of evt recording region */
|
|
#define IOT_BRM_EVT_REGION_START IOT_BRM_MISC_REC_REGION_END
|
|
#define IOT_BRM_EVT_REGION_SIZE (128 *1024)
|
|
#define IOT_BRM_EVT_REGION_END \
|
|
IOT_BRM_EVT_REGION_START + IOT_BRM_EVT_REGION_SIZE
|
|
|
|
#define IOT_BRM_RESERVE_SIZE2 (32 * 1024)
|
|
|
|
/* define the start, size, and end of stat recording region */
|
|
#define IOT_BRM_STAT_REC_REGION_START \
|
|
IOT_BRM_EVT_REGION_END + IOT_BRM_RESERVE_SIZE2
|
|
#define IOT_BRM_STAT_REC_REGION_SIZE (16 * 1024)
|
|
#define IOT_BRM_STAT_REC_REGION_END \
|
|
(IOT_BRM_STAT_REC_REGION_START + IOT_BRM_STAT_REC_REGION_SIZE)
|
|
|
|
/* define the start, size, and end of debug recording region */
|
|
#define IOT_BRM_DBG_REC_REGION_START IOT_BRM_STAT_REC_REGION_END
|
|
#define IOT_BRM_DBG_REC_REGION_SIZE (18 * 1024)
|
|
#define IOT_BRM_DBG_REC_REGION_END \
|
|
(IOT_BRM_DBG_REC_REGION_START + IOT_BRM_DBG_REC_REGION_SIZE)
|
|
|
|
/* define the start, size, and end of information recode region */
|
|
#define IOT_BRM_BR_RECV_REGION_START IOT_BRM_DBG_REC_REGION_END
|
|
#define IOT_BRM_BR_RECV_REGION_SIZE (64 * 1024)
|
|
#define IOT_BRM_BR_RECV_REGION_END \
|
|
IOT_BRM_BR_RECV_REGION_START + IOT_BRM_BR_RECV_REGION_SIZE
|
|
|
|
#define IOT_BRM_RESERVE_SIZE3 (4 * 1024)
|
|
|
|
#if (IOT_BRM_ENABLE && PLC_SUPPORT_STA_ROLE)
|
|
|
|
/**
|
|
* @brief: iot_brm_flash_init() - initialization flash.
|
|
* @retval: ERR_OK - success, otherwise - see eeeor code.
|
|
*/
|
|
uint8_t iot_brm_flash_init(void);
|
|
|
|
/**
|
|
* @brief: iot_brm_flash_deinit() - deinitialization flash.
|
|
*/
|
|
void iot_brm_flash_deinit(void);
|
|
|
|
/**
|
|
* @brief: iot_brm_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_brm_flash_read(uint32_t pos, uint8_t *buf,
|
|
uint32_t cnt);
|
|
|
|
/**
|
|
* @brief: iot_brm_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_brm_flash_write(uint32_t pos, uint8_t *buf,
|
|
uint32_t cnt);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_BRM_ENABLE && PLC_SUPPORT_STA_ROLE */
|
|
|
|
#endif /* IOT_BRM_FLASH_H */
|