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

📄 tuner_init.c

📁 模拟高频头的 驱动程序(搜台、换台等功能)
💻 C
字号:
/******************************************************************************/
/**
 * @file    tuner_init.c
 *
 * @brief   Tuner Driver Init/Save Functions.
 *
 * @note    (c) 2005 - 2008 Micronas GmbH. All rights reserved.
 *          Any use of the Software is permitted only in accordance
 *          with the terms set forth in the Disclaimer text file.
 *
 * @author  ACOM software team
 ******************************************************************************/

#define _SOURCE_TUNER_INIT_


/******************************************************************************/
/**
 * INCLUDES:
 ******************************************************************************/

#include <system.h>

#include <api_i2c.h>

#include <tuner_init.h>
#include <tuner_drv.h>
#include "tuner_rh_init.h"
#include "tuner_rh_reg.h"
#include "tuner_reg.h"


/******************************************************************************/
/**
 * LOCAL FUNCTION PROTOTYPES: - General local Init Routine -
 ******************************************************************************/

static void Tuner_Init(const uint16_t uIndex, uint16_t uNum);


/******************************************************************************/
/**
 * GLOBAL VARIABLES:
 ******************************************************************************/

uint16_t gwTunerFrequency;
uint16_t gwTunerLowerFreqBound;
uint16_t gwTunerUpperFreqBound;
uint16_t gwTunerVHF1VHF3Bound;
uint16_t gwTunerVHF3UHFBound;

/******************************************************************************/
/**
 * GLOBAL CODE ARRAY:
 ******************************************************************************/
#ifdef __PHI__
code TunerBoundaries_t TunerBoundaries [] =
{
   {0x0970,0x1BB0}, /* T6002PH5Init  */
   {0x09E0,0x1BB0}, /* UV1316mk3Init */
   {0x0AC0,0x1D30}  /* ET50Init      */
}
;
#else
code TunerBoundaries_t TunerBoundaries [] =
{
 #ifdef __AD_TUNER_ALPS__
   {0x0990,0x1AE0},
 #else
   #ifdef __EX_EUROPE__
      {0x0970,0x1B04}, /*FieldTest.061102: GDC JL193XB, for 1 station is lost in Erfurt */
   #else
      {0x08C4,0x1B04}, /* T6002PH5Init  DVB-T*/  //   {0x0970,0x1BB0}, /* T6002PH5Init  DK 193*/
   #endif
 #endif
   {0x09E0,0x1BB0}, /* UV1316mk3Init */
   {0x0AC0,0x1D30}  /* ET50Init      */
}
;

#endif

/******************************************************************************/
/**
 * @brief   Makes a register initialisation from the BASE table.
 *
 * @param   --
 *
 * @return  --
 ******************************************************************************/

void Tuner_InitBase(void)
{
   Tuner_Init(TUNERBASE_INDEX, TUNERBASE_NUM_INITS);
}

/******************************************************************************/
/**
 * @brief   Makes a register initialisation from the BASE table.
 *
 * @param   --
 *
 * @return  --
 ******************************************************************************/

void Tuner_InitDefaults(void)
{
   gwTunerFrequency      = TUNER_DEFAULT_FREQUENCY;
   gwTunerLowerFreqBound = TUNER_DEFAULT_LOWER_FREQBOUND;
   gwTunerUpperFreqBound = TUNER_DEFAULT_UPPER_FREQ_BOUND;
   Tuner_DrvCalcFrequencyBand(gwTunerFrequency);
}

/******************************************************************************/
/**
 *  STATIC FUNCTIONS:
 ******************************************************************************/

/******************************************************************************/
/**
 * @brief   Local Init loop called from separated Init Functions.
 *
 * @param   uIndex - [in] Index of table
 * @param   uNum   - [in] Number of init items.
 *
 * @return  --
 ******************************************************************************/

static void Tuner_Init(const uint16_t uIndex, uint16_t uNum)
{
   TUNERBASE_t code *pTab;
   uint8_t          uDataIntoReg;


   pTab = &tunerBase[uIndex];

   while (uNum > 0)
   {  /* NVM data ? */
      if(pTab->uCtrl & TUNERBASE_UCTRL_NVMDATA)
      {
         /* Get data from NVM */
         uDataIntoReg = API_I2c_Read1ByteWith1SubAddr(I2CDEV_TUNER,pTab->uData);
      }
      else
      {
         /* Get data from table */
         uDataIntoReg = pTab->uData;
      }
      /* bitslice data ? */
      if(pTab->uCtrl & TUNERBASE_UCTRL_BITSID)
      {
         /* Bitslice-ID is used in table instead of register address
            because a shadow variable must be updated.
            Use bitslice structure to get register address
            and variable index.
            -> uData is the value of the complete hardware register! */

         /* Update Mirror */
         tunerVar[tuner[pTab->uAddr].uVar] = uDataIntoReg;
         /* there is no single write into single register only update shadow */
         /* shadow variables will be written all once                        */
      }
      else
      {
         /* there is no single write into single register only update shadow */
         /* shadow variables will be written all once                        */
      }
      uNum--;
      pTab++;
   }
}

⌨️ 快捷键说明

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