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

📄 ttfc.c

📁 keil C51 LCD 驱动源码,其中还有I2C驱动,ADC驱动,键盘操作等,是一个完整的keil源代码,供大家参考
💻 C
📖 第 1 页 / 共 3 页
字号:
    else if( InputSource==INPUT_DIGITAL )
    {
       zwtemp = zwtemp / 2;
    }

    ZuracWriteWord(0x60,zwtemp);
}
/***************************************************************************
  Function : isVGAabsent()
  Purpose  : check if VGA signal is present or absent
  Input    :
  Output   :
  External : VSyncOn                   V-sync in or not
             VSyncReady                V-sync detect ok
  Return   : True                      VGA signal absent
             FALSE                     VGA signal ok
***************************************************************************/
Bool isVGAabsent()
{
#if     ZURAC_HWMD
    if ( HWMD_VideoStatus() & 0x04 )
        return FALSE;
    return TRUE;
#else   // ZURAC_HWMD
    if( VSyncOn==0 && VSyncReady==1 )
       return TRUE;
    return FALSE;
#endif  // ZURAC_HWMD
}

/**************************************************************/
// void ZuracHsf(Word inHsize,Word outHsize)
// {
// #if  ZURAC_HSCALING
//     Word   hslopem,hmin,hval;
//     Byte   Hhinc,Hdy,Hdx,x,y;
//
//     Hhinc = 0;
//     hval  = 16*inHsize;
//     while( 1 )
//     {
//        if( hval >= outHsize )
//        {
//           Hhinc++;
//           hval -= outHsize;
//           continue;
//        }
//        break;
//     }
//
//     Hdy  = 63;
//     Hdx  = 63;
//     hmin = 65535;
//     hslopem = (Word) (((Long)(16*inHsize-outHsize*Hhinc) * 256) / outHsize);
//
//     if( hslopem==0 )
//     {
//        Hdy = 0;
//        Hdx = 1;
//     }
//     else
//     {
//        for(y=63; y>0; y--)
//        {
//          for(x=63; x>0; x--)
//          {
//             hval = (((Word)y*256) / x);
//             if( hval > hslopem )  hval = hval - hslopem;
//             else                  hval = hslopem - hval;
//
//             if(hval <= hmin)
//             {
//                hmin = hval;
//                Hdy = y;
//                Hdx = x;
//             }
//          }
//        }
//     }
//     if( Hdx==1 && Hdy==1 )
//     {
//        Hhinc++;
//        Hdy = 0;
//     }
//
//     TrmBuf[7] = Hdx;
//     TrmBuf[8] = Hdy;
//     TrmBuf[9] = Hhinc;
// #endif
//     return;
// }

/**************************************************************/
/**************************************************************/
// void  ZuracDimDemo(void)
// {
//     Byte i,j,kx,ky;
//     Word IDATA x1,y1,x2,y2;
//
//     kx = (PANEL_WIDTH - 200) / 10;
//     ky = (PANEL_HEIGHT - 200) / 10;
//     ZuracWriteByte(0x0A,0x0B);
//
//     x1 = 1;
//     for(i=0; i<10; i++)
//     {
//        x1 = x1 + kx;
//        x2 = x1 + 200;
//        y1 = 1;
//        for(j=0; j<10; j++)
//        {
//           y1 = y1 + ky;
//           y2 = y1 + 200 + 0x8000;
//           ZuracWriteWord(0x48,x1);
//           ZuracWriteWord(0x4A,x2);
//           ZuracWriteWord(0x4C,y1);
//           ZuracWriteWord(0x4E,y2);
//           Delay(50);
//        }
//     }
//     ZuracWriteByte(0x0A,0x0A);
// }

#if 0
//********************************************************************
//********************************************************************
void  ZuracAdjHPos()
{
    Byte  i;
    ZuracI2CActDirect(0);
    ZuracWaitVsync( 40 );
    ZuracSetHPos();
    ZuracSetHOutput();
    ZuracI2CActDirect(1);
    ZuracWaitVsync( 40 );
    return;
}

