Power_Ctrl.c
上传用户:xmyjxjd
上传日期:2013-05-04
资源大小:1517k
文件大小:7k
开发平台:

C/C++

  1. #define __POWERCTRL__
  2. #include "HeaderLcd_main.h"
  3. #include "Headeraccess.h"
  4. #include "Headerconfig.h"
  5. #include "HeaderOsd.h"
  6. #include "HeaderInitial.h"
  7. #include "HeaderLcd_msg.h"
  8. #include "HeaderFrame_Sync.h"
  9. #include "HeaderLcd_func.h"
  10. #include "HeaderFont.h"
  11. void PowerDown_ADC(void)
  12. {
  13.     RTDSetByte(PLL1_CTRL_D6, 0xf2);     // Power down PLL1
  14.     RTDSetByte(PLL2_CTRL_DA, 0x40);     // Power down PLL2
  15.     RTDSetByte(ADC_CTRL_E6, 0x40);      // Power down ADC
  16. }
  17. void PowerUp_ADC(void)
  18. {
  19.     RTDSetByte(PLL1_CTRL_D6, 0xf3);     // Power up PLL1
  20.     RTDSetByte(PLL2_CTRL_DA, 0x41);     // Power up PLL2
  21.     RTDSetByte(ADC_CTRL_E6, 0x47);      // Power up ADC
  22.     RTDSetByte(PLL2_FILTER_DD, 0x5f);
  23. }
  24. void PowerDown_TMDS(void)
  25. {
  26.     RTDSetByte(TMDS_OUTPUT_ENA_A0, 0x0F);    
  27. }
  28. void PowerUp_TMDS(void)
  29. {
  30.    RTDSetByte(TMDS_OUTPUT_ENA_A0, 0x8F);
  31. }
  32. void PowerDown_VDC(void)
  33. {
  34. #if (VIDEO_CHIP != VDC_NONE)
  35. #if(MCU_TYPE == MCU_WINBOND)
  36.     bVDC_PWR    = VDC_OFF;
  37. #else
  38.     MCU_WriteVideoPower(VDC_OFF);
  39. #endif
  40. #endif
  41. }
  42. void PowerUp_VDC(void)
  43. {
  44. #if (VIDEO_CHIP != VDC_NONE)
  45. #if(MCU_TYPE == MCU_WINBOND)
  46.      bVDC_PWR    = VDC_ON;
  47. #else
  48.      MCU_WriteVideoPower(VDC_ON);
  49. #endif
  50. #endif
  51. }
  52. void PowerDown_LVDS(void)
  53. {
  54. #if (OUTPUT_BUS == LVDS_TYPE)
  55. RTDCodeW(LVDS_POWERDOWN);
  56. #endif
  57. }
  58. void PowerUp_LVDS(void)
  59. {
  60. #if (OUTPUT_BUS == LVDS_TYPE)
  61. RTDCodeW(LVDS_POWERUP);
  62. #endif
  63. }
  64. void Set_Panel(unsigned char status)
  65. {
  66.     if (status)
  67.     {
  68.         PowerUp_LVDS();
  69. //Device_Power(LVDS_POWER,ON);
  70.         Delay_Xms(10);
  71.         RTDSetByte(VDIS_SIGINV_21, 0x00 | DISP_EO_SWAP | DISP_RB_SWAP | DISP_ML_SWAP);       // DHS, DVS, DEN, DCLK MUST NOT be inverted.
  72.         RTDSetBit(VDIS_CTRL_20, 0xfd, 0x01);    // DHS, DVS, DEN, DCLK and data are clamped to 0
  73.         Delay_Xms(20);
  74.         RTDSetBit(VDIS_CTRL_20, 0xfe, 0x00);    // Stop display timing
  75.         Delay_Xms(20);
  76. #if(MCU_TYPE == MCU_WINBOND)
  77.         bPANEL_PWR  = PANEL_ON;
  78. #else
  79.         MCU_WritePanelPower(PANEL_ON);
  80. #endif
  81.         bPanel_Status = _ON;
  82.         
  83.         Delay_Xms(40);
  84.         RTDSetByte(VDIS_SIGINV_21, DISP_INV | DISP_EO_SWAP | DISP_RB_SWAP | DISP_ML_SWAP);       // DHS, DVS, DEN, DCLK MUST NOT be inverted.
  85.         RTDSetBit(VDIS_CTRL_20, 0xff, 0x03);    // DHS, DVS, DEN, DCLK in normal operation
  86.         
  87.         RTDSetBit(DIS_TIMING0_3A, 0xff, 0x20);  // Force display timing enable
  88.         RTDSetBit(DIS_TIMING0_3A, 0xdf, 0x00);  // Stop forcing
  89.         //Delay_Xms(200);
  90.         //Delay_Xms(200);
  91.         Load_VLC_Font(Font_Global, 0x00, 0xa1);
  92.        if( (stGUD1.FUNCTION & 0x07) == JAPANESS )
  93.        {
  94.        Load_VLC_Font(Font_East_J, 0x573, 0x4B);
  95.        }
  96.        else
  97.        {
  98.           Load_VLC_Font(Font_East_C, 0x5a9, 0x45);
  99.        }
  100.        Load_VLC_Font(Font_Icons, 0x828, 0x70);
  101.         Load_VLC_Font(Font_add, 0x20a, 0x06); //anson   3A(addr)  x  9  = 20A
  102. //   12 x18 / 8 /3 = 9
  103. RTDSetByte(STATUS0_01, 0x00);  // Write once to clear status
  104.         RTDSetByte(STATUS1_1F, 0x00);  // Write once to clear status
  105.         
  106. #if(MCU_TYPE == MCU_WINBOND)
  107.         bLIGHT_PWR  = LIGHT_ON;
  108. #else
  109.         MCU_WriteBacklightPower(LIGHT_ON);
  110. #endif
  111.     }
  112.     else
  113.     {
  114. #if(MCU_TYPE == MCU_WINBOND)
  115.         bLIGHT_PWR  = LIGHT_OFF;
  116. #else
  117.         MCU_WriteBacklightPower(LIGHT_OFF);
  118. #endif
  119.         Delay_Xms(120);
  120.         RTDOSDW(OSD_Reset);
  121.         RTDSetByte(VDIS_SIGINV_21, 0x00 | DISP_EO_SWAP | DISP_RB_SWAP | DISP_ML_SWAP);       // DHS, DVS, DEN, DCLK MUST NOT be inverted.
  122.         RTDSetBit(VDIS_CTRL_20, 0xfd, 0x01);    // DHS, DVS, DEN, DCLK and data are clamped to 0
  123.         Delay_Xms(20);
  124.         RTDSetBit(VDIS_CTRL_20, 0xfe, 0x00);    // Stop display timing
  125.         Delay_Xms(20);
  126. #if(MCU_TYPE == MCU_WINBOND)  
  127.         bPANEL_PWR  = PANEL_OFF;
  128. #else
  129.         MCU_WritePanelPower(PANEL_OFF);
  130. #endif
  131.         bPanel_Status = _OFF;
  132.         Delay_Xms(40);
  133.         PowerDown_LVDS();
  134. //Device_Power(LVDS_POWER,OFF);
  135.     }
  136. }
  137.             //////////////////////
  138.             // Power Controller //
  139.             //////////////////////
  140. bit Power_Control(unsigned char Notify)
  141. {
  142.             if (0 == bPower_Status)
  143.             {
  144.                 if (NOTIFY_POWERUP == Notify)
  145.                 {
  146.                     bPower_Status   = 1;
  147.                     Power_Up_Init();
  148.                     ISP_Check_Sum();
  149.                     bStable     = 0;                    // Assume input signal is not stable when power up
  150.                     bReload     = 1;                    // Always reload font when power up
  151.                     bFrameSync  = 0;                    // Not sync yet
  152.                     ucModeCnt   = MODE_DETECT_FREQ;     // Reset Input Mode Detector
  153.                     
  154.                     Measure_Mode();                     // Measure mode-timing
  155.                     Set_Task(STATE_POWERUP);            // Notify Task State Machine
  156. #if (RTDDEBUG)
  157.                     ucMode_PrevAct  = MODE_NOSIGNAL;
  158.                     ucMode_QuitCnt  = 0;
  159.                     ucDebug         = 0;
  160. #endif
  161. #if (POWER_KEY_TYPE == TYPE_ONE_TOUCH)
  162.                     // Save power status when power-key is one-touch type
  163.                     stGUD1.FUNCTION &= 0xf7;
  164.                     Save_GUD1();
  165.                     Delay_Xms(10);
  166. #endif
  167.                 }
  168.                 bNotify_Timer0_Int  = 0;
  169. //               continue;   // leave current iteration.
  170.                  return _TRUE;
  171.             }
  172.             else if (NOTIFY_POWERDOWN == Notify)
  173.             {
  174. #if (POWER_KEY_TYPE == TYPE_ONE_TOUCH)
  175.                 // Save power status when power-key is one-touch type
  176.                 stGUD1.FUNCTION |= 0x08;
  177.                 Save_GUD1();
  178.                 Delay_Xms(10);
  179. #endif
  180.                 bPower_Status   = 0;
  181.                 Set_Panel(0);                   // Turn off panel
  182.                 SetMute(0);
  183.                 RTDSetByte(HOSTCTRL_02, 0x42);  // Set RTD to power-saving
  184.                 I2CWrite(V_DISABLE);
  185.                 PowerDown_ADC();
  186.                 PowerDown_VDC();
  187.                 PowerDown_TMDS();
  188.                 Delay_Xms(250);
  189.                 Delay_Xms(250);
  190.                 Delay_Xms(250);
  191.                 Delay_Xms(250);
  192.                 Delay_Xms(250);
  193.                 Set_Task(STATE_POWERDOWN);      // Notify Task State Machine
  194.                 bNotify_Timer0_Int  = 0;
  195.                 //continue;   // leave current iteration.
  196. return _TRUE;
  197.             }
  198. return _FALSE;
  199. }