⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reg0297j.c

📁 st7710的tuner标准驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_SOFT_RESET,0);
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    STTBX_Print(("%s ==> SOFT RESET\n", identity));
#endif
}
/**/
/******* GetSymbolRate ***********/
/*********************************/
unsigned long	Reg0297J_GetSymbolRate(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_GetSymbolRate()";
#endif
    unsigned long   regsym;
    long            _ExtClk;
    unsigned long   RegSymbolRate;
    U8 temp[3];

    /**/
    _ExtClk = DeviceMap->RegExtClk;
    STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_STLOOP_5, 4, temp);
    regsym  = temp[0];
    regsym += (temp[1]*256L);
    regsym += (temp[2]*65536L);
    regsym += (temp[3]*16777216L);

    if(regsym < 134217728L)         /* 134217728L = 2**27 */
                                    /* # 1.56 MBd (clock = 50 MHz) */
	{
        regsym = regsym * 32;       /* 32 = 2**5 */
        regsym = regsym / 65536L;   /* 65536L = 2**16 */
        regsym = _ExtClk * regsym;  /* _ExtClk in kHz */
        RegSymbolRate = regsym/256L;/* 256 = 2**8 */
        RegSymbolRate *= 125 ;      /* 125 = 1000/2**3 */
        RegSymbolRate /= 1024 ;     /* 1024 = 2**10 */
	}
    else if(regsym < 268435456L)    /* 268435456L = 2**28 */
                                    /* # 3.13 MBd (clock = 50 MHz) */
	{
        regsym = regsym * 16;       /* 16 = 2**4 */
        regsym = regsym / 65536L;   /* 65536L = 2**16 */
        regsym = _ExtClk * regsym;  /* _ExtClk in kHz */
        RegSymbolRate = regsym/256L;/* 256 = 2**8 */
        RegSymbolRate *= 125 ;      /* 125 = 1000/2**3 */
        RegSymbolRate /= 512 ;      /* 512 = 2**9 */
	}
    else if(regsym < 536870912L)    /* 536870912L = 2**29 */
                                    /* # 6.25 MBd (clock = 50 MHz) */
	{
        regsym = regsym * 8;        /* 8 = 2**3 */
        regsym = regsym / 65536L;   /* 65536L = 2**16 */
        regsym = _ExtClk * regsym;  /* _ExtClk in kHz */
        RegSymbolRate = regsym/256L;/* 256 = 2**8 */
        RegSymbolRate *= 125 ;      /* 125 = 1000/2**3 */
        RegSymbolRate /= 256 ;      /* 256 = 2**8 */
	}
	else
	  {
        regsym = regsym * 4;        /* 8 = 2**2 */
        regsym = regsym / 65536L;   /* 65536L = 2**16 */
        regsym = _ExtClk * regsym;  /* _ExtClk in kHz */
        RegSymbolRate = regsym/256L;/* 256 = 2**8 */
        RegSymbolRate *= 125 ;      /* 125 = 1000/2**3 */
        RegSymbolRate /= 128 ;      /* 128 = 2**7 */
	  }

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    STTBX_Print(("%s ==> SR %u\n", identity, RegSymbolRate));
#endif
    return(RegSymbolRate);
}
/******* SetSymbolRate ***********/
/*********************************/
void	Reg0297J_SetSymbolRate(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, unsigned long _SymbolRate)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_SetSymbolRate()";
#endif
    unsigned long   ulong_tmp;
    long            _ExtClk;
    U8 temp[3];

    /**/
    _ExtClk = DeviceMap->RegExtClk;
    ulong_tmp = _SymbolRate ;  /* _SymbolRate is in Bd */

    if(ulong_tmp < 2097152L)        /* 8388608 = 2**21 */
	{
        ulong_tmp *= 2048 ;             /* 2048 = 2**11 */
		ulong_tmp = ulong_tmp /_ExtClk ;
        ulong_tmp = ulong_tmp * 32768L; /* 8192 = 2**15 */
        ulong_tmp /= 125 ;              /* 125 = 1000/2**3 */
        ulong_tmp = ulong_tmp * 8L;     /* 8 = 2**3 */
	}
    else if(ulong_tmp < 4194304L)   /* 4194304 = 2**22 */
	{
        ulong_tmp *= 1024 ;             /* 1024 = 2**10 */
		ulong_tmp = ulong_tmp /_ExtClk ;
        ulong_tmp = ulong_tmp * 32768L; /* 8192 = 2**15 */
        ulong_tmp /= 125 ;              /* 125 = 1000/2**3 */
        ulong_tmp = ulong_tmp * 16L;    /* 16 = 2**4 */
	}
    else if(ulong_tmp < 8388607L)   /* 8388607 = 2**23 */
	{
        ulong_tmp *= 512 ;              /* 512 = 2**9 */
		ulong_tmp = ulong_tmp /_ExtClk ;
        ulong_tmp = ulong_tmp * 32768L; /* 8192 = 2**15 */
        ulong_tmp /= 125 ;              /* 125 = 1000/2**3 */
        ulong_tmp = ulong_tmp * 32L;    /* 32 = 2**5 */
	}
	else
	{
        ulong_tmp *= 256 ;              /* 256 = 2**8 */
		ulong_tmp = ulong_tmp /_ExtClk ;
        ulong_tmp = ulong_tmp * 32768L; /* 8192 = 2**15 */
        ulong_tmp /= 125 ;              /* 125 = 1000/2**3 */
        ulong_tmp = ulong_tmp * 64L;    /* 64 = 2**6 */
	}
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    STTBX_Print(("%s ==> SR %u (%u)\n", identity, _SymbolRate, ulong_tmp));
#endif
       
    temp[0]=(int)(MAC0297J_B0(ulong_tmp));
    temp[1]=(int)(MAC0297J_B1(ulong_tmp));
    temp[2]=(int)(MAC0297J_B2(ulong_tmp));
    temp[3]=(int)(MAC0297J_B3(ulong_tmp));
    STTUNER_IOREG_SetContigousRegisters(DeviceMap, IOHandle, R0297J_STLOOP_5, temp, 4);

    return;
}
/****** RegSetSpectrumInversion *********************************************/
/* Sets the spectrum inversion                                              */
/****************************************************************************/
void    Reg0297J_SetSpectrumInversion(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, STTUNER_Spectrum_t SpectrumInversion)
{
    if(SpectrumInversion == TRUE)
        STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_SPEC_INV, 1);
    else
        STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_SPEC_INV, 0);

	return;
}
/******* SetSweepRate ************/
/*                               */
/*********************************/
void	Reg0297J_SetSweepRate(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, short _FShift)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_SetSweepRate()";
#endif
    long            long_tmp;
    short           FShift ;
    unsigned long   ulong_tmp ;
    U8 temp[1],try1;
    /**/
    FShift = _FShift ;  /* in ms */
    ulong_tmp = Reg0297J_GetSymbolRate(DeviceMap, IOHandle) ;  /* in Baud/s */
    /**/
    long_tmp = FShift * 262144L ;  /* 262144 = 2*18 */
    ulong_tmp /= 1024 ;
    long_tmp /= (long) ulong_tmp ;
    long_tmp /= 1000 ;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    STTBX_Print(("%s ==> _FShift %d long_tmp %d %x\n", identity, _FShift, long_tmp, long_tmp));
#endif
 
    temp[0]=(int)(MAC0297J_B0(long_tmp));   
    try1=STTUNER_IOREG_GetRegister(DeviceMap,IOHandle,R0297J_CRL_13);
    temp[1]=try1&0xE0;
    temp[1]=temp[1]|((int)(MAC0297J_B1(long_tmp)));
    STTUNER_IOREG_SetContigousRegisters(DeviceMap, IOHandle, R0297J_CRL_13, temp, 2);
    return;
}

/******* SetFrequencyOffset *********/
/*                                  */
/************************************/
void	Reg0297J_SetFrequencyOffset(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle, long _CarrierOffset)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_SetFrequencyOffset()";
#endif
    long long_tmp;
    long CarrierOffset ;
    U8 temp[3],try1;
    /**/
    CarrierOffset = _CarrierOffset     ; /* in 0/000 of Fs */
    /**/
    long_tmp = CarrierOffset * 26844L ; /* (2**28)/10000 */
    if(long_tmp < 0) long_tmp += 0x10000000 ;
    long_tmp &= 0x0FFFFFFF ;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    STTBX_Print(("%s ==> _CarrierOffset %d long_tmp %d %x\n", identity, _CarrierOffset, long_tmp, long_tmp));
#endif
  
    temp[0]=(int)(MAC0297J_B0(long_tmp));
    temp[1]=(int)(MAC0297J_B1(long_tmp));
    temp[2]=(int)(MAC0297J_B2(long_tmp));
    try1=STTUNER_IOREG_GetRegister(DeviceMap,IOHandle,R0297J_CRL_9);
    temp[3]=try1&0xE0;
    temp[3]=temp[3]|((int)(MAC0297J_B3(long_tmp)));
    STTUNER_IOREG_SetContigousRegisters(DeviceMap, IOHandle, R0297J_CRL_9, temp, 4);
    return;
}



unsigned short  Reg0297J_GetBlkCounter(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_GetBlkCounter()";
#endif
    unsigned short Value;
    U8 temp[1];
    if (STTUNER_IOREG_GetField(DeviceMap, IOHandle, F0297J_FEC_AC_OR_B) == 1)
    {
        STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_RS_DESC_0, 2, temp);
        Value =  temp[0];
        Value += temp[1]<<8;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
        STTBX_Print(("%s ==> BlkCounter (FEC_AC_OR_B==1) %u\n", identity, Value));
#endif
    }
    else
    {
        STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_RS_UNERR_CNT_0, 2, temp);
        Value =  temp[0];
        Value += temp[1]<<8;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
        STTBX_Print(("%s ==> BlkCounter (FEC_AC_OR_B==0) %u\n", identity, Value));
#endif
    }
    return(Value);
}



unsigned short  Reg0297J_GetCorrBlk(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_GetCorrBlk()";
#endif
    unsigned short Value;
    U8 temp[1];
    if (STTUNER_IOREG_GetField(DeviceMap, IOHandle, F0297J_FEC_AC_OR_B) == 1)
    {
        STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_RS_DESC_2, 2, temp);
        Value =  temp[0];
        Value += temp[1]<<8;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
        STTBX_Print(("%s ==> CorrBlk (FEC_AC_OR_B==1) %u\n", identity, Value));
#endif
    }
    else
    {
        STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_RS_CORR_CNT_0, 2, temp);
        Value =  temp[0];
        Value += temp[1]<<8;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
        STTBX_Print(("%s ==> CorrBlk (FEC_AC_OR_B==0) %u\n", identity, Value));
#endif
    }
    return(Value);
}



unsigned short  Reg0297J_GetUncorrBlk(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_GetUncorrBlk()";
#endif
    unsigned short Value;
    U8 temp[1];
    if (STTUNER_IOREG_GetField(DeviceMap, IOHandle, F0297J_FEC_AC_OR_B) == 1)
    {
        STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_RS_DESC_4, 2, temp);
        Value =  temp[0];
        Value += temp[1]<<8;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
        STTBX_Print(("%s ==> UncorrBlk (FEC_AC_OR_B==1) %u\n", identity, Value));
#endif
    }
    else
    {
        STTUNER_IOREG_GetContigousRegisters(DeviceMap, IOHandle, R0297J_RS_UNC_CNT_0, 2, temp);
        Value =  temp[0];
        temp[1]=temp[1]&0x1F;
        Value += temp[1]<<8;
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
        STTBX_Print(("%s ==> UncorrBlk (FEC_AC_OR_B==0) %u\n", identity, Value));
#endif
    }
    return(Value);
}


/* ----------------------------------------------------------------------------
Name: Reg0297J_GetSTV0297JId()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
U8 Reg0297J_GetSTV0297JId(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    const char *identity = "STTUNER reg0297J.c Reg0297J_GetSTV0297JId()";
#endif
    U8    Value;

    Value =   0x11;     /* See top-view package */

#ifdef STTUNER_DEBUG_MODULE_CABDRV_REG0297J
    STTBX_Print(("%s ==> Version %x\n", identity, Value));
#endif
    return(Value);
}

/* ----------------------------------------------------------------------------
Name: Reg0297J_StartBlkCounter()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297J_StartBlkCounter(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_CT_HOLD, 0);
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_CT_CLEAR, 0);
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_CT_CLEAR, 1);
}

/* ----------------------------------------------------------------------------
Name: Reg0297J_StopBlkCounter()

Description:

Parameters:

Return Value:
---------------------------------------------------------------------------- */
void Reg0297J_StopBlkCounter(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle)
{
    STTUNER_IOREG_SetField(DeviceMap, IOHandle, F0297J_CT_HOLD, 1);
}

/* End of reg0297J.c */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -