112 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			112 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 _PHY_PPM_H_
							 | 
						||
| 
								 | 
							
								#define _PHY_PPM_H_
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_config.h"
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								#include "iot_errno_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* constans *******************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* nn_ppm function's nid/ppm reg group max, 0~7 */
							 | 
						||
| 
								 | 
							
								#define PHY_SW_NN_PPM_PARA_MAX          (8)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* base on PPM calculation nn_phase_adj.
							 | 
						||
| 
								 | 
							
								 * nn_ppm: neighbor network ppm;
							 | 
						||
| 
								 | 
							
								 * my_ppm: myself hw ppm
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define PHY_PPM_TO_NN_PHASE_ADJ(nn_ppm, self_ppm) \
							 | 
						||
| 
								 | 
							
								    (((1374 + 3072) * 12 * (nn_ppm - self_ppm)) / (1 << 10))
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(push)
							 | 
						||
| 
								 | 
							
								#pragma pack(1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* typdefs ********************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* functions ******************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_set_sw_nn_tx_ppm_en - enable sw tx nn ppm function
							 | 
						||
| 
								 | 
							
								 * @enable      0: disable; others: enable
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void phy_set_sw_nn_tx_ppm_en(uint8_t enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_get_sw_nn_tx_ppm_en - get sw tx nn ppm function enable status
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      0: disable; others: enable
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_sw_nn_tx_ppm_en(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_set_sw_nn_rx_ppm_en - enable sw rx nn ppm function
							 | 
						||
| 
								 | 
							
								 * @enable      0: disable; others: enable
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void phy_set_sw_nn_rx_ppm_en(uint8_t enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_get_sw_nn_rx_ppm_en - get sw rx nn ppm function enable status
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      0: disable; others: enable
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_sw_nn_rx_ppm_en(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_set_sw_nn_ppm_para - set sw nn ppm function parameters
							 | 
						||
| 
								 | 
							
								 * @para_id     parameters group id, 0 ~ PHY_SW_NN_PPM_PARA_MAX
							 | 
						||
| 
								 | 
							
								 * @nn_nid      neighbor network nid
							 | 
						||
| 
								 | 
							
								 * @nn_ppm      neighbor network ppm error relative to 0ppm
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      error code. see iot_errno_api.h
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t phy_set_sw_nn_ppm_para(uint32_t para_id, uint32_t nn_nid,
							 | 
						||
| 
								 | 
							
								    int16_t nn_ppm);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_get_sw_nn_rx_ppm_para - get sw nn rx ppm function parameters
							 | 
						||
| 
								 | 
							
								 * @para_id     parameters group id, 0 ~ PHY_SW_NN_PPM_PARA_MAX
							 | 
						||
| 
								 | 
							
								 * @nn_nid      neighbor network nid
							 | 
						||
| 
								 | 
							
								 * @nn_ppm      neighbor network ppm error relative to 0ppm
							 | 
						||
| 
								 | 
							
								 * @rx_nn_phase_adj
							 | 
						||
| 
								 | 
							
								  *             registor rx_nn_phase_adj value
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      error code. see iot_errno_api.h
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_sw_nn_rx_ppm_para(uint32_t para_id, uint32_t *nn_nid,
							 | 
						||
| 
								 | 
							
								    int16_t *nn_ppm, int16_t *rx_nn_phase_adj);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* phy_get_sw_nn_tx_ppm_para - get sw nn tx ppm function parameters
							 | 
						||
| 
								 | 
							
								 * @para_id     parameters group id, 0 ~ PHY_SW_NN_PPM_PARA_MAX
							 | 
						||
| 
								 | 
							
								 * @nn_nid      neighbor network nid
							 | 
						||
| 
								 | 
							
								 * @nn_ppm      neighbor network ppm error relative to 0ppm
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:      error code. see iot_errno_api.h
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_sw_nn_tx_ppm_para(uint32_t para_id, uint32_t *nn_nid,
							 | 
						||
| 
								 | 
							
								    int16_t *nn_ppm);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif
							 |