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

📄 dcf_tua6020.c

📁 机顶盒解调芯片DCF8722驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
      u8WaitCount++;
      if(u8WaitCount == 5)
         return(False);
   }

   /* recover the old tuner charge pump current. */
   TUA_TUNER_DRIVER_Set_CP(pNim, pNim->tuner.tua6020.tuner_charge_pump);

   return(True);
}

/*****************************************************************************/
/*  FUNCTION:    Tuner_STUA_TUNER_DRIVER_Set_CP                              */
/*                                                                           */
/*  PARAMETERS:  pNim  - pointer to the DCF_NIM structure                    */
/*               ui8CP - the definition of tuner charge pump current mode    */
/*                                                                           */
/*  DESCRIPTION: The function sets the tuner charge pump current.            */
/*               The tuner default charge pump current is 50 uA.             */
/*                                                                           */
/*  RETURNS:     True if successful, False if unsuccessful.                  */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static bool TUA_TUNER_DRIVER_Set_CP(DCF_NIM *pNim, unsigned char u8CP)
{
   switch(u8CP)
   {
      case DCF_TUA_CP_220:
         /* tuner_shadow[2] - x1xx xxxx b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] | 0x40;
         break;
      
      case DCF_TUA_CP_50:
         /* tuner_shadow[2] - x0xx xxxx b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] & 0xBF;
         break;
      
      default:
         /* tuner_shadow[2] - x0xx xxxx b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] & 0xBF;
         break;
   }
   return(True);
}

/*****************************************************************************/
/*  FUNCTION:    TUA_TUNER_DRIVER_Get_CP                                     */
/*                                                                           */
/*  PARAMETERS:  pCFG - pointer to the CNIM_CFG structure                    */
/*               pu8Data - pointer to the return data                        */
/*                                                                           */
/*  DESCRIPTION: The function gets the current tuner charge pump current.    */
/*                                                                           */
/*  RETURNS:     True if successful, False if unsuccessful.                  */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static bool TUA_TUNER_DRIVER_Get_CP(DCF_NIM *pNim, unsigned char *pu8Data)
{
   /* sanity check */
   if(pNim == NULL)
      return(False);

   /* tuner_shadow[2] - x?xx xxxx b */
   if(pNim->tuner.tua6020.tuner_shadow[2] & 0x40)
   {
      *pu8Data = DCF_TUA_CP_220;
   }
   else
   {
      *pu8Data = DCF_TUA_CP_50;
   }
   return(True);
}


/*****************************************************************************/
/*  FUNCTION:    TUA_TUNER_DRIVER_Set_Step                                   */
/*                                                                           */
/*  PARAMETERS:  pNim - pointer to the DCF_NIM structure                     */
/*               u32Step - the definition of tuner step                      */
/*                                                                           */
/*  DESCRIPTION: The function sets the tuner reference frequency (step).     */
/*               The tuner default IF is 36000000 Hz. (FOR 36 MHz ONLY)      */
/*               The tuner default step is 62500 Hz.                         */
/*                                                                           */
/*  RETURNS:     True if successful, False if unsuccessful.                  */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static bool TUA_TUNER_DRIVER_Set_Step (DCF_NIM *pNim, unsigned long u32Step)
{
   switch(u32Step)
   {
      case DCF_STEP_31250:
         /* tuner_shadow[3] - xxxx x01x b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] | 0x02;
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] & 0xFB;
         pNim->tuner.tua6020.tuner_ref_freq = 31250;
         pNim->tuner.tua6020.tuner_IF_step = 1152;  /* tuner_IF_step = tuner_interm_freq / tuner_ref_freq */
         break;
      
      case DCF_STEP_50000:
         /* tuner_shadow[3] - xxxx xx0x b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] & 0xFD;
         pNim->tuner.tua6020.tuner_ref_freq = 50000;
         pNim->tuner.tua6020.tuner_IF_step = 720;   /* tuner_IF_step = tuner_interm_freq / tuner_ref_freq */
         break;
      
      case DCF_STEP_62500:
         /* tuner_shadow[3] - xxxx x11x b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] | 0x06;
         pNim->tuner.tua6020.tuner_ref_freq = 62500;
         pNim->tuner.tua6020.tuner_IF_step = 576;   /* tuner_IF_step = tuner_interm_freq / tuner_ref_freq */
         break;
      
      default:
         /* tuner_shadow[3] - xxxx x11x b */
         pNim->tuner.tua6020.tuner_shadow[2] = pNim->tuner.tua6020.tuner_shadow[2] | 0x06;
         pNim->tuner.tua6020.tuner_ref_freq = 62500;
         pNim->tuner.tua6020.tuner_IF_step = 576;   /* tuner_IF_step = tuner_interm_freq / tuner_ref_freq */
         break;
   }
   return(True);
}

/*****************************************************************************/
/*  FUNCTION:    TUA_TUNER_DRIVER_Get_Freq                                   */
/*                                                                           */
/*  PARAMETERS:  pNim - pointer to the DCF_NIM structure                     */
/*               p32Data - pointer to the return data                        */
/*                                                                           */
/*  DESCRIPTION: The function get the signal frequency F(IN).                */
/*               F(IN) = F(OSC) - F(IF) = Divider * F(STEP) - F(IF)          */
/*                                                                           */
/*  RETURNS:     True if successful, False if unsuccessful.                  */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static bool TUA_TUNER_DRIVER_Get_Freq (DCF_NIM *pNim, unsigned long *pu32Data)
{
   unsigned long   u32Divider;
   
   u32Divider = ((unsigned long)(pNim->tuner.tua6020.tuner_shadow[0]) & 0x0000007F) << 8;
   u32Divider += ((unsigned long)(pNim->tuner.tua6020.tuner_shadow[1]) & 0x000000FF);
   
   if (u32Divider < (pNim->tuner.tua6020.tuner_IF_step))
   {
      return(False);
   }
   else
   {
      u32Divider = u32Divider - (pNim->tuner.tua6020.tuner_IF_step);
      *pu32Data = (pNim->tuner.tua6020.tuner_ref_freq) * u32Divider;
      return(True);
   }
}

/*****************************************************************************/
/*  FUNCTION:    TUA_TUNER_DRIVER_Get_Lock_Status                            */
/*                                                                           */
/*  PARAMETERS:  pNim - pointer to the DCF_NIM structure                     */
/*               pbLocked - pointer to the lock status                       */
/*                                                                           */
/*  DESCRIPTION: The function get PLL lock status of TUNER                   */
/*                                                                           */
/*  RETURNS:     True if successful, False if unsuccessful.                  */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
bool TUA_TUNER_DRIVER_Get_Lock_Status (DCF_NIM *pNim, bool *pbLocked)
{
   bool                 bRetVal;
   unsigned char   u8RegAdata;
   bRetVal = DCF_RegRead(pNim, 0x00, 1, &u8RegAdata, DCF_TUNER_I2C);
   if(bRetVal == False)
   	return(False);

   if((u8RegAdata & 0x40) == 0x40)
   	*pbLocked = True;
   else
   	*pbLocked = False;

   return(True);
}


⌨️ 快捷键说明

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