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

📄 initial.c

📁 keil C51 LCD 驱动源码,其中还有I2C驱动,ADC驱动,键盘操作等,是一个完整的keil源代码,供大家参考
💻 C
📖 第 1 页 / 共 2 页
字号:

    for(i=0; i<TOTAL_MODE_NUMBER; i++)
    {
       if( EepromTimingRecall(i) )    // checksum error
       {
          EepromTimingDefault(i);
          EepromTimingStore(i);
       }
    }
    if( EepromCommonRecall(0) )
    {
        EepromCommonDefault(0);
        EepromCommonStore(0);
    }
    if( EepromCommonRecall(1) )
    {
        EepromCommonDefault(1);
        EepromCommonStore(1);
    }
    if( EepromCommonRecall(2) )
    {
        EepromCommonDefault(2);
        EepromCommonStore(2);
    }
    if( EepromCommonRecall(3) )
    {
        EepromCommonDefault(3);
        EepromCommonStore(3);
    }
    EepromColorRecall(ColorTemp);       //tonny
}
/************************************************************************/
/************************************************************************/
void InitialVariable( void )
{
#if     ZURAC_HWMD
    InputSource = INPUT_ANALOG;     // default inpt source
    CurHFreq = 0xFFFF;              // Current H frequency
    CurVFreq = 0xFFFF;              // Current V frequency
    HCountH = 0;
    VCountH = 0;
    tempHCountH = 0;
    tempVCountH = 0;
    LastHCountH = 0;
    LastVCountH = 0;
    HS1frCount = 0;                 // Hsync 1 frame line count
    MuteTimer = 0;
    StableCnt = 0;
    SyncSource = 0xA3;
    FgModeDetect = 1;
    FgSogSignal = 0;
    FgSepSignal = 0;
    FgCompSignal = 0;
    LastHPol = 0;
    LastVPol = 0;
    tempHPol = 0;
    tempVPol = 0;
    FgSWChange = 0;
    CurrentHPol = 0;
    CurrentVPol = 0;
    FgNoSignal  = 0;
    FgFreeRun   = 0;
//  FgBurnin    = 0;
    VSyncStart = 0;
#else   // ZURAC_HWMD
    InputSource = INPUT_ANALOG;     // default inpt source
    InVTime  = 0;                   // Incoming V Sync Period
    NewVFreq = 0;                   // Last V frequency
    NewHFreq = 0;                   // Last H frequency
    CurHFreq = 0xFFFF;              // Current H frequency
    CurVFreq = 0xFFFF;              // Current V frequency
    VPolTime = 0;                   // time to check V polarity
    VSyncOVTime = TIME_28MS;        // H sync overflow time
    StableCount = 0;                //

    InHPol  = 0;                    // incoming H sync polarity
    InVPol  = 0;                    // incoming V sync polarity
    NewHPol = 0;                    // last H sync polarity
    NewVPol = 0;                    // last V sync polarity
    CurrentHPol = 0;                // current H sync polarity
    CurrentVPol = 0;                // current V sync polarity
    VS4msCount  = 0;
    VS1usCount  = 0;
    HS1frCount  = 0;
    VSyncOn     = 0;
    VSyncReady  = 0;
    FgModeChange = 0;

    FgNoSignal  = 0;
    FgFreeRun   = 0;
//  FgBurnin    = 0;
#endif  // ZURAC_HWMD
}
/************************************************************************/
/************************************************************************/
void InitialOsd(void)
{
    OsdClearAll();
    
}
/************************************************************************/
/************************************************************************/
void Delay(Byte count)
{
    T8_192msTimer = count;
    while ( T8_192msTimer != 0 );
}
/************************************************************************/
/************************************************************************/
void ShortDelay(Byte count)
{
    Byte  i,j;

    for(i=0; i<count; i++)
       for(j=0; j<=142; j++)
          _nop_();
}
/************************************************************************/
/************************************************************************/
void PowerDpms(Byte on_off)
{
   if( on_off==1 )   /* ON */
      DPMS_PIN    = 0;       // DPMS System-power-on
   else              /* OFF */
      DPMS_PIN    = 1;       // DPMS System-power-off
}

void PowerScaler(Byte on_off)
{
#if  ZURAC_HWMD
   if( on_off==2 )   /* OFF */
   {
      // in HWMD mode, scaler must be live!
      ASICPDP_PIN = 0;       // Zurac power-on
   }
   else if( on_off==1 )   /* ON */
   {
      ASICPDP_PIN = 0;       // Zurac power-on
   }
   else              /* OFF */
   {
      ASICPDP_PIN = 1;       // Zurac power-off
   }
#else
   if( on_off==1 )   /* ON */
      ASICPDP_PIN = 0;       // Zurac power-on
   else              /* OFF */
      ASICPDP_PIN = 1;       // Zurac power-off
#endif
}

void PowerAdc(Byte on_off)
{
#if (ADC_CHIP==ADI_9884 || ADC_CHIP==FMS_9884 || ADC_CHIP==FMS_9874)
   if( on_off==1 )   /* ON */
      ADCPDN_PIN    = 1;      // AD9884 power-on
   else              /* OFF */
      ADCPDN_PIN    = 0;      // AD9884 power-off
#elif (ADC_CHIP==ADI_9883)
   SlvAdr    = AD9883_ADDR;
   ByteCnt   = 2;
   TrmBuf[0] = 0x0F;
   if( on_off==1 )   /* ON */
      TrmBuf[1] = 0x5E;       // AD9883 normal operatates
   else              /* OFF */
      TrmBuf[1] = 0x5C;       // AD9883 Full Chip Power Down
   SendData();
#elif (ADC_CHIP==ADI_9887)
   SlvAdr    = AD9887_ADDR;
   ByteCnt   = 2;
   TrmBuf[0] = 0x12;
   if( on_off==1 || on_off==2 )   /* ON */
   {
      TrmBuf[2] = SyncSource & 0x03;
      if( TrmBuf[2]==0 )       TrmBuf[1] = 0xBD;   // SOG
      else if( TrmBuf[2]==1 )  TrmBuf[1] = 0xAD;   // Composite
      else /* TrmBuf[2]==3 */  TrmBuf[1] = 0xA9;   // Seperate

      if( InputSource==INPUT_DIGITAL )
         TrmBuf[1] = 0xE9;
   }
   else              /* OFF */
   {
      TrmBuf[1] = 0xA8;       // AD9887 Full Chip Power Down
   }
   SendData();
#endif
}

void PowerPanel(Byte on_off)
{
   if( on_off==1 )   /* ON */
      PANELPWR_PIN = 0;       // Panel power-on
   else              /* OFF */
      PANELPWR_PIN = 1;       // Panel power-off
}

void PowerBacklight(Byte on_off)
{
   if( on_off==1 )   /* ON */
      BACKLIT_PIN  = 0;       // Backlight power-on
   else             /* OFF */
      BACKLIT_PIN  = 1;       // Backlight power-off
}

void PowerLedPower(Byte on_off)
{
   if( on_off==1 )   /* ON */
//    LEDPOWER_PIN = 1;       // Power-LED on
      LEDPOWER_PIN = 0;       // Power-LED on
   else              /* OFF */
//    LEDPOWER_PIN = 0;       // Power-LED off
      LEDPOWER_PIN = 1;       // Power-LED off
}

void PowerLedSleep(Byte on_off)
{
   if( on_off==1 )   /* ON */
//    LEDSLEEP_PIN = 1;       // Sleep-LED on
      LEDSLEEP_PIN = 0;       // Sleep-LED on
   else              /* OFF */
//    LEDSLEEP_PIN = 0;       // Sleep-LED off
      LEDSLEEP_PIN = 1;       // Sleep-LED off
}

void ResetScaler()
{
#if ZURAC_HWMD

#else
   TTFC_RSTN_PIN = 0;
   ShortDelay(5);
   TTFC_RSTN_PIN = 1;
   ShortDelay(2);
#endif
}

void ResetAdc()
{
#if (ADC_CHIP==ADI_9884 || ADC_CHIP==FMS_9884 || ADC_CHIP==FMS_9874)
   ADCPDN_PIN = 0;
   ShortDelay(5);
   ADCPDN_PIN = 1;
#elif (ADC_CHIP==ADI_9883)
   SlvAdr    = AD9883_ADDR;
   ByteCnt   = 2;
   TrmBuf[0] = 0x0F;
   TrmBuf[1] = 0x5C;       // AD9883 Full Chip Power Down
   SendData();
   ShortDelay(5);
   ByteCnt   = 2;
   TrmBuf[0] = 0x0F;
   TrmBuf[1] = 0x5E;       // AD9883 Power Normal
   SendData();
#elif (ADC_CHIP==ADI_9887)
   SlvAdr    = AD9887_ADDR;
   ByteCnt   = 2;
   TrmBuf[0] = 0x12;
   TrmBuf[1] = 0xA8;       // AD9887 Full Chip Power Down
   SendData();
   ShortDelay(5);
   ByteCnt   = 2;
   TrmBuf[0] = 0x12;
   TrmBuf[1] = 0xA9;       // AD9887 Power Normal
   SendData();
#endif
}

⌨️ 快捷键说明

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