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

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