
#include "C035QAN01.h"

/******************************************************************************
函数名：TFT_Start_Config 
功  能：上电初始化
参  数：无        
返回值：无
******************************************************************************/

void LCD_Init(void)
{ /*
  uint8_t i;
  uint8_t WDTEn;
  uint8_t VDir;
  uint8_t HDir;
  
  wdt_reset();
  WDTEn = 3;
  Sim_SPI_Master_Start(SIM_SPI_MODE_3, SIM_SPI_MSB_FIRST);
  
  do
  {
    if (WDTEn)
    {
      WDTEn--;
      wdt_reset();
    }
    
    //1.Reset LCD Panel
    LCD_nCS = 0;
    Sim_SPI_Master_Word_Write(0x9900);
    LCD_nCS = 1;
    
    LCD_Wait_ms(10);
    
    LCD_nCS = 0;
    Sim_SPI_Master_Word_Write(0x9901);
    LCD_nCS = 1;
    
    LCD_Wait_ms(1);
    
    //2.Set Gamma Settings
    for (i = 0; i < sizeof(LCDGammaSetting) / 2; i++)
    {
      LCD_nCS = 0;
      Sim_SPI_Master_Word_Write(LCDGammaSetting[i]);
      LCD_nCS = 1;
      
      LCD_Wait_ms(1);
    }
    
    //3.Set Fine Tune Charge Pump Settings
    for (i = 0; i < sizeof(LCDChargePumpSetting) / 2; i++)
    {
      LCD_nCS = 0;
      Sim_SPI_Master_Word_Write(LCDChargePumpSetting[i]);
      LCD_nCS = 1;
      
      LCD_Wait_ms(1);
    }

    //4.Set User Settings
    LCD_nCS = 0;
    Sim_SPI_Master_Word_Write(0xA500 | LCD_REG_VDIR);
    LCD_nCS = 1;
    


    LCD_Wait_ms(1);
    
    LCD_nCS = 0;
    Sim_SPI_Master_Word_Write(0xA600 | LCD_REG_HDIR);
    LCD_nCS = 1;
    


    LCD_Wait_ms(1);
    
    LCD_nCS = 0;
    Sim_SPI_Master_Word_Write(0xB700 | LCD_REG_SYNC_DE);
    LCD_nCS = 1;

    LCD_Wait_ms(100);
    LCD_Wait_ms(100);
    LCD_Wait_ms(100);
    
    LCD_nCS = 0;
    Sim_SPI_Master_Byte_Write(0xE6);
    HDir = Sim_SPI_Master_Byte_Read(0x00);
    LCD_nCS = 1;
      
    LCD_Wait_ms(1);
    LCD_nCS = 0;
    Sim_SPI_Master_Byte_Write(0xE5);
    VDir = Sim_SPI_Master_Byte_Read(0x00);   
    LCD_nCS = 1;
    
    LCD_Wait_ms(100);
  }
  while ((HDir != LCD_REG_HDIR) || (VDir != LCD_REG_VDIR));
  */
}

/******************************************************************************
函数名：LCD_Wait_ms
功  能：延时一段时间
参  数：msCnt：延时时间,单位ms
返回值：无
******************************************************************************/
void LCD_Wait_ms(uint8_t msCnt)
{
  uint16_t Dst;
  
  Dst  = (uint16_t)msCnt;
  Dst  = Dst * (1024 / API_INT_CYCLE);
  Dst += API_ROLLING_COUNTER;
  
  while (Dst != API_ROLLING_COUNTER);
}