void  ZuracAdjVPos()
{
    ZuracI2CActDirect(0);
    ZuracWaitVsync( 40 );
    ZuracSetVPos();
    ZuracSetVOutput();
    ZuracI2CActDirect(1);
    ZuracWaitVsync( 40 );
    return;
}

void  ZuracAdjClock()
{
    ZuracI2CActDirect(0);
    ZuracWaitVsync( 40 );
    ZuracSphEmu();
    ZuracSetHPos();
    ZuracSetHOutput();
    ZuracI2CActDirect(1);
    ZuracWaitVsync( 40 );
    return;
}

void  ZuracAdjDithering()
{
    Byte  btemp;
    
    btemp = Zurac03Value(ModeCounter);
    ZuracWriteByte(0x03,btemp);
    
    btemp = Scale_IO_control_table[ModeCounter][5];
    if( DitherMode!=0 )  btemp |= 0x02;  /* dithering Feedback ON  */
    ZuracWriteByte(0x05,btemp);
}

void  ZuracAdjScaling()
{
    Byte  btemp;
    
    btemp  = Scale_scaling_factor_table[ModeCounter][14];
    btemp |= (ScalingMode << 6);   /* Reg6E[7:6] : Scaling algorithm */
    ZuracWriteByte(0x6E,btemp);
}

void  ZuracAdjABlending()
{
    ZuracWriteByte(0x6E,AlphaBlending+0x08);
}

void  ZuracSetHPos()
{
    Word  wtemp;
    
    // Set Input Horizontal Active Start
    wtemp = HorPositionValue;
    if( InputSource==INPUT_DIGITAL )  wtemp &= 0xFFFE;
    ZuracWriteWord(0x10,wtemp);
    
    // check Input Horizontal Active Width
    wtemp = MAKEWORD( Scale_input_para_table[ModeCounter][3],Scale_input_para_table[ModeCounter][2] );
    if( (HorPositionValue + wtemp) >= (ClockValue-1) )
       wtemp = ClockValue - HorPositionValue - 2;
    ZuracWriteWord(0x12,wtemp);
    return;
}

void  ZuracSetVPos()
{
    Word  wtemp;
    
    // Set Input Vertical Active Start
    ZuracWriteWord(0x16,VerPositionValue);
    
    // check Input Vertical Active Width
    wtemp  = MAKEWORD( Scale_input_para_table[ModeCounter][9],Scale_input_para_table[ModeCounter][8] );
    if( (wtemp + VerPositionValue) >= HS1frCount )
       wtemp = HS1frCount - VerPositionValue - 1;
    ZuracWriteWord(0x18,wtemp);
}

void  ZuracSetHOutput()
{
    Byte  thn,thd;
    Word  wtemp,wtemp2;
    
    thd = mode_factor[ModeCounter]*4;
    thn = scale_factor_table[thd];      /* Hsf numerator   */
    thd = scale_factor_table[thd+1];    /* Hsf denominator */

    // Check Panel Horizontal active region
    wtemp = MAKEWORD( Scale_input_para_table[ModeCounter][3],Scale_input_para_table[ModeCounter][2] );
    wtemp2 = wtemp;
    if( (HorPositionValue + wtemp) >= (ClockValue) )
       wtemp2 = ClockValue - HorPositionValue - 1;

    if( wtemp2 < wtemp )   // IH-AWIDTH
    {
        wtemp = MAKEWORD( Scale_output_para_table[ModeCounter][3],Scale_output_para_table[ModeCounter][2] );
        wtemp = (Word) (((long)wtemp2 * (long)thn) / (long)thd); // - 2;
    }
    else
    {
        wtemp = MAKEWORD( Scale_output_para_table[ModeCounter][3],Scale_output_para_table[ModeCounter][2] );
    }
    if( wtemp >= PANEL_WIDTH )  wtemp = PANEL_WIDTH;
#if  ZURAC_HSCALING
    wtemp2 = MAKEWORD( Scale_output_para_table[ModeCounter[1],Scale_output_para_table[ModeCounter][0] );
    if( InputSource==INPUT_ANALOG )
    {
       if( HScaling < 32 )
       {
          if( (hscaling_table[ModeCounter] & 0xF0)==0x00 )   /* scale up mode */
          {
             wtemp  = wtemp  - (32 - HScaling)*2;
             wtemp++;
             wtemp2 = wtemp2 + (32 - HScaling);
          }
       }
       else
       {
          wtemp = wtemp + (HScaling - 32) * 2;
          if( wtemp>=PANEL_WIDTH )  wtemp = PANEL_WIDTH;
       }
    }
    ZuracWriteWord(0x30,wtemp2);
#endif
    ZuracWriteWord(0x32,wtemp);
}

void  ZuracSetVOutput()
{
    Byte  tvn,tvd;
    Word  wtemp,wtemp2;
    
    tvd = mode_factor[ModeCounter]*4;
    tvn = scale_factor_table[tvd+2];    /* Vsf numerator   */
    tvd = scale_factor_table[tvd+3];    /* Vsf denominator */
    
    /* Calculate PV_ASTART and PV_TOTAL */
    wtemp  = (Word) (((Long)HS1frCount * (Long)tvn) / (Long)tvd);
#if  ((OUTPUT_MODE==OUTPUT_XGA) && (PANEL_DEFAULT==PANEL_HANNSTAR))
    if( ModeCounter > 9 )      wtemp -= 2;
    else if( ModeCounter==9 )  wtemp -= 4;   
    else                       wtemp -= 3;
#else
    wtemp -= 2; 
#endif              
    wtemp2 = MAKEWORD( Scale_output_para_table[ModeCounter][5],Scale_output_para_table[ModeCounter][4] );
    if( (wtemp2+PANEL_HEIGHT+4)>wtemp )  /* set PV_ASTART */
    {
       wtemp2 = wtemp - PANEL_HEIGHT - 4;
       ZuracWriteWord(0x34,wtemp2);
    }
    ZuracWriteWord(0x38,wtemp);
    
    if( InputSource==INPUT_DIGITAL )   /* set input vertical active width */
    {
       wtemp = MAKEWORD( Scale_input_para_table[ModeCounter][9],Scale_input_para_table[ModeCounter][8] );
       wtemp = (Word) (((long)wtemp * (long)tvn) / (long)tvd);
       if( wtemp > PANEL_HEIGHT )
          wtemp = PANEL_HEIGHT;
       ZuracWriteWord(0x36,wtemp);
    }
    
    /*** send BACKGROUND Control register[0x44..0x47] ***/
    ZuracWriteWord(0x44,wtemp2);                /* Background V-start */
    ZuracWriteWord(0x46,wtemp2+PANEL_HEIGHT);   /* Background V-end */
}
void  ZuracI2CActDirect(Bool fg_direct)
{
    Byte  btemp;
       
    if( fg_direct )  btemp = 0x03;
    else             btemp = 0x02;
    if( DitherMode && (InputSource==INPUT_DIGITAL) )  btemp |= 0x30;
    ZuracWriteWord(0x0B,btemp);
}
       
void ZuracWaitVsync(Byte msecs)
{    
#if     ZURAC_HWMD                                        
    Byte  btemp;
    
    T8_192msTimer = (msecs+3) / 4;
    HWMD_ReadStatus();                         /* clear Interrupt */
    while( T8_192msTimer!=0 )
    {
       btemp = HWMD_ReadStatus();
       if( (btemp & 0x30)!=0 )   break;
    }
#else   // ZURAC_HWMD
    T8_192msTimer = (msecs+3) / 4;
    VSyncStart = 0;
    while( T8_192msTimer!=0 )
    {
       if( VSyncStart!=0 )   break;
    }
#endif  // ZURAC_HWMD
    return;
}

#endif

⌨️ 快捷键说明

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