99 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			99 lines
		
	
	
		
			2.9 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_NV_H
 | ||
|  | #define IOT_BSRM_NV_H
 | ||
|  | 
 | ||
|  | /* os shim includes */ | ||
|  | #include "os_types_api.h"
 | ||
|  | 
 | ||
|  | /* iot common header files */ | ||
|  | #include "iot_config_api.h"
 | ||
|  | #include "iot_bsrm_common.h"
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | extern "C" { | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #if IOT_BSRM_MODE
 | ||
|  | 
 | ||
|  | /* non-volatile section ID */ | ||
|  | typedef enum { | ||
|  |     iot_bsrm_nv_id_param, | ||
|  |     iot_bsrm_nv_id_info, | ||
|  | } iot_bsrm_nv_id_t; | ||
|  | 
 | ||
|  | #pragma pack(push)  /* save the pack status */
 | ||
|  | #pragma pack(1)     /* 1 byte align */
 | ||
|  | 
 | ||
|  | 
 | ||
|  | /* parameter layout */ | ||
|  | typedef struct _iot_bsrm_nv_param { | ||
|  |     /* absolute threshold */ | ||
|  |     float tiabs; | ||
|  |     /* relative threshold */ | ||
|  |     float ticps; | ||
|  |     /* fundamental threshold */ | ||
|  |     float tibcs; | ||
|  |     /* characteristic signal similarity */ | ||
|  |     uint8_t similarity; | ||
|  |     /* current ratio coefficient unit: 0.0001 */ | ||
|  |     uint32_t i_coeff; | ||
|  |     /* branch receive parameter */ | ||
|  |     iot_bsrm_br_param_t br_param; | ||
|  |     /* branch receive extend data, reserve for future */ | ||
|  |     uint8_t br_param_rsvd[32]; | ||
|  |     /* upgrade pm guard code, 0xaa55 - upgrade pm, other - don't upgrade */ | ||
|  |     uint16_t upgrade_pm_guard_code; | ||
|  |     /* reserved */ | ||
|  |     uint8_t reserv[433]; | ||
|  | } iot_bsrm_nv_param_t; | ||
|  | 
 | ||
|  | /* node information list layout */ | ||
|  | typedef struct _iot_bsrm_nv_info { | ||
|  |     /* event occurrence counter */ | ||
|  |     uint32_t evt_occur_cnt; | ||
|  |     /* payload */ | ||
|  |     uint8_t reserved[244]; | ||
|  | } iot_bsrm_nv_info_t; | ||
|  | 
 | ||
|  | #pragma pack(pop)
 | ||
|  | /**
 | ||
|  |  * @brief iot_bsrm_nv_init() - initialization of non-volatile regions | ||
|  |  * @retval: ERR_OK - successfully, otherwise - error code | ||
|  |  */ | ||
|  | uint32_t iot_bsrm_nv_init(void); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief iot_bsrm_nv_get_section() -  gets the buffer pointer for the | ||
|  |  *        specified section | ||
|  |  * @param id: seticon id, see iot_bsrm_nv_id_t | ||
|  |  * @retval: buffer pointer for the specified section | ||
|  |  */ | ||
|  | void *iot_bsrm_nv_get_section(iot_bsrm_nv_id_t id); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief iot_bsrm_nv_update_section() - update the specified seticon to | ||
|  |  *        non-volatile storage | ||
|  |  * @param id: seticon id, see iot_bsrm_nv_id_t | ||
|  |  */ | ||
|  | void iot_bsrm_nv_update_section(iot_bsrm_nv_id_t id); | ||
|  | 
 | ||
|  | #endif /* IOT_BSRM_MODE */
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | } | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #endif /* IOT_BSRM_NV_H */
 |