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

📄 stv0297.c

📁 机顶盒解调芯片DCF8722驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEM_RETURN st0_stl_unfreeze (u_int8 i2cAddr)
{
   /* unfreeze all blocks that work at symbol rate. */
   gDemReg[ST0_RID_STLOOP_10].value = gDemReg[ST0_RID_STLOOP_10].value & 0xDF;
   st0_set_a_reg( i2cAddr, ST0_RID_STLOOP_10);
   return (DEM_OK);
}

/*****************************************************************************/
/*  FUNCTION:    st0_set_symbol_rate                                         */
/*                                                                           */
/*  PARAMETERS:  i2cAddr  - the i2c address for accessing STV0297 registers. */
/*               uSR - a 32-bit symbol timing frequency.                     */
/*                                                                           */
/*  DESCRIPTION: The function sets 32-bit symbol timing frequency            */
/*               by programming STLOOP_5 / STLOOP_6 / STLOOP_7 / STLOOP_8    */
/*               register.                                                   */
/*                                                                           */
/*  RETURNS:     DEM_OK if successful, DEM_ERROR if unsuccessful.            */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEM_RETURN st0_set_symbol_rate (u_int8 i2cAddr, u_int32 uSR)
{
   gDemReg[ST0_RID_STLOOP_5].value = (u_int8)(uSR & 0x000000FF);
   gDemReg[ST0_RID_STLOOP_6].value = (u_int8)((uSR >> 8) & 0x000000FF);
   gDemReg[ST0_RID_STLOOP_7].value = (u_int8)((uSR >> 16) & 0x000000FF);
   gDemReg[ST0_RID_STLOOP_8].value = (u_int8)((uSR >> 24) & 0x000000FF);
   
   st0_set_a_reg( i2cAddr, ST0_RID_STLOOP_5);
   st0_set_a_reg( i2cAddr, ST0_RID_STLOOP_6);
   st0_set_a_reg( i2cAddr, ST0_RID_STLOOP_7);
   st0_set_a_reg( i2cAddr, ST0_RID_STLOOP_8);
   return (DEM_OK);
}

/*****************************************************************************/
/*  FUNCTION:    st0_get_symbol_rate                                         */
/*                                                                           */
/*  PARAMETERS:  i2cAddr  - the i2c address for accessing STV0297 registers. */
/*               pData - the pointer to the return data.                     */
/*                                                                           */
/*  DESCRIPTION: The function gets 32-bit symbol timing frequency            */
/*               by reading STLOOP_5 / STLOOP_6 / STLOOP_7 / STLOOP_8 REGs.  */
/*                                                                           */
/*  RETURNS:     DEM_OK if successful, DEM_ERROR if unsuccessful.            */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEM_RETURN st0_get_symbol_rate (u_int8 i2cAddr, u_int32 *pData)
{
   u_int32     uTemp;
   
   st0_get_a_reg( i2cAddr, ST0_RID_STLOOP_5);
   st0_get_a_reg( i2cAddr, ST0_RID_STLOOP_6);
   st0_get_a_reg( i2cAddr, ST0_RID_STLOOP_7);
   st0_get_a_reg( i2cAddr, ST0_RID_STLOOP_8);
   
   uTemp  = ((u_int32)(gDemReg[ST0_RID_STLOOP_8].value) << 24);
   uTemp += ((u_int32)(gDemReg[ST0_RID_STLOOP_7].value) << 16);
   uTemp += ((u_int32)(gDemReg[ST0_RID_STLOOP_6].value) << 8);
   uTemp += (u_int32)(gDemReg[ST0_RID_STLOOP_5].value);
   *pData = uTemp;
   return (DEM_OK);
}

/*****************************************************************************/
/*  FUNCTION:    st0_crl_init                                                */
/*                                                                           */
/*  PARAMETERS:  i2cAddr  - the i2c address for accessing STV0297 registers. */
/*                                                                           */
/*  DESCRIPTION: The function initialize the carrier recovery loop           */
/*               by programming the CRL_n registers.                         */
/*                                                                           */
/*  RETURNS:     DEM_OK if successful, DEM_ERROR if unsuccessful.            */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEM_RETURN st0_crl_init (u_int8 i2cAddr)
{
   /* Frequency Offset Clear */
   gDemReg[ST0_RID_CRL_3].value = 0x00;
   gDemReg[ST0_RID_CRL_4].value = 0x00;
   gDemReg[ST0_RID_CRL_5].value = 0x00;
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_3);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_4);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_5);
   gDemReg[ST0_RID_CRL_6].value = 0x00;
   gDemReg[ST0_RID_CRL_7].value = 0x00;
   gDemReg[ST0_RID_CRL_8].value = 0x00;
   gDemReg[ST0_RID_CRL_9].value = 0x00;
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_6);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_7);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_8);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_9);
   /* Disable Sweep */
   gDemReg[ST0_RID_CRL_10].value = gDemReg[ST0_RID_CRL_10].value & 0xFE;
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_10);
   return (DEM_OK);
}


DEM_RETURN st0_set_sweep_rate (u_int8 i2cAddr, u_int32 uSWEEP)
{
   gDemReg[ST0_RID_CRL_0].value  = (u_int8)(uSWEEP & 0x000000FF);
   gDemReg[ST0_RID_CRL_9].value |= (u_int8)((uSWEEP >> 4) & 0x000000F0);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_0);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_9);
   return (DEM_OK);
}


DEM_RETURN st0_set_iphase (u_int8 i2cAddr, int32 iIPHASE)
{
   gDemReg[ST0_RID_CRL_6].value  = (u_int8)(iIPHASE & 0x000000FF);
   gDemReg[ST0_RID_CRL_7].value  = (u_int8)((iIPHASE >> 8) & 0x000000FF);
   gDemReg[ST0_RID_CRL_8].value  = (u_int8)((iIPHASE >> 16) & 0x000000FF);
   gDemReg[ST0_RID_CRL_9].value |= (u_int8)((iIPHASE >> 24) & 0x0000000F);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_6);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_7);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_8);
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_9);
   return (DEM_OK);
}

/*****************************************************************************/
/*  FUNCTION:    st0_pmfagc_init                                             */
/*                                                                           */
/*  PARAMETERS:  i2cAddr  - the i2c address for accessing STV0297 registers. */
/*                                                                           */
/*  DESCRIPTION: The function initialize the post-filter digital AGC module  */
/*               by programming the PMFAGC_n registers.                      */
/*                                                                           */
/*  RETURNS:     DEM_OK if successful, DEM_ERROR if unsuccessful.            */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEM_RETURN st0_pmfagc_init (u_int8 i2cAddr)
{
   /* 1: override the internal PMFAGC lock status bit to "unlocked" */
   gDemReg[ST0_RID_PMFAGC_1].value = gDemReg[ST0_RID_PMFAGC_1].value | 0x80;
   st0_set_a_reg( i2cAddr, ST0_RID_PMFAGC_1);
   /* 2: reset the PMFAGC accumulator. */
   gDemReg[ST0_RID_PMFAGC_2].value = 0x00;
   gDemReg[ST0_RID_PMFAGC_3].value = 0x00;
   gDemReg[ST0_RID_PMFAGC_4].value = 0x00;
   st0_set_a_reg( i2cAddr, ST0_RID_PMFAGC_2);
   st0_set_a_reg( i2cAddr, ST0_RID_PMFAGC_3);
   st0_set_a_reg( i2cAddr, ST0_RID_PMFAGC_4);
   return (DEM_OK);
}

/*****************************************************************************/
/*  FUNCTION:    st0_fec_init                                                */
/*                                                                           */
/*  PARAMETERS:  i2cAddr  - the i2c address for accessing STV0297 registers. */
/*                                                                           */
/*  DESCRIPTION: The function initialize the FEC modules                     */
/*               by programming the PMFAGC_n registers.                      */
/*                                                                           */
/*  RETURNS:     DEM_OK if successful, DEM_ERROR if unsuccessful.            */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEM_RETURN st0_fec_init (u_int8 i2cAddr)
{
   /* 1: software reset the deinterleaver & descrambler */
   st0_di_swreset (i2cAddr);
   /* 2: force the deinterleaver sync detector to unlock */
   gDemReg[ST0_RID_DEINT_SYNC_0].value = gDemReg[ST0_RID_DEINT_SYNC_0].value | 0x80;
   st0_set_a_reg( i2cAddr, ST0_RID_DEINT_SYNC_0);
   gDemReg[ST0_RID_DEINT_SYNC_0].value = gDemReg[ST0_RID_DEINT_SYNC_0].value & 0x7F;
   st0_set_a_reg( i2cAddr, ST0_RID_DEINT_SYNC_0);
   /* 3: set the polarity of the lock indicator signal, and enable the DI_SYNC
    *    & the SYNC interrupts, clear the DI_SYNC & the SYNC interrupt events.
    */
   gDemReg[ST0_RID_CTRL_5].value = 0x80;
   st0_set_a_reg( i2cAddr, ST0_RID_CTRL_5);
   /* 4: set the number of states required to unlock */
   gDemReg[ST0_RID_DEINT_SYNC_0].value = gDemReg[ST0_RID_DEINT_SYNC_0].value | 0x02;
   st0_set_a_reg( i2cAddr, ST0_RID_DEINT_SYNC_0);
   /* 5: software reset the Reed-Solomon block */
   st0_rs_swreset (i2cAddr);
   return (DEM_OK);
}


DEM_RETURN st0_acquisition_1 (u_int8 i2cAddr)
{
   /* enable the detection of corner points */
   // gDemReg[ST0_RID_CTRL_8].value = gDemReg[ST0_RID_CTRL_8].value | 0x08;
   // st0_set_a_reg( i2cAddr, ST0_RID_CTRL_8);
   /* unfreeze all blocks that work at symbol rate. */
   st0_stl_unfreeze (i2cAddr);
   /* set the roll value of WBAGC. 0x0258 or 0x0180 */
   gDemReg[ST0_RID_WBAGC_9].value = gDemReg[ST0_RID_WBAGC_9].start; /* high byte of a 12-bit unsigned */
   gDemReg[ST0_RID_WBAGC_4].value = gDemReg[ST0_RID_WBAGC_4].start; /*  low byte of a 12-bit unsigned */
   st0_set_a_reg( i2cAddr, ST0_RID_WBAGC_9);
   st0_set_a_reg( i2cAddr, ST0_RID_WBAGC_4);
   /* enable the WBAGC loop */
   gDemReg[ST0_RID_WBAGC_3].value = gDemReg[ST0_RID_WBAGC_3].value | 0x10;
   st0_set_a_reg( i2cAddr, ST0_RID_WBAGC_3);
   return (DEM_OK);
}

DEM_RETURN st0_acquisition_2 (u_int8 i2cAddr)
{
   #if (0)
   /* set the roll value of WBAGC */
   gDemReg[ST0_RID_WBAGC_9].value = 0x12; /* high byte of a 12-bit unsigned */
   gDemReg[ST0_RID_WBAGC_4].value = 0x80; /*  low byte of a 12-bit unsigned */
   st0_set_a_reg( i2cAddr, ST0_RID_WBAGC_9);
   st0_set_a_reg( i2cAddr, ST0_RID_WBAGC_4);
   #endif
   /* enable sweep */
   gDemReg[ST0_RID_CRL_10].value = gDemReg[ST0_RID_CRL_10].value | 0x01;
   st0_set_a_reg( i2cAddr, ST0_RID_CRL_10);
   /* override the internal PMFAGC lock status bit to "unlocked" */
   gDemReg[ST0_RID_PMFAGC_1].value = gDemReg[ST0_RID_PMFAGC_1].value & 0x7F;
   st0_set_a_reg( i2cAddr, ST0_RID_PMFAGC_1);
   return (DEM_OK);
}

DEM_RETURN st0_acquisition_3 (u_int8 i2cAddr)
{
   /* disable sweep */
   // gDemReg[ST0_RID_CRL_10].value = gDemReg[ST0_RID_CRL_10].value & 0xFE;
   // st0_set_a_reg( i2cAddr, ST0_RID_CRL_10);
   /* disable the detection of corner points */
   // gDemReg[ST0_RID_CTRL_8].value = gDemReg[ST0_RID_CTRL_8].value & 0xF7;
   // st0_set_a_reg( i2cAddr, ST0_RID_CTRL_8);
   return (DEM_OK);
}


/*****************************************************************************/
/*  FUNCTION:    st0_start_bert                                              */
/*                                                                           */
/*  PARAMETERS:  i2cAddr  - the i2c address for accessing STV0297 registers. */
/*               ui8Mode  - the BERT working mode.                           */
/*                                                                           */
/*  DESCRIPTION: The function starts

⌨️ 快捷键说明

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