113 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			113 lines
		
	
	
		
			3.5 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_COMMON_H
 | |
| #define __IOT_BSRM_COMMON_H
 | |
| 
 | |
| /* os shim includes */
 | |
| #include "os_types_api.h"
 | |
| 
 | |
| /* iot common header files */
 | |
| #include "iot_config_api.h"
 | |
| #include "iot_rtc_api.h"
 | |
| #include "iot_io_api.h"
 | |
| #include "iot_pkt_api.h"
 | |
| #include "iot_bsrm_fr.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #if IOT_BSRM_MODE
 | |
| 
 | |
| #define iot_bsrm_printf iot_printf
 | |
| 
 | |
| /* load hw tsfm mode encode frequncy. unit: 0.01Hz */
 | |
| #define IOT_BSRM_BRANCH_LOAD_FREQ_DEF       (83333)
 | |
| 
 | |
| /* define branch detect identification code max len */
 | |
| #define IOT_BSRM_BRANCH_ID_CODE_MAX         16
 | |
| 
 | |
| #pragma pack(push)  /* save the pack status */
 | |
| #pragma pack(1)     /* 1 byte align */
 | |
| 
 | |
| /* branch revceive paramter */
 | |
| typedef struct _iot_bsrm_br_param {
 | |
|     /* load hw tsfm mode encode frequncy. unit: 0.01Hz */
 | |
|     uint32_t fc;
 | |
|     /* characteristics data per bit duration time, unit: 1ms */
 | |
|     uint16_t chara_bit_dur;
 | |
|     /* modulate pulse signal high duration time, unit: 1us */
 | |
|     uint16_t pulse_high_dur;
 | |
|     /* modulate pulse signal low duration time, unit: 1us */
 | |
|     uint16_t pulse_low_dur;
 | |
|     /* branch receive identification code len */
 | |
|     uint8_t id_code_len;
 | |
|     /* branch receive identification code */
 | |
|     uint8_t id_code[IOT_BSRM_BRANCH_ID_CODE_MAX];
 | |
| } iot_bsrm_br_param_t;
 | |
| 
 | |
| #pragma pack(pop)
 | |
| 
 | |
| /**
 | |
|  * @brief iot_bsrm_data_print() - print data, format is hex.
 | |
|  * @param str:    a short string to be printed before data
 | |
|  * @param buf:    buffer contain data to be printed
 | |
|  * @param len:    length of data in the buffer
 | |
|  */
 | |
| void iot_bsrm_data_print(const char* str, uint8_t* buf, uint32_t len);
 | |
| 
 | |
| 
 | |
| /**
 | |
|  * @brief iot_bsrm_time_to_rtctime() - convert integer timestamp to RTC time.
 | |
|  * @param time:  integer timestamp relative to 1970-1-1 00:00:00
 | |
|  * @param tm:    return RTC time
 | |
|  */
 | |
| void iot_bsrm_time_to_rtctime(uint32_t time, iot_time_tm_t *tm);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_bsrm_rtctime_to_time() - convert RTC time to integer timestamp.
 | |
|  * @param tm:  pointer to the rtc time
 | |
|  * @retval: integer timestamp relative to 1970-1-1 00:00:00
 | |
|  */
 | |
| uint32_t iot_bsrm_rtctime_to_time(iot_time_tm_t *tm);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_bsrm_uart_send() - send uart data.
 | |
|  * @param pkt:  pointer to pkt data.
 | |
|  */
 | |
| void iot_bsrm_uart_send(iot_pkt_t *pkt);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_bsrm_set_pm_upgrade_guard_code() - set upgrade pm guard code.
 | |
|  * @param guard_code: upgrade pm guard code.
 | |
|  * @retval: ERR_OK - renew flash upgrade guard code,
 | |
|  *                   other - don't renew flasg guard code.
 | |
|  */
 | |
| uint32_t iot_bsrm_set_pm_upgrade_guard_code(uint16_t guard_code);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_bsrm_get_pm_upgrade_guard_code() - get upgrade pm guard code.
 | |
|  * @param upgrade pm guard code.
 | |
|  */
 | |
| uint16_t iot_bsrm_get_pm_upgrade_guard_code();
 | |
| 
 | |
| #endif /* IOT_BSRM_MODE */
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif  /* IOT_BSRM_COMMON_H */
 |