164 lines
4.9 KiB
C
164 lines
4.9 KiB
C
|
/*==============================================================================
|
|||
|
* Copyright (c) 2011~2012, CPIT. All Rights Reserved.
|
|||
|
*
|
|||
|
* MODULE: STC模块驱动
|
|||
|
*
|
|||
|
* FILENAME: stc.h
|
|||
|
*
|
|||
|
* DESCRIPTION: Source Code of STC Driver
|
|||
|
*
|
|||
|
* Current Version: 1.0
|
|||
|
*
|
|||
|
* HISTORY:
|
|||
|
* Date CR No Person Description
|
|||
|
* ---------- ------------ ------ -------------
|
|||
|
* 2022-05-21 Li Weihua Initial version.
|
|||
|
==============================================================================*/
|
|||
|
#ifndef __STC_DRV_API_H__
|
|||
|
#define __STC_DRV_API_H__
|
|||
|
|
|||
|
#include "typedef.h"
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
#if 0
|
|||
|
#pragma align(1) /* set tight packing */
|
|||
|
#pragma pack(1)
|
|||
|
#endif
|
|||
|
/*==============================================================================
|
|||
|
Includes and Public Data Declarations
|
|||
|
==============================================================================*/
|
|||
|
|
|||
|
/* 包含系统文件以及定义公用数据文件 */
|
|||
|
|
|||
|
|
|||
|
/*==============================================================================
|
|||
|
Include Files
|
|||
|
==============================================================================*/
|
|||
|
|
|||
|
/* 包含本地文件 */
|
|||
|
/*==============================================================================
|
|||
|
Constant / Define Declarations
|
|||
|
==============================================================================*/
|
|||
|
|
|||
|
|
|||
|
/* 常量定义,并对所定义的常量进行说明 */
|
|||
|
/*==============================================================================
|
|||
|
Global Constant Data Declarations
|
|||
|
==============================================================================*/
|
|||
|
|
|||
|
/*==============================================================================
|
|||
|
Macro Definitions
|
|||
|
==============================================================================*/
|
|||
|
/* 宏定义,并对其进行简要说明 */
|
|||
|
|
|||
|
/*==============================================================================
|
|||
|
Function Prototypes
|
|||
|
==============================================================================*/
|
|||
|
|
|||
|
/*STC中断类型*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
STC_INT_RESERVED = 0, /* Reserved*/
|
|||
|
STC_TOD_1PPS, /* stc内部产生的1pps中断 */
|
|||
|
STC_EX_1PPS_IN, /* 外部1pps中断 */
|
|||
|
STC_HSCC_DUMP = 4 /* HSCC_DUMP中断 */
|
|||
|
} stc_int_type_e;
|
|||
|
|
|||
|
|
|||
|
/*输入1PPS中断源*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
GMAC0_1PPS_IN = 0, /* gmac0 */
|
|||
|
GMAC1_1PPS_IN, /* gmac1 */
|
|||
|
RESERVED0_1PPS_IN, /* Reserved*/
|
|||
|
CPRI_GMAC_1PPS_IN = 3, /* cpri gmac */
|
|||
|
TMAC_1PPS_IN, /* tmac */
|
|||
|
GNSS_1PPS_IN, /* 接收机 */
|
|||
|
//GMAC_1PPS
|
|||
|
RESERVED_1PPS_IN /* Reserved*/
|
|||
|
} pp1s_soure_e;
|
|||
|
|
|||
|
/*输出1PPS源*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
GMAC0_1PPS_OUT = 0, /* gmac0 */
|
|||
|
GMAC1_1PPS_OUT, /* gmac1 */
|
|||
|
RESERVED0_1PPS_OUT, /* Reserved*/
|
|||
|
CPRI_GMAC_1PPS_OUT = 3, /* cpri gmac */
|
|||
|
TMAC_1PPS_OUT, /* tmac */
|
|||
|
STC_1PPS_OUT, /* stc产生的1pps */
|
|||
|
TOD_1PPS_OUT, /* stc产生的1pps */
|
|||
|
RESERVED_1PPS_OUT /* Reserved*/
|
|||
|
} pp1s_output_e;
|
|||
|
|
|||
|
/*synce接口类型*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
SYNCE_GMAC = 0, /* GMAC */
|
|||
|
SYNCE_TMAC, /* TMAC */
|
|||
|
SYNCE_ECPRI, /* eCPRI */
|
|||
|
RESERVED_SYNCE /* Reserved*/
|
|||
|
}synce_src_e;
|
|||
|
|
|||
|
|
|||
|
/*hscc_dump的输入源*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
TOD_1PPS = 0, /* stc内部产生的1pps */
|
|||
|
EX_1PPS_IN, /* 外部1pps */
|
|||
|
EX_SYNCE, /* 恢复时钟/synce时钟分频产生的1pps */
|
|||
|
HSCC_RESERVED /* Reserved*/
|
|||
|
} hscc_dump_soure_e;
|
|||
|
|
|||
|
int32_t init_stc();
|
|||
|
int32_t enable_stc_irq(stc_int_type_e irq_type);
|
|||
|
int32_t disable_stc_irq(stc_int_type_e irq_type);
|
|||
|
int32_t select_xpps_in_source(pp1s_soure_e src);
|
|||
|
int32_t set_xpps_out_source(pp1s_output_e src,uint32_t enable);
|
|||
|
double stc_adjust_frequency();
|
|||
|
int32_t stc_adjust_phase(uint32_t phase_diff);
|
|||
|
int32_t stc_adjust_sniffer_phase(int32_t phase_diff,uint32_t flag);
|
|||
|
int32_t set_ape_preset_value(uint32_t cal_bfn);
|
|||
|
int32_t stc_wait_for_hscc();
|
|||
|
int32_t stc_wait_for_expps();
|
|||
|
uint32_t get_gmac_src_time();
|
|||
|
uint32_t get_tmac_src_time();
|
|||
|
uint32_t read_stc_local_timer();
|
|||
|
|
|||
|
/******************************************************************
|
|||
|
* Input(s):
|
|||
|
* sync_status: STC同步状态 1:同步,0:失步
|
|||
|
* Output(s):
|
|||
|
* <none>
|
|||
|
* Returns:
|
|||
|
* 0:成功
|
|||
|
* 非0:失败
|
|||
|
********************************************************************/
|
|||
|
int32_t set_sync_status_to_ape(uint32_t sync_status);
|
|||
|
|
|||
|
/*配置STC内部 synce时钟源*/
|
|||
|
int32_t config_synce(uint32_t synce_flag, synce_src_e interface, uint32_t clk);
|
|||
|
|
|||
|
/*synce时设置频率校准周期*/
|
|||
|
int32_t set_fsync_frequncy(uint32_t frequncy);
|
|||
|
|
|||
|
/*选择hscc_dump中断的输入*/
|
|||
|
int32_t select_hscc_dump_source(hscc_dump_soure_e src_type);
|
|||
|
|
|||
|
uint32_t read_stc_local_timer();
|
|||
|
|
|||
|
#if 0
|
|||
|
#pragma align() /* restore default packing */
|
|||
|
#pragma pack()
|
|||
|
#endif
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif /* __STC_DRV_API_H__ */
|
|||
|
|