diff --git a/public/common/driver/inc/mtimer_com.h b/public/common/driver/inc/mtimer_com.h index d3f41d9..26f88f5 100644 --- a/public/common/driver/inc/mtimer_com.h +++ b/public/common/driver/inc/mtimer_com.h @@ -1,11 +1,12 @@ #ifndef _INC_MTIMER_COM_H_ #define _INC_MTIMER_COM_H_ -#define APE_NUM (8) //4 +#define APE_NUM (8) //4 -#define FIBER_MIN_DELAY 1 // 10 // -#define INT_DELAY 4 // 6 // // us -#define EDMA_OFFSET 50 // 6 // 8 // 2 // us +#define FIBER_MIN_DELAY 1000 // ns +#define CPRI_INT_DELAY 3000 // ns +#define JESD_INT_DELAY 4000 // ns +#define EDMA_OFFSET 50000 // ns #define CPRI_RE_TOFFSET 0 // 100 // 200 // ns // Toffset, to be change #define CPRI_T2A 100 // 1 // 10 // ns @@ -170,6 +171,8 @@ typedef struct _tagMtimerIntStat{ uint32_t txSymbolIntCnt; // int flag uint32_t sfnOffsetIntFlag; + // pp1s int cost + uint32_t tmrPP1sCost; // ns }stMtimerIntStat; typedef struct _tagMtimerPhyPara{ diff --git a/public/common/driver/inc/phy_para.h b/public/common/driver/inc/phy_para.h index 466c81c..f3bc78a 100644 --- a/public/common/driver/inc/phy_para.h +++ b/public/common/driver/inc/phy_para.h @@ -51,7 +51,7 @@ #define DDR_MONITOR_ENABLE (SPU_DRV_SM_ADDR+0x270) // 开始监测ddr性能 #define DDR_MONITOR_CNT (SPU_DRV_SM_ADDR+0x274) -#define JESD_RF_TXOFF2RXON (SPU_DRV_SM_ADDR+0x278) // us as unit +#define JESD_RF_TXOFF2RXON (SPU_DRV_SM_ADDR+0x278) // ns as unit #define JESD_RF_TXON2PP1S (SPU_DRV_SM_ADDR+0x27C) #define SLOT_NUM_DEBUG_ADDR (SPU_DRV_SM_ADDR+0x300) diff --git a/public/common/ecs_dm/inc/jesd_drv_para.h b/public/common/ecs_dm/inc/jesd_drv_para.h index 12cf81f..6138f5d 100644 --- a/public/common/ecs_dm/inc/jesd_drv_para.h +++ b/public/common/ecs_dm/inc/jesd_drv_para.h @@ -5,7 +5,7 @@ typedef struct JesdDelay { - // 10ms offset, us as unit + // 10ms offset, ns as unit uint32_t tx_offset; uint32_t rx_offset; uint32_t tdd_offset; diff --git a/public/ecs_rfm_spu1/driver/inc/jesd_csu_nr_7ds2u.h b/public/ecs_rfm_spu1/driver/inc/jesd_csu_nr_7ds2u.h index 4ee24c9..6a13b88 100644 --- a/public/ecs_rfm_spu1/driver/inc/jesd_csu_nr_7ds2u.h +++ b/public/ecs_rfm_spu1/driver/inc/jesd_csu_nr_7ds2u.h @@ -66,7 +66,7 @@ #define JESD_98_NR7DS2U_RX_SLOT_ODD_DATA_ADDR 0x6BE69000 // 0x1E0000 // 0x6c049000 #define JESD_ORX_DATA_ADDR 0x60000000 -#define JESD_ORX_DATA_LEN (24576000*5) // 125ms +#define JESD_ORX_DATA_LEN 12288000 // (24576000*5) // 125ms int32_t jesd_csu_init_nr_7ds2u(); int32_t jesd_csu_init_nr_7d2u_slot0(); diff --git a/public/ecs_rfm_spu1/driver/inc/jesd_timer.h b/public/ecs_rfm_spu1/driver/inc/jesd_timer.h index a73c885..176d779 100644 --- a/public/ecs_rfm_spu1/driver/inc/jesd_timer.h +++ b/public/ecs_rfm_spu1/driver/inc/jesd_timer.h @@ -4,9 +4,9 @@ #include "typedef.h" #include "phy_para.h" -#define JESD_TXRX_CHANGE_GAP 13 -#define JESD_RF_ON_GAP 8 -#define JESD_RF_OFF_GAP 2 +#define JESD_TXRX_CHANGE_GAP 13000 // ns +#define JESD_RF_ON_GAP 8000 +#define JESD_RF_OFF_GAP 2000 //#define JESD_TX_ADVANCE_SAMPLE 0 // 500 // sample //#define JESD_RX_ADVANCE_SAMPLE 1600 // sample //#define JESD_RRU_TD 0 // 480 // sample diff --git a/public/ecs_rfm_spu1/driver/inc/mtimer_drv.h b/public/ecs_rfm_spu1/driver/inc/mtimer_drv.h index 98d89a6..283be08 100644 --- a/public/ecs_rfm_spu1/driver/inc/mtimer_drv.h +++ b/public/ecs_rfm_spu1/driver/inc/mtimer_drv.h @@ -54,6 +54,8 @@ int32_t set_mtimer_period(uint8_t nTmrId, uint32_t nTmrL, uint32_t nTmrM, uint32 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); diff --git a/public/ecs_rfm_spu1/driver/src/cpri_delay.s.c b/public/ecs_rfm_spu1/driver/src/cpri_delay.s.c index 9fc0f05..82bf769 100644 --- a/public/ecs_rfm_spu1/driver/src/cpri_delay.s.c +++ b/public/ecs_rfm_spu1/driver/src/cpri_delay.s.c @@ -39,19 +39,19 @@ void cpri_delay_init() memset(pCpriDelay, 0, sizeof(stCpriDelayMeasure)); pCpriDelay->delayReTOffset = CPRI_RE_TOFFSET; // ns pCpriDelay->delayReT2A = CPRI_T2A; // ns - pCpriDelay->delayDma = EDMA_OFFSET; + pCpriDelay->delayDma = EDMA_OFFSET; // ns - pCpriDelay->cpri10msOffset = (uint32_t)((float)CPRI_RE_TOFFSET/1000+0.5) + FIBER_MIN_DELAY + INT_DELAY; - pCpriDelay->cpri10msRxOffset = (uint32_t)((float)CPRI_RE_TOFFSET/1000+0.5) + FIBER_MIN_DELAY + INT_DELAY; // + 2; - pCpriDelay->cpriTddOffset = (uint32_t)((float)CPRI_RE_TOFFSET/1000+0.5) + FIBER_MIN_DELAY + INT_DELAY + EDMA_OFFSET; + pCpriDelay->cpri10msOffset = CPRI_RE_TOFFSET + CPRI_INT_DELAY*2; + pCpriDelay->cpri10msRxOffset = CPRI_RE_TOFFSET + CPRI_INT_DELAY*2; // + 2; + pCpriDelay->cpriTddOffset = CPRI_RE_TOFFSET + CPRI_INT_DELAY*2 + EDMA_OFFSET; do_write(CPRI_ADVANCE_ADDR, pCpriDelay->cpri10msOffset); do_write(CPRI_TDD_ADVANCE_ADDR, pCpriDelay->cpriTddOffset); do_write(CPRI_DELAY_ADDR, pCpriDelay->cpri10msRxOffset); - pCpriDelay->cpri10ms2PP1sTxOffset = pCpriDelay->cpri10msOffset + gpsOffset; - pCpriDelay->cpri10ms2PP1sRxOffset = gpsOffset - pCpriDelay->cpri10msRxOffset; - pCpriDelay->cpriTdd2PP1sOffset = gpsOffset + pCpriDelay->cpriTddOffset; + pCpriDelay->cpri10ms2PP1sTxOffset = pCpriDelay->cpri10msOffset + gpsOffset*1000; + pCpriDelay->cpri10ms2PP1sRxOffset = gpsOffset*1000 - pCpriDelay->cpri10msRxOffset; + pCpriDelay->cpriTdd2PP1sOffset = gpsOffset*1000 + pCpriDelay->cpriTddOffset; do_write(CPRI_TX_ADVANCE_PP1S_ADDR, pCpriDelay->cpri10ms2PP1sTxOffset); do_write(CPRI_RX_ADVANCE_PP1S_ADDR, pCpriDelay->cpri10ms2PP1sRxOffset); @@ -321,7 +321,7 @@ void cpri_delay_measurement() cpri_10ms_rx_offset = (offsetRxSum >> 6);// / 1000; // ns -> us __ucps2_synch(0); - cpri_tdd_offset = cpri_10ms_offset + pCpriDelay->delayDma*1000; // ns + cpri_tdd_offset = cpri_10ms_offset + pCpriDelay->delayDma; // ns pCpriDelay->delayMeausreValid = 1; __ucps2_synch(0); @@ -329,14 +329,14 @@ void cpri_delay_measurement() debug_write((DBG_DDR_IDX_DRV_BASE+1013), cpri_tdd_offset); // 0xfd4 debug_write((DBG_DDR_IDX_DRV_BASE+1014), cpri_10ms_rx_offset); // 0xfd8 #if 0 - uint32_t tempOffset; - tempOffset = (uint32_t)(((float)cpri_10ms_offset/1000)+0.5); // ns -> us - pCpriDelay->cpri10msOffset = (tempOffset < FIBER_MIN_DELAY) ? (FIBER_MIN_DELAY+INT_DELAY) : (tempOffset+INT_DELAY); + //uint32_t tempOffset; + //tempOffset = (uint32_t)(((float)cpri_10ms_offset/1000)+0.5); // ns -> us + pCpriDelay->cpri10msOffset = (cpri_10ms_offset < FIBER_MIN_DELAY) ? (FIBER_MIN_DELAY+CPRI_INT_DELAY) : (cpri_10ms_offset+CPRI_INT_DELAY); - tempOffset = (uint32_t)(((float)cpri_10ms_rx_offset/1000)+0.5); // ns -> us - pCpriDelay->cpri10msRxOffset = (tempOffset < FIBER_MIN_DELAY) ? (FIBER_MIN_DELAY+INT_DELAY) : (tempOffset+INT_DELAY); + //tempOffset = (uint32_t)(((float)cpri_10ms_rx_offset/1000)+0.5); // ns -> us + pCpriDelay->cpri10msRxOffset = (cpri_10ms_rx_offset < FIBER_MIN_DELAY) ? (FIBER_MIN_DELAY+CPRI_INT_DELAY) : (cpri_10ms_rx_offset+CPRI_INT_DELAY); - pCpriDelay->cpriTddOffset = pCpriDelay->cpri10msOffset + INT_DELAY + EDMA_OFFSET + pCpriDelay->cpriTddOffset = pCpriDelay->cpri10msOffset + CPRI_INT_DELAY + EDMA_OFFSET; do_write(CPRI_ADVANCE_ADDR, pCpriDelay->cpri10msOffset); do_write(CPRI_TDD_ADVANCE_ADDR, pCpriDelay->cpriTddOffset); diff --git a/public/ecs_rfm_spu1/driver/src/cpri_timer.s.c b/public/ecs_rfm_spu1/driver/src/cpri_timer.s.c index ad378e2..f90dd9e 100644 --- a/public/ecs_rfm_spu1/driver/src/cpri_timer.s.c +++ b/public/ecs_rfm_spu1/driver/src/cpri_timer.s.c @@ -130,11 +130,17 @@ void cpri_timer_reconfig(phy_timer_config_ind_t *my_cpritmr) __ucps2_synch(0); } - tempOffset = (uint32_t)(((float)pCpriDelay->cpriTxOffset/1000)+0.5); // ns -> us - pCpriDelay->cpri10msOffset = (tempOffset < (FIBER_MIN_DELAY+INT_DELAY)) ? (FIBER_MIN_DELAY+INT_DELAY) : (tempOffset+FIBER_MIN_DELAY+INT_DELAY); + //debug_write((DBG_DDR_IDX_DRV_BASE+62), pMtimerInt->tmrPP1sCost); // 0xF8 - tempOffset = (uint32_t)(((float)pCpriDelay->cpriRxOffset/1000)+0.5); // ns -> us - pCpriDelay->cpri10msRxOffset = (tempOffset < (FIBER_MIN_DELAY+INT_DELAY)) ? (FIBER_MIN_DELAY+INT_DELAY) : (tempOffset+FIBER_MIN_DELAY+INT_DELAY); + //tempOffset = (uint32_t)(((float)pCpriDelay->cpriTxOffset/1000)+0.5); // ns -> us + //pCpriDelay->cpri10msOffset = (tempOffset < (CPRI_INT_DELAY+FIBER_MIN_DELAY)) ? (CPRI_INT_DELAY+FIBER_MIN_DELAY) : (tempOffset+CPRI_INT_DELAY+FIBER_MIN_DELAY); + tempOffset = pCpriDelay->cpriTxOffset; + pCpriDelay->cpri10msOffset = tempOffset + pMtimerInt->tmrPP1sCost*2; // +FIBER_MIN_DELAY; + + //tempOffset = (uint32_t)(((float)pCpriDelay->cpriRxOffset/1000)+0.5); // ns -> us + //pCpriDelay->cpri10msRxOffset = (tempOffset < (CPRI_INT_DELAY+FIBER_MIN_DELAY)) ? (CPRI_INT_DELAY+FIBER_MIN_DELAY) : (tempOffset+CPRI_INT_DELAY-FIBER_MIN_DELAY); + tempOffset = pCpriDelay->cpriRxOffset; + pCpriDelay->cpri10msRxOffset = (tempOffset < (12000-pMtimerInt->tmrPP1sCost*2)) ? (12000-pMtimerInt->tmrPP1sCost*2) : (tempOffset); pCpriDelay->cpriTddOffset = pCpriDelay->cpri10msOffset + EDMA_OFFSET; @@ -145,9 +151,9 @@ void cpri_timer_reconfig(phy_timer_config_ind_t *my_cpritmr) uint32_t addr = (uint32_t)&(phyPara[my_cpritmr->scsId].gpsOffset); uint16_t gpsOffset = do_read_volatile_short(addr); - pCpriDelay->cpri10ms2PP1sTxOffset = pCpriDelay->cpri10msOffset + gpsOffset; // advance us - pCpriDelay->cpri10ms2PP1sRxOffset = gpsOffset - pCpriDelay->cpri10msRxOffset; // delay us - pCpriDelay->cpriTdd2PP1sOffset = gpsOffset + pCpriDelay->cpriTddOffset; // advance us as positive number + pCpriDelay->cpri10ms2PP1sTxOffset = pCpriDelay->cpri10msOffset + gpsOffset*1000; // advance ns + pCpriDelay->cpri10ms2PP1sRxOffset = gpsOffset*1000 - pCpriDelay->cpri10msRxOffset; // delay ns + pCpriDelay->cpriTdd2PP1sOffset = gpsOffset*1000 + pCpriDelay->cpriTddOffset; // advance ns as positive number reCfgFlag = 1; @@ -185,7 +191,7 @@ void cpri_timer_reconfig(phy_timer_config_ind_t *my_cpritmr) pMtimerPara->slotPeriod = my_cpritmr->t_us; pMtimerPara->slotMaxNum = my_cpritmr->num_tti_per_sfn; pMtimerSfn->slotMaxNum = my_cpritmr->num_tti_per_sfn; - pMtimerSfn->slotNumPP1s = (pCpriDelay->cpri10ms2PP1sTxOffset / my_cpritmr->t_us) % my_cpritmr->num_tti_per_sfn; + pMtimerSfn->slotNumPP1s = (pCpriDelay->cpri10ms2PP1sTxOffset / (my_cpritmr->t_us*1000)) % my_cpritmr->num_tti_per_sfn; do_write_short((&(phyPara[my_cpritmr->scsId].slotNumOfTdd)), my_cpritmr->num_tti); do_write_short((&(phyPara[my_cpritmr->scsId].mtimerId)), MTIMER_CPRI_ID); @@ -363,9 +369,9 @@ void set_cpri_sfn_offset(void) EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); offset = pEcsDmLocalMgt->pCpriDelay->cpri10ms2PP1sTxOffset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; //#endif - uint32_t tmr0Point = SFN_PERIOD - offset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; // us + uint32_t tmr0Point = SFN_PERIOD*1000 - offset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; // us - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_10ms_OFFSET, tmr0Point, MTIMER_MASK_62BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_10ms_OFFSET, tmr0Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_10ms_OFFSET, MTMR_INT_10ms); } @@ -383,9 +389,9 @@ void set_cpri_tx_axc_ch_en(void) EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); offset = pEcsDmLocalMgt->pCpriDelay->cpri10ms2PP1sTxOffset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; //#endif - uint32_t tmr1Point = SFN_PERIOD - offset - 2; // us + uint32_t tmr1Point = SFN_PERIOD*1000 - offset - 2000; // ns - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_CSU_CH, tmr1Point, MTIMER_MASK_62BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_CSU_CH, tmr1Point, MTIMER_MASK_62BIT); } void set_cpri_tdd_offset(void) @@ -398,20 +404,20 @@ void set_cpri_tdd_offset(void) offset = pEcsDmLocalMgt->pCpriDelay->cpriTdd2PP1sOffset; // pEcsDmLocalMgt->pCpriDelay->cpriTddOffset; //#endif - uint32_t tmr2Point = 5000 - offset; // us // 5ms - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_TDD_OFFSET, tmr2Point, MTIMER_MASK_62BIT); + uint32_t tmr2Point = 5000*1000 - offset; // us // 5ms + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_TDD_OFFSET, tmr2Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_TDD_OFFSET, MTMR_INT_TDD_OFFSET); - uint32_t tmr25Point = SFN_PERIOD - offset; // us // 5ms - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_10000, tmr25Point, MTIMER_MASK_62BIT); + uint32_t tmr25Point = SFN_PERIOD*1000 - offset; // us // 5ms + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_10000, tmr25Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_10000, MTMR_INT_TDD_OFFSET); - uint32_t tmr26Point = 2500 - offset; // us - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_2500, tmr26Point, MTIMER_MASK_62BIT); + uint32_t tmr26Point = 2500*1000 - offset; // us + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_2500, tmr26Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_2500, MTMR_INT_TDD_OFFSET); - uint32_t tmr27Point = 7500 - offset; // us - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_7500, tmr27Point, MTIMER_MASK_62BIT); + uint32_t tmr27Point = 7500*1000 - offset; // us + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_7500, tmr27Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_TDD_OFFSET_7500, MTMR_INT_TDD_OFFSET); } @@ -433,8 +439,8 @@ void set_tx_slot_offset() offset = pEcsDmLocalMgt->pCpriDelay->cpri10ms2PP1sTxOffset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; //#endif - uint32_t tmr3Point = SFN_PERIOD - offset; // us - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_TXSLOT_OFFSET, tmr3Point, MTIMER_MASK_32BIT); + uint32_t tmr3Point = SFN_PERIOD*1000 - offset; // us + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_TXSLOT_OFFSET, tmr3Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_TXSLOT_OFFSET, MTMR_INT_SLOT_OFFSET); //uint32_t tempL = gCpriTimerPara.tmrMsPeriod * (tmr3Point % gCpriTimerPara.slotPeriod) / 1000; @@ -477,9 +483,9 @@ void set_rx_slot_offset() } else { - tmr4Point = SFN_PERIOD - offset; // us + tmr4Point = SFN_PERIOD*1000 - offset; // us } - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_RXSLOT_OFFSET, tmr4Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_RXSLOT_OFFSET, tmr4Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_RXSLOT_OFFSET, MTMR_INT_SLOT_OFFSET); //uint32_t tempL = gCpriTimerPara.tmrMsPeriod * (tmr3Point % gCpriTimerPara.slotPeriod) / 1000; @@ -515,9 +521,9 @@ void set_cpri_lte_fapi_offset(void) EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); offset = pEcsDmLocalMgt->pCpriDelay->cpri10ms2PP1sTxOffset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; //#endif - uint32_t tmr30Point = SFN_PERIOD - offset - 500; // us + uint32_t tmr30Point = SFN_PERIOD*1000 - offset - 500000; // ns - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_LTE_FAPI, tmr30Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_LTE_FAPI, tmr30Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_LTE_FAPI, MTMR_INT_SLOT_OFFSET); } @@ -545,7 +551,7 @@ int32_t set_cpri_ape_slot_offset(uint32_t apeCoreId) rxOffset = pEcsDmLocalMgt->pCpriDelay->cpri10ms2PP1sRxOffset; // pEcsDmLocalMgt->pCpriDelay->cpri10msRxOffset; //#endif - uint32_t tmr3Point = SFN_PERIOD - txOffset; // us + uint32_t tmr3Point = SFN_PERIOD*1000 - txOffset; // us uint32_t tmr4Point = 0; // offset; // us if (rxOffset < 0) { @@ -553,7 +559,7 @@ int32_t set_cpri_ape_slot_offset(uint32_t apeCoreId) } else { - tmr4Point = SFN_PERIOD - rxOffset; // us + tmr4Point = SFN_PERIOD*1000 - rxOffset; // us } // ape tmrpoints @@ -568,11 +574,11 @@ int32_t set_cpri_ape_slot_offset(uint32_t apeCoreId) } // tx slot int tmrId = MTMR_APE0_TXSLOT + (apeId<<1); - set_mtimer_tmrpoint(MTIMER_CPRI_ID, tmrId, tmr3Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, tmrId, tmr3Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, tmrId, (MTMR_INT_APE0_SLOT+apeId)); // rx slot int tmrId = MTMR_APE0_RXSLOT + (apeId<<1); - set_mtimer_tmrpoint(MTIMER_CPRI_ID, tmrId, tmr4Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, tmrId, tmr4Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, tmrId, (MTMR_INT_APE0_SLOT+apeId)); runCore &= (~(1 << apeId)); @@ -628,17 +634,17 @@ int32_t set_cpri_tx_symbol_offset(uint8_t symbolId) uint32_t longCp = (uint32_t)4448*500000/(4448+13*4384); // ns uint32_t shortCp = (uint32_t)4384*500000/(4448+13*4384); // ns - int32_t tmrPoint = 0 - INT_DELAY; + int32_t tmrPoint = 0 - CPRI_INT_DELAY; if (1 >= symbolId) { - tmrPoint += ((longCp*symbolId)/1000); + tmrPoint += ((longCp*symbolId)); } else { - tmrPoint += ((longCp + shortCp*(symbolId-1))/1000); + tmrPoint += ((longCp + shortCp*(symbolId-1))); } - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_ECPRI_TX_SYMBOL0+symbolId, tmrPoint, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_ECPRI_TX_SYMBOL0+symbolId, tmrPoint, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_ECPRI_TX_SYMBOL0+symbolId, MTMR_INT_RFM0_SLOT); return 0; @@ -653,8 +659,8 @@ void set_cpri_insert_int(void) offset = pEcsDmLocalMgt->pCpriDelay->cpri10ms2PP1sTxOffset; // pEcsDmLocalMgt->pCpriDelay->cpri10msOffset; //#endif - UINT32 tmr24Point = 8000 - offset; // us - set_mtimer_tmrpoint(MTIMER_CPRI_ID, MTMR_CSU_INSERT, tmr24Point, MTIMER_MASK_62BIT); + UINT32 tmr24Point = 8000000 - offset; // us + set_mtimer_tmrpoint_ns(MTIMER_CPRI_ID, MTMR_CSU_INSERT, tmr24Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(MTIMER_CPRI_ID, MTMR_CSU_INSERT, MTMR_INT_TDD_OFFSET); } @@ -718,14 +724,14 @@ void isr_cpri_10ms(void) uint32_t tmrBaseAddr = mtimer_get_baseaddr(MTIMER_CPRI_ID); tmrIntcFlag = do_read_volatile(tmrBaseAddr + MTMR_INTC_REG) ; - __ucps2_synch(0); + //__ucps2_synch(0); if ((tmrIntcFlag & (1 << MTMR_INT_10ms))) /* tmr int */ { uint32_t cFlagAddr = tmrBaseAddr + MTMR_CINTF0_REG + 2*(MTMR_INT_10ms<<2); uint32_t tFlagAddr = tmrBaseAddr + MTMR_TINTF00_REG + 6*(MTMR_INT_10ms<<2); cEventFlag = do_read_volatile(cFlagAddr); tEventFlag = do_read_volatile(tFlagAddr); - __ucps2_synch(0); + //__ucps2_synch(0); if ((cEventFlag & BIT17) || (cEventFlag & BIT2) || (tEventFlag & (1<tmrPP1sCost = GET_STC_CNT(); + debug_write((DBG_DDR_IDX_DRV_BASE+61), pMtimerInt->tmrPP1sCost); // 0xF4 } #ifdef ENABLE_SFNCAL @@ -765,7 +773,7 @@ void isr_cpri_10ms(void) #endif //debug_write((DBG_DDR_IDX_DRV_BASE+288), (GET_STC_CNT()-start)); // 0x480 } - if (cEventFlag & (1<= symbolId) { - tmrPoint += ((longCp*symbolId)/1000); + tmrPoint += ((longCp*symbolId)); } else { - tmrPoint += ((longCp + shortCp*(symbolId-1))/1000); + tmrPoint += ((longCp + shortCp*(symbolId-1))); } - set_mtimer_tmrpoint(MTIMER_ECPRI_ID, MTMR_ECPRI_TX_SYMBOL0+symbolId, tmrPoint, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(MTIMER_ECPRI_ID, MTMR_ECPRI_TX_SYMBOL0+symbolId, tmrPoint, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(MTIMER_ECPRI_ID, MTMR_ECPRI_TX_SYMBOL0+symbolId, MTMR_INT_RFM0_SLOT); return 0; diff --git a/public/ecs_rfm_spu1/driver/src/jesd_csu_nr_7ds2u.s.c b/public/ecs_rfm_spu1/driver/src/jesd_csu_nr_7ds2u.s.c index 2b397d5..051ca12 100644 --- a/public/ecs_rfm_spu1/driver/src/jesd_csu_nr_7ds2u.s.c +++ b/public/ecs_rfm_spu1/driver/src/jesd_csu_nr_7ds2u.s.c @@ -654,7 +654,7 @@ int32_t jesd_csu_init_nr_2500us_double_slot0() int32_t jesd_sniffer_orx_csu_init() { jesd_orx_csu_init(5); - stJesdCsuNodePara orxCsuNode[1]; + stJesdCsuNodePara orxCsuNode[2]; //orx的链表地址 uint32_t orxListAddr = JESD_RX_LIST2_ADDR; // 0x8A00C000 @@ -664,7 +664,11 @@ int32_t jesd_sniffer_orx_csu_init() orxCsuNode[0].yStep = JESD_ORX_DATA_LEN; orxCsuNode[0].allNum = JESD_ORX_DATA_LEN; - jesd_csu_orx_cfg(orxListAddr, 1, orxCsuNode, 0); + orxCsuNode[1].dataAddr = JESD_ORX_DATA_ADDR+JESD_ORX_DATA_LEN; + orxCsuNode[1].yStep = JESD_ORX_DATA_LEN; + orxCsuNode[1].allNum = JESD_ORX_DATA_LEN; + + jesd_csu_orx_cfg(orxListAddr, 2, orxCsuNode, 0); return 0; } diff --git a/public/ecs_rfm_spu1/driver/src/jesd_timer.s.c b/public/ecs_rfm_spu1/driver/src/jesd_timer.s.c index 21c4843..e6519db 100644 --- a/public/ecs_rfm_spu1/driver/src/jesd_timer.s.c +++ b/public/ecs_rfm_spu1/driver/src/jesd_timer.s.c @@ -111,12 +111,12 @@ void jesd_delay_init() EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); JesdDelay_t* jesd_delay_ptr = pEcsDmLocalMgt->jesd_delay_ptr; - jesd_delay_ptr->tx_offset = INT_DELAY*2.0; - jesd_delay_ptr->rx_offset = INT_DELAY*2.0; - jesd_delay_ptr->tdd_offset = INT_DELAY + EDMA_OFFSET; - jesd_delay_ptr->jesd_10ms2pp1s_txoffset = jesd_delay_ptr->tx_offset; // advance us - jesd_delay_ptr->jesd_10ms2pp1s_rxoffset = jesd_delay_ptr->rx_offset; // gpsOffset - pJesdDelay->rxOffset; // delay us - jesd_delay_ptr->jesd_tdd2pp1s_offset = jesd_delay_ptr->tdd_offset; // advance us as positive number + jesd_delay_ptr->tx_offset = JESD_INT_DELAY*2; + jesd_delay_ptr->rx_offset = JESD_INT_DELAY*2; + jesd_delay_ptr->tdd_offset = JESD_INT_DELAY + EDMA_OFFSET; + jesd_delay_ptr->jesd_10ms2pp1s_txoffset = jesd_delay_ptr->tx_offset; // advance ns + jesd_delay_ptr->jesd_10ms2pp1s_rxoffset = jesd_delay_ptr->rx_offset; // gpsOffset - pJesdDelay->rxOffset; // delay ns + jesd_delay_ptr->jesd_tdd2pp1s_offset = jesd_delay_ptr->tdd_offset; // advance ns as positive number } int32_t jesd_mtimer_init(int32_t nTmrId, int32_t nScsId, int32_t nTddSlotNum) @@ -196,6 +196,28 @@ int32_t get_jesd_timer_point_para(int32_t nTmrId, int32_t tmrPoint, uint32_t* te return 0; } +int32_t get_jesd_timer_pointns_para(int32_t nTmrId, int32_t tmrPoint, uint32_t* tempL, uint16_t* tempM, uint16_t* tempH) +{ + EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); + stMtimerPara* pMtimerPara = pEcsDmLocalMgt->pMtimerPara[nTmrId]; + uint32_t nSlotPeriodNs = pMtimerPara->slotPeriod*1000; + + while (tmrPoint < 0) + { + tmrPoint += (pMtimerPara->tddPeriod*1000); //SFN_PERIOD; + } + + *tempL = (uint64_t)pMtimerPara->tmrMsPeriod * (tmrPoint % nSlotPeriodNs) / 1000000; + *tempM = tmrPoint / nSlotPeriodNs; + if (0 == *tempL) + { + *tempM = (*tempM > 0) ? (*tempM - 1) : (pMtimerPara->tempM_max); + } + *tempL = (*tempL > 0) ? (*tempL - 1) : (pMtimerPara->tempL_max); + + return 0; +} + int32_t jesd_timer_get_csu_point(int32_t nTmrId, phy_timer_config_ind_t *my_jesdtmr) { if (NULL == my_jesdtmr) @@ -208,6 +230,7 @@ int32_t jesd_timer_get_csu_point(int32_t nTmrId, phy_timer_config_ind_t *my_jesd stMtimerPara* pMtimerPara = pEcsDmLocalMgt->pMtimerPara[nTmrId]; stMtimerPara* pMtimerTxPara = pEcsDmLocalMgt->pMtimerPara[nTmrId+2]; JesdDelay_t* pJesdDelay = pEcsDmLocalMgt->jesd_delay_ptr; + stMtimerIntStat* pMtimerInt = &gMtimerIntCnt[nTmrId]; uint32_t tdd = pMtimerPara->tddPeriod; // us uint32_t slotUs = pMtimerPara->slotPeriod; uint32_t longSymbCost = slotUs*1000*LONGCP_SAM_CNT/SLOT_SAM_CNT; // ns @@ -222,14 +245,14 @@ int32_t jesd_timer_get_csu_point(int32_t nTmrId, phy_timer_config_ind_t *my_jesd if (FDD_MODE == gJesdTFMode) { - //pMtimerTxPara->txCsuOn[0].timerPoint = (tdd*1000.0 - gCsuTxAdvanceNs - pJesdDelay->gps_offset*1000.0 - INT_DELAY*1000.0)/1000; // pJesdDelay->jesd_10ms2pp1s_txoffset; - pMtimerTxPara->txCsuOn[0].timerPoint = tdd - gCsuTxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; - get_jesd_timer_point_para(nTmrId+2, pMtimerTxPara->txCsuOn[0].timerPoint, &pMtimerTxPara->txCsuOn[0].pointL, + pMtimerTxPara->txCsuOn[0].timerPoint = tdd*1000.0 - gCsuTxAdvanceNs - pJesdDelay->gps_offset*1000.0 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; + //pMtimerTxPara->txCsuOn[0].timerPoint = tdd - gCsuTxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; + get_jesd_timer_pointns_para(nTmrId+2, pMtimerTxPara->txCsuOn[0].timerPoint, &pMtimerTxPara->txCsuOn[0].pointL, &pMtimerTxPara->txCsuOn[0].pointM, &pMtimerTxPara->txCsuOn[0].pointH); - //pMtimerPara->rxCsuOn[0].timerPoint = (tdd*1000.0 - gCsuRxAdvanceNs - pJesdDelay->gps_offset*1000.0 - INT_DELAY*1000.0)/1000; - pMtimerPara->rxCsuOn[0].timerPoint = tdd - gCsuRxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; - get_jesd_timer_point_para(nTmrId, pMtimerPara->rxCsuOn[0].timerPoint, &pMtimerPara->rxCsuOn[0].pointL, + pMtimerPara->rxCsuOn[0].timerPoint = tdd*1000.0 - gCsuRxAdvanceNs - pJesdDelay->gps_offset*1000.0 - pMtimerInt->tmrPP1sCost; + //pMtimerPara->rxCsuOn[0].timerPoint = tdd - gCsuRxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->rxCsuOn[0].timerPoint, &pMtimerPara->rxCsuOn[0].pointL, &pMtimerPara->rxCsuOn[0].pointM, &pMtimerPara->rxCsuOn[0].pointH); debug_write((DBG_DDR_IDX_DRV_BASE+48+(0<<2)), pMtimerTxPara->txCsuOn[0].timerPoint); // 0xC0 @@ -249,23 +272,24 @@ int32_t jesd_timer_get_csu_point(int32_t nTmrId, phy_timer_config_ind_t *my_jesd dlSlotCnt = my_jesdtmr->num_t_dl[0]; dlSymbolCnt = my_jesdtmr->num_t_dl_symb[0]; } - //pMtimerTxPara->txCsuOn[i].timerPoint = (tdd*1000.0 - gCsuTxAdvanceNs - pJesdDelay->gps_offset*1000.0 - INT_DELAY*1000.0)/1000; // pJesdDelay->jesd_10ms2pp1s_txoffset; - pMtimerTxPara->txCsuOn[i].timerPoint = tdd - gCsuTxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; - get_jesd_timer_point_para(nTmrId+2, pMtimerTxPara->txCsuOn[i].timerPoint, &pMtimerTxPara->txCsuOn[i].pointL, + pMtimerTxPara->txCsuOn[i].timerPoint = tdd*1000.0 - gCsuTxAdvanceNs - pJesdDelay->gps_offset*1000.0 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; + //pMtimerTxPara->txCsuOn[i].timerPoint = tdd - gCsuTxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; + get_jesd_timer_pointns_para(nTmrId+2, pMtimerTxPara->txCsuOn[i].timerPoint, &pMtimerTxPara->txCsuOn[i].pointL, &pMtimerTxPara->txCsuOn[i].pointM, &pMtimerTxPara->txCsuOn[i].pointH); - //pMtimerTxPara->txCsuOff[i].timerPoint = (dlSlotCnt*slotUs*1000.0 + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost) - pJesdDelay->gps_offset*1000.0 - INT_DELAY*1000.0)/1000; // pJesdDelay->jesd_10ms2pp1s_txoffset; - pMtimerTxPara->txCsuOff[i].timerPoint = dlSlotCnt*slotUs + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost)/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; - get_jesd_timer_point_para(nTmrId+2, pMtimerTxPara->txCsuOff[i].timerPoint, &pMtimerTxPara->txCsuOff[i].pointL, + pMtimerTxPara->txCsuOff[i].timerPoint = dlSlotCnt*slotUs*1000.0 + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost) - pJesdDelay->gps_offset*1000.0 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; + //pMtimerTxPara->txCsuOff[i].timerPoint = dlSlotCnt*slotUs + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost)/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; + get_jesd_timer_pointns_para(nTmrId+2, pMtimerTxPara->txCsuOff[i].timerPoint, &pMtimerTxPara->txCsuOff[i].pointL, &pMtimerTxPara->txCsuOff[i].pointM, &pMtimerTxPara->txCsuOff[i].pointH); - pMtimerPara->rxCsuOn[i].timerPoint = pMtimerTxPara->txCsuOff[i].timerPoint + (gapSymbolCnt*shortSymbCost - gCsuRxAdvanceNs)/1000; - get_jesd_timer_point_para(nTmrId, pMtimerPara->rxCsuOn[i].timerPoint, &pMtimerPara->rxCsuOn[i].pointL, + pMtimerPara->rxCsuOn[i].timerPoint = pMtimerTxPara->txCsuOff[i].timerPoint + gapSymbolCnt*shortSymbCost - gCsuRxAdvanceNs; + //pMtimerPara->rxCsuOn[i].timerPoint = pMtimerTxPara->txCsuOff[i].timerPoint + (gapSymbolCnt*shortSymbCost - gCsuRxAdvanceNs)/1000; + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->rxCsuOn[i].timerPoint, &pMtimerPara->rxCsuOn[i].pointL, &pMtimerPara->rxCsuOn[i].pointM, &pMtimerPara->rxCsuOn[i].pointH); - //pMtimerPara->rxCsuOff[i].timerPoint = (tdd*1000.0 - gCsuRxAdvanceNs - pJesdDelay->gps_offset*1000.0 - INT_DELAY*1000.0)/1000; // pJesdDelay->jesd_10ms2pp1s_txoffset; - pMtimerPara->rxCsuOff[i].timerPoint = tdd - gCsuRxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; - get_jesd_timer_point_para(nTmrId, pMtimerPara->rxCsuOff[i].timerPoint, &pMtimerPara->rxCsuOff[i].pointL, + pMtimerPara->rxCsuOff[i].timerPoint = tdd*1000.0 - gCsuRxAdvanceNs - pJesdDelay->gps_offset*1000.0 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; + //pMtimerPara->rxCsuOff[i].timerPoint = tdd - gCsuRxAdvanceNs/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->rxCsuOff[i].timerPoint, &pMtimerPara->rxCsuOff[i].pointL, &pMtimerPara->rxCsuOff[i].pointM, &pMtimerPara->rxCsuOff[i].pointH); debug_write((DBG_DDR_IDX_DRV_BASE+992+(i<<2)), pMtimerTxPara->txCsuOn[i].timerPoint); // 0xF80 @@ -300,6 +324,7 @@ int32_t jesd_timer_get_rf_point(int32_t nTmrId, phy_timer_config_ind_t *my_jesdt EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); stMtimerPara* pMtimerPara = pEcsDmLocalMgt->pMtimerPara[nTmrId]; JesdDelay_t* pJesdDelay = pEcsDmLocalMgt->jesd_delay_ptr; + stMtimerIntStat* pMtimerInt = &gMtimerIntCnt[nTmrId]; uint32_t tdd = pMtimerPara->tddPeriod; uint32_t slotUs = pMtimerPara->slotPeriod; uint32_t longSymbCost = slotUs*1000*LONGCP_SAM_CNT/SLOT_SAM_CNT; // ns @@ -324,21 +349,24 @@ int32_t jesd_timer_get_rf_point(int32_t nTmrId, phy_timer_config_ind_t *my_jesdt dlSlotCnt = my_jesdtmr->num_t_dl[0]; dlSymbolCnt = my_jesdtmr->num_t_dl_symb[0]; } - pMtimerPara->txRfOn[i].timerPoint = tdd - do_read_volatile(JESD_RF_TXON2PP1S) - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; //JESD_RF_ON_GAP; // tdd-8us - get_jesd_timer_point_para(nTmrId, pMtimerPara->txRfOn[i].timerPoint, &pMtimerPara->txRfOn[i].pointL, + pMtimerPara->txRfOn[i].timerPoint = tdd * 1000 - do_read_volatile(JESD_RF_TXON2PP1S) - pJesdDelay->gps_offset * 1000 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; //JESD_RF_ON_GAP; // tdd-8us + //pMtimerPara->txRfOn[i].timerPoint = tdd - do_read_volatile(JESD_RF_TXON2PP1S) - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; //JESD_RF_ON_GAP; // tdd-8us + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->txRfOn[i].timerPoint, &pMtimerPara->txRfOn[i].pointL, &pMtimerPara->txRfOn[i].pointM, &pMtimerPara->txRfOn[i].pointH); - //pMtimerPara->txRfOff[i].timerPoint = (dlSlotCnt*slotUs*1000.0 + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost) - pJesdDelay->gps_offset*1000.0 - INT_DELAY*1000.0)/1000; // pJesdDelay->jesd_10ms2pp1s_txoffset; - pMtimerPara->txRfOff[i].timerPoint = dlSlotCnt*slotUs + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost)/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; - get_jesd_timer_point_para(nTmrId, pMtimerPara->txRfOff[i].timerPoint, &pMtimerPara->txRfOff[i].pointL, + pMtimerPara->txRfOff[i].timerPoint = dlSlotCnt*slotUs*1000 + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost) - pJesdDelay->gps_offset*1000 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; + //pMtimerPara->txRfOff[i].timerPoint = dlSlotCnt*slotUs + (longSymbCost+(dlSymbolCnt-1)*shortSymbCost)/1000 - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->txRfOff[i].timerPoint, &pMtimerPara->txRfOff[i].pointL, &pMtimerPara->txRfOff[i].pointM, &pMtimerPara->txRfOff[i].pointH); pMtimerPara->rxRfOn[i].timerPoint = pMtimerPara->txRfOff[i].timerPoint + do_read_volatile(JESD_RF_TXOFF2RXON); //JESD_TXRX_CHANGE_GAP; - get_jesd_timer_point_para(nTmrId, pMtimerPara->rxRfOn[i].timerPoint, &pMtimerPara->rxRfOn[i].pointL, + //pMtimerPara->rxRfOn[i].timerPoint = pMtimerPara->txRfOff[i].timerPoint + do_read_volatile(JESD_RF_TXOFF2RXON); //JESD_TXRX_CHANGE_GAP; + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->rxRfOn[i].timerPoint, &pMtimerPara->rxRfOn[i].pointL, &pMtimerPara->rxRfOn[i].pointM, &pMtimerPara->rxRfOn[i].pointH); - pMtimerPara->rxRfOff[i].timerPoint = tdd - do_read_volatile(JESD_RF_TXOFF2RXON) - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; //JESD_TXRX_CHANGE_GAP; // tdd-13us - get_jesd_timer_point_para(nTmrId, pMtimerPara->rxRfOff[i].timerPoint, &pMtimerPara->rxRfOff[i].pointL, + pMtimerPara->rxRfOff[i].timerPoint = tdd * 1000 - do_read_volatile(JESD_RF_TXOFF2RXON) - pJesdDelay->gps_offset * 1000 - pMtimerInt->tmrPP1sCost; // pJesdDelay->jesd_10ms2pp1s_txoffset; //JESD_TXRX_CHANGE_GAP; // tdd-13us + //pMtimerPara->rxRfOff[i].timerPoint = tdd - do_read_volatile(JESD_RF_TXOFF2RXON) - pJesdDelay->gps_offset - INT_DELAY; // pJesdDelay->jesd_10ms2pp1s_txoffset; //JESD_TXRX_CHANGE_GAP; // tdd-13us + get_jesd_timer_pointns_para(nTmrId, pMtimerPara->rxRfOff[i].timerPoint, &pMtimerPara->rxRfOff[i].pointL, &pMtimerPara->rxRfOff[i].pointM, &pMtimerPara->rxRfOff[i].pointH); debug_write((DBG_DDR_IDX_DRV_BASE+1000+(i<<2)), pMtimerPara->txRfOn[i].timerPoint); // 0xFA0 @@ -365,16 +393,24 @@ int32_t jesd_timer_reconfig(int32_t nTmrId, phy_timer_config_ind_t *my_jesdtmr) EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); stMtimerPara* pMtimerPara = pEcsDmLocalMgt->pMtimerPara[nTmrId]; stMtimerPara* pMtimerTxPara = pEcsDmLocalMgt->pMtimerPara[nTmrId+2]; - stMtimerPhyPara* pMtimerSfn = &gMtimerSfnNum[nTmrId]; JesdDelay_t* pJesdDelay = pEcsDmLocalMgt->jesd_delay_ptr; + stMtimerPhyPara* pMtimerSfn = &gMtimerSfnNum[nTmrId]; + stMtimerIntStat* pMtimerInt = &gMtimerIntCnt[nTmrId]; uint32_t addr = (uint32_t)&(phyPara[my_jesdtmr->scsId].gpsOffset); uint16_t gpsOffset = do_read_volatile_short(addr); pJesdDelay->gps_offset = gpsOffset; - pJesdDelay->jesd_10ms2pp1s_txoffset = pJesdDelay->tx_offset + gpsOffset; // advance us - pJesdDelay->jesd_10ms2pp1s_rxoffset = pJesdDelay->rx_offset + gpsOffset; // gpsOffset - pJesdDelay->rxOffset; // delay us - pJesdDelay->jesd_tdd2pp1s_offset = gpsOffset + pJesdDelay->tdd_offset; // advance us as positive number + pJesdDelay->tx_offset = pMtimerInt->tmrPP1sCost * 2; + pJesdDelay->rx_offset = pMtimerInt->tmrPP1sCost * 2; + + do_write(CPRI_ADVANCE_ADDR, pJesdDelay->tx_offset); + do_write(CPRI_DELAY_ADDR, pJesdDelay->rx_offset); + do_write(CPRI_TDD_ADVANCE_ADDR, pJesdDelay->tdd_offset); + + pJesdDelay->jesd_10ms2pp1s_txoffset = pJesdDelay->tx_offset + gpsOffset*1000; // advance ns + pJesdDelay->jesd_10ms2pp1s_rxoffset = pJesdDelay->rx_offset + gpsOffset*1000; // gpsOffset - pJesdDelay->rxOffset; // delay ns + pJesdDelay->jesd_tdd2pp1s_offset = gpsOffset*1000 + pJesdDelay->tdd_offset; // advance us as positive number do_write(CPRI_TX_ADVANCE_PP1S_ADDR, pJesdDelay->jesd_10ms2pp1s_txoffset); do_write(CPRI_RX_ADVANCE_PP1S_ADDR, pJesdDelay->jesd_10ms2pp1s_rxoffset); @@ -395,7 +431,7 @@ int32_t jesd_timer_reconfig(int32_t nTmrId, phy_timer_config_ind_t *my_jesdtmr) pMtimerTxPara->slotMaxNum = my_jesdtmr->num_tti_per_sfn; pMtimerSfn->slotMaxNum = my_jesdtmr->num_tti_per_sfn; - pMtimerSfn->slotNumPP1s = (pJesdDelay->jesd_10ms2pp1s_txoffset / my_jesdtmr->t_us) % my_jesdtmr->num_tti_per_sfn; + pMtimerSfn->slotNumPP1s = (pJesdDelay->jesd_10ms2pp1s_txoffset / (my_jesdtmr->t_us*1000)) % my_jesdtmr->num_tti_per_sfn; do_write_short((&(phyPara[scsId].slotNumOfTdd)), my_jesdtmr->num_tti); do_write_short((&(phyPara[scsId].mtimerId)), nTmrId); @@ -682,9 +718,9 @@ void set_jesd_1pps_scratch(int32_t nTmrId) void set_jesd_sfn_offset(int32_t nTmrId) { EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); - uint32_t tmr0Point = SFN_PERIOD - pEcsDmLocalMgt->jesd_delay_ptr->jesd_10ms2pp1s_txoffset; // us + uint32_t tmr0Point = SFN_PERIOD*1000 - pEcsDmLocalMgt->jesd_delay_ptr->jesd_10ms2pp1s_txoffset; // ns - set_mtimer_tmrpoint(nTmrId, MTMR_10ms_OFFSET, tmr0Point, MTIMER_MASK_62BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_10ms_OFFSET, tmr0Point, MTIMER_MASK_62BIT); enable_mtimer_tmrpoint_int(nTmrId, MTMR_10ms_OFFSET, MTMR_INT_10ms); } @@ -694,8 +730,8 @@ void set_jesd_tdd_offset(int32_t nTmrId) stMtimerPara* pMtimerPara = pEcsDmLocalMgt->pMtimerPara[nTmrId]; JesdDelay_t* pJesdDelay = pEcsDmLocalMgt->jesd_delay_ptr; - uint32_t tmr2Point = pMtimerPara->tddPeriod - pJesdDelay->jesd_tdd2pp1s_offset; // us // 5ms - set_mtimer_tmrpoint(nTmrId, MTMR_TDD_OFFSET, tmr2Point, MTIMER_MASK_48BIT); + uint32_t tmr2Point = pMtimerPara->tddPeriod*1000 - pJesdDelay->jesd_tdd2pp1s_offset; // ns // 5ms + set_mtimer_tmrpoint_ns(nTmrId, MTMR_TDD_OFFSET, tmr2Point, MTIMER_MASK_48BIT); enable_mtimer_tmrpoint_int(nTmrId, MTMR_TDD_OFFSET, MTMR_INT_TDD_OFFSET); } @@ -708,9 +744,9 @@ void set_jesd_tx_slot_offset(int32_t nTmrId) { EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); JesdDelay_t* pJesdDelay = pEcsDmLocalMgt->jesd_delay_ptr; - int32_t tmr3Point = SFN_PERIOD - pJesdDelay->jesd_10ms2pp1s_txoffset; // pJesdDelay->tx_offset; // us + int32_t tmr3Point = SFN_PERIOD*1000 - pJesdDelay->jesd_10ms2pp1s_txoffset; // pJesdDelay->tx_offset; // ns - set_mtimer_tmrpoint(nTmrId, MTMR_TXSLOT_OFFSET, tmr3Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_TXSLOT_OFFSET, tmr3Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(nTmrId, MTMR_TXSLOT_OFFSET, MTMR_INT_SLOT_OFFSET); } @@ -723,9 +759,9 @@ void set_jesd_rx_slot_offset(int32_t nTmrId) { EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); JesdDelay_t* pJesdDelay = pEcsDmLocalMgt->jesd_delay_ptr; - int32_t tmr4Point = SFN_PERIOD - pJesdDelay->jesd_10ms2pp1s_txoffset; //gJesdDelay.rxOffset; // // us + int32_t tmr4Point = SFN_PERIOD*1000 - pJesdDelay->jesd_10ms2pp1s_txoffset; //gJesdDelay.rxOffset; // // us - set_mtimer_tmrpoint(nTmrId, MTMR_RXSLOT_OFFSET, tmr4Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_RXSLOT_OFFSET, tmr4Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(nTmrId, MTMR_RXSLOT_OFFSET, MTMR_INT_SLOT_OFFSET); } @@ -750,15 +786,15 @@ int32_t set_jesd_ape_slot_offset(int32_t nTmrId, uint32_t apeCoreId) txOffset = pJesdDelay->jesd_10ms2pp1s_txoffset; rxOffset = pJesdDelay->jesd_10ms2pp1s_txoffset; - uint32_t tmr3Point = SFN_PERIOD - txOffset; // us - uint32_t tmr4Point = SFN_PERIOD - txOffset; // us + uint32_t tmr3Point = SFN_PERIOD*1000 - txOffset; // ns + uint32_t tmr4Point = SFN_PERIOD*1000 - txOffset; // ns if (rxOffset < 0) { tmr4Point = (~rxOffset) + 1; } else { - tmr4Point = SFN_PERIOD - rxOffset; // us + tmr4Point = SFN_PERIOD*1000 - rxOffset; // us } // ape tmrpoints @@ -772,11 +808,11 @@ int32_t set_jesd_ape_slot_offset(int32_t nTmrId, uint32_t apeCoreId) } // tx slot int tmrId = MTMR_APE0_TXSLOT + (apeId<<1); - set_mtimer_tmrpoint(nTmrId, tmrId, tmr3Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(nTmrId, tmrId, tmr3Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(nTmrId, tmrId, (MTMR_INT_APE0_SLOT+apeId)); // rx slot int tmrId = MTMR_APE0_RXSLOT + (apeId<<1); - set_mtimer_tmrpoint(nTmrId, tmrId, tmr4Point, MTIMER_MASK_32BIT); + set_mtimer_tmrpoint_ns(nTmrId, tmrId, tmr4Point, MTIMER_MASK_32BIT); enable_mtimer_tmrpoint_int(nTmrId, tmrId, (MTMR_INT_APE0_SLOT+apeId)); runCore &= (~(1 << apeId)); @@ -997,7 +1033,7 @@ void set_jesd_txon_point(int32_t nTmrId, uint8_t nPointId) int32_t tmr29Point = pMtimerPara->txRfOn[nPointId].timerPoint; - set_mtimer_tmrpoint(nTmrId, MTMR_JESD_TXON, tmr29Point, MTIMER_MASK_48BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_JESD_TXON, tmr29Point, MTIMER_MASK_48BIT); enable_mtimer_tmrpoint_int(nTmrId, MTMR_JESD_TXON, MTMR_INT_TDD_OFFSET); } @@ -1021,7 +1057,7 @@ void set_jesd_txoff_point(int32_t nTmrId, uint8_t nPointId) #if 1 int32_t tmr28Point = pMtimerPara->txRfOff[nPointId].timerPoint; - set_mtimer_tmrpoint(nTmrId, MTMR_JESD_TXOFF, tmr28Point, MTIMER_MASK_48BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_JESD_TXOFF, tmr28Point, MTIMER_MASK_48BIT); #else uint32_t startTick = 0; uint32_t cost = 0; @@ -1057,7 +1093,7 @@ void set_jesd_rxon_point(int32_t nTmrId, uint8_t nPointId) #if 1 int32_t tmr26Point = pMtimerPara->rxRfOn[nPointId].timerPoint; - set_mtimer_tmrpoint(nTmrId, MTMR_JESD_RXON, tmr26Point, MTIMER_MASK_48BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_JESD_RXON, tmr26Point, MTIMER_MASK_48BIT); #else do_write((tmrBaseAddr + MTMR_TnL_REG0 + (MTMR_JESD_RXON<<3)), pMtimerPara->rxRfOn[nPointId].pointL); do_write((tmrBaseAddr + MTMR_TnH_REG0 + (MTMR_JESD_RXON<<3)), ((MTIMER_MASK_48BIT<<30) + pMtimerPara->rxRfOn[nPointId].pointM)); @@ -1088,7 +1124,7 @@ void set_jesd_rxoff_point(int32_t nTmrId, uint8_t nPointId) int32_t tmr27Point = pMtimerPara->rxRfOff[nPointId].timerPoint; - set_mtimer_tmrpoint(nTmrId, MTMR_CSU_INSERT, tmr27Point, MTIMER_MASK_48BIT); + set_mtimer_tmrpoint_ns(nTmrId, MTMR_CSU_INSERT, tmr27Point, MTIMER_MASK_48BIT); enable_mtimer_tmrpoint_int(nTmrId, MTMR_CSU_INSERT, MTMR_INT_TDD_OFFSET); } @@ -1204,7 +1240,9 @@ void jesd_10ms_callback(uint8_t nTmrId) if (MTIMER_JESD_RX0_ID == nTmrId) { start_jesd_timer(MTIMER_JESD_TX0_ID); + debug_write((DBG_DDR_IDX_DRV_BASE+57), GET_STC_CNT()); } + pMtimerInt->tmrPP1sCost = GET_STC_CNT(); } if (MTIMER_JESD_RX1_ID == nTmrId) @@ -1215,7 +1253,7 @@ void jesd_10ms_callback(uint8_t nTmrId) #ifdef ENABLE_SFNCAL if (MTIMER_JESD_RX0_ID == nTmrId) { - debug_write((DBG_DDR_IDX_DRV_BASE+57), GET_STC_CNT()); + //debug_write((DBG_DDR_IDX_DRV_BASE+57), GET_STC_CNT()); mtimer_1pps_func(nTmrId); } #endif diff --git a/public/ecs_rfm_spu1/driver/src/mtimer_cell.s.c b/public/ecs_rfm_spu1/driver/src/mtimer_cell.s.c index bbd4cd5..4a40e30 100644 --- a/public/ecs_rfm_spu1/driver/src/mtimer_cell.s.c +++ b/public/ecs_rfm_spu1/driver/src/mtimer_cell.s.c @@ -94,7 +94,9 @@ int32_t mtimer_reconfig(phy_timer_config_ind_t *my_mtmr) flag++; debug_write((DBG_DDR_IDX_DRV_BASE+32), flag); // 0xb7e06080 debug_write((DBG_DDR_IDX_DRV_BASE+34), my_mtmr->runCoreId); // 0xb7e06088 - } + debug_write((DBG_DDR_IDX_DRV_BASE+35), nScsId); // 0xb7e0608c + debug_write((DBG_DDR_IDX_DRV_BASE+35), my_mtmr->scsId); // 0xb7e06090 + } else // ѽС { flag++; diff --git a/public/ecs_rfm_spu1/driver/src/mtimer_drv.s.c b/public/ecs_rfm_spu1/driver/src/mtimer_drv.s.c index 4382deb..f8a6ce9 100644 --- a/public/ecs_rfm_spu1/driver/src/mtimer_drv.s.c +++ b/public/ecs_rfm_spu1/driver/src/mtimer_drv.s.c @@ -326,6 +326,65 @@ int32_t set_mtimer_tmrpoint(uint8_t nTmrId, uint8_t nPointId, int32_t nTmrPoint, return 0; } +// nTmrPoint: ns as unit +int32_t set_mtimer_tmrpoint_ns(uint8_t nTmrId, uint8_t nPointId, int32_t nTmrPoint, uint8_t mask) +{ + uint32_t tmrBaseAddr = mtimer_get_baseaddr(nTmrId); + if (0 == tmrBaseAddr) + { + return -1; + } + + EcsRfmDmLocalMgt_t* pEcsDmLocalMgt = get_ecs_rfm_dm_local_mgt(); + stMtimerPara* pMtimerPara = pEcsDmLocalMgt->pMtimerPara[nTmrId]; + //uint32_t periodL = pMtimerPara->tempL_max + 1; + uint32_t periodM = pMtimerPara->tempM_max + 1; + //uint32_t periodH = pMtimerPara->tempH_max + 1; + + if (nTmrPoint < 0) + { + nTmrPoint += (SFN_PERIOD*1000); + } + + uint32_t tempL = (uint64_t)pMtimerPara->tmrMsPeriod * (nTmrPoint % (pMtimerPara->slotPeriod*1000)) / 1000000; + uint32_t tempM = (nTmrPoint / (pMtimerPara->slotPeriod*1000)) % periodM; + uint32_t tempH = (nTmrPoint / (pMtimerPara->slotPeriod*1000)) / periodM; + if ((0 == tempM) && (0 == tempL)) + { + tempH = (tempH > 0) ? (tempH - 1) : (pMtimerPara->tempH_max); + tempM = (tempM > 0) ? (tempM - 1) : (pMtimerPara->tempM_max); + } + else if (0 == tempL) + { + tempM = (tempM > 0) ? (tempM - 1) : (pMtimerPara->tempM_max); + } + tempL = (tempL > 0) ? (tempL - 1) : (pMtimerPara->tempL_max); + + if (MTIMER_MASK_32BIT == mask) + { + tempH = 0; + tempM = 0; + } + else if (MTIMER_MASK_48BIT == mask) + { + tempH = 0; + } +#ifdef PALLADIUM_TEST + debug_write((DBG_DDR_IDX_DRV_BASE+128+4+(nPointId<<2)+(nTmrId<<7)), nTmrPoint); // 0x210 + debug_write((DBG_DDR_IDX_DRV_BASE+128+5+(nPointId<<2)+(nTmrId<<7)), tempL); // 0x214 + debug_write((DBG_DDR_IDX_DRV_BASE+128+6+(nPointId<<2)+(nTmrId<<7)), tempM); // 0x218 + debug_write((DBG_DDR_IDX_DRV_BASE+128+7+(nPointId<<2)+(nTmrId<<7)), tempH); // 0x21c +#endif + + do_write((tmrBaseAddr + MTMR_TnL_REG0 + (nPointId<<3)), tempL); + do_write((tmrBaseAddr + MTMR_TnH_REG0 + (nPointId<<3)), ((mask<<30) + (tempH<<16) + tempM)); + do_write((tmrBaseAddr + MTMR_TWREQ0_REG + ((nPointId>>5)<<2)), (1<<(nPointId&0x1F))); + __ucps2_synch(0); + while(do_read_volatile(tmrBaseAddr + MTMR_TWREQ0_REG + ((nPointId>>5)<<2)) & (1<<(nPointId&0x1F))); // REQ reg, wait until the T0L and T0H set finished + + return 0; +} + int32_t enable_mtimer_tmrpoint_int(uint8_t nTmrId, uint8_t nPointId, uint8_t nIntcId) { uint32_t tmrBaseAddr = mtimer_get_baseaddr(nTmrId); diff --git a/public/ecs_rfm_spu1/driver/src/rfm1_drv.s.c b/public/ecs_rfm_spu1/driver/src/rfm1_drv.s.c index e9e7c7d..e644703 100644 --- a/public/ecs_rfm_spu1/driver/src/rfm1_drv.s.c +++ b/public/ecs_rfm_spu1/driver/src/rfm1_drv.s.c @@ -152,7 +152,7 @@ int32_t check_phy_cell(void) //clockCnt = clockEnd - clockBegin; //debug_write((DBG_DDR_IDX_DRV_BASE+900), clockCnt); // 0xe10 - if (0 != ret) + if (0 > ret) { UCP_PRINT_ERROR("mtimer_reconfig failed. \r\n"); return ret;