/*********************************************************************
 *
 *        Filename:  mtimer_drv.h
 *
 *         Created:  2022-04-28 02:19:34 PM
 *   Last Modified:  2022-04-28 02:19:34 PM
 *          Author:  xinxin.li
 *    Organization:  Beijing Smart Logic Technology Co., Ltd.
 *
 *     Description:
 *
 *
 ********************************************************************/

#ifndef __MTIMER_DRV_H__
#define __MTIMER_DRV_H__

#include "ucp_drv_common.h"

typedef enum _tagMtimerMaskId
{
	MTIMER_MASK_32BIT	= 0,
	MTIMER_MASK_48BIT	= 1,
	MTIMER_MASK_62BIT	= 2
}MtimerMaskId;

/*
mtimer的pp1s选择信号;
3’b000:表示选择gmac_pps;
3’b001:表示选择gmac1_pps;
3’b010:表示选择cpri_aux_rfp_rx_jesd;
3’b011:表示选择cpri_gmac_pps;
3’b010:表示选择pet_pps;
3’b101:表示选择gnss_pps_in；
3’b110:表示选择stc_one_pps_out;
3’b111:表示选择tod_one_pps_out;
*/
typedef enum _tagMTimerPP1sSrc{
	MTIMER_PP1S_SRC_GMAC	             = 0,
	MTIMER_PP1S_SRC_GMAC1                = 1,
	MTIMER_PP1S_SRC_CPRI_AUX_RFP_RX_JESD = 2,
	MTIMER_PP1S_SRC_CPRI_GMAC            = 3,
	MTIMER_PP1S_SRC_PET_PPS              = 4,
	MTIMER_PP1S_SRC_GNSS	             = 5,
	MTIMER_PP1S_SRC_STC	                 = 6,
	MTIMER_PP1S_SRC_TOD	                 = 7
}numMTimerPP1sSrc;


uint32_t mtimer_get_baseaddr(uint8_t nTmrId);
int32_t mtimer_para_init(uint8_t nTmrId, int32_t nScsId, int32_t nTddSlotNum);
int32_t mtimer_clear_all_event(uint8_t nTmrId);
int32_t set_mtimer_period(uint8_t nTmrId, uint32_t nTmrL, uint32_t nTmrM, uint32_t nTmrH);
int32_t set_mtimer_1pps_scratch(uint8_t nTmrId);
// nTmrPoint: us as unit
int32_t set_mtimer_tmrpoint(uint8_t nTmrId, uint8_t nPointId, int32_t nTmrPoint, uint8_t mask);
// nTmrPoint: ns as unit
int32_t set_mtimer_tmrpoint_ns(uint8_t nTmrId, uint8_t nPointId, int32_t nTmrPoint, uint8_t mask);
int32_t enable_mtimer_tmrpoint_int(uint8_t nTmrId, uint8_t nPointId, uint8_t nIntcId);
int32_t disable_mtimer_tmrpoint_int(uint8_t nTmrId, uint8_t nPointId, uint8_t nIntcId);
int32_t enable_mtimer_cevent_int(uint8_t nTmrId, uint8_t nCEvtId, uint8_t nIntcId);
int32_t disable_mtimer_cevent_int(uint8_t nTmrId, uint8_t nCEvtId, uint8_t nIntcId);

int32_t set_cpri_tmr_ctrl();

int32_t start_mtimer(uint8_t nTmrId);

int32_t stop_mtimer(uint8_t nTmrId);

uint64_t get_mtimer_rt_scr_value(uint8_t nTmrId);

#endif

