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

📄 debug.c

📁 完整的软件学习--显示器驱动视频软件
💻 C
字号:
#include <math.h>
#include "types.h"
#include "debugDef.h"
#include "board.h"
#include "global.h"
#include "ms_reg.h"
#include "ms_rwreg.h"
#include "msosd.h"
#include "NVRam.h"
#include "i2c.h"
#include "misc.h"
#include "adjust.h"
#include "userPref.h"
#include "menudef.h"
#include "menufunc.h"
#include "power.h"

#if (MTV512)//EnableAutoColorTemp
BYTE SIORxBuffer[4];
#elif MSTMCU
BYTE idata SIORxBuffer[18];
#else
BYTE SIORxBuffer[18];
#endif

BYTE SIORxIndex=0;
BYTE ReSyncCounter;
extern void Save6500KAutoColor(void);
extern void Save9300KAutoColor(void);

void printData(char *str, WORD value);
void printMsg(char * str);
void putSIOChar(unsigned char sendData);
#if !(MTV512)
//void SetTempContrast(BYTE TempContrast);    //zwtan add for pcadjust color
//Bool CheckError(void);
#endif
extern void LoadLanguageFont(BYTE language);


void ProcessCommand(void)
{
#if !(MTV512)

  if (DebugCommand==Read_mStar)
    { DebugData=mStar_ReadByte(DebugAddress);
              /*hw_SetGreenLed();
		hw_SetAmberLed();
		Delay1ms(1000);
		hw_ClrGreenLed();
		hw_ClrAmberLed();
		Delay1ms(1000);
		 hw_SetGreenLed();
		 hw_SetAmberLed();
		*/
		
    }
  else if (DebugCommand==Write_mStar)
    { mStar_WriteByte(DebugAddress, DebugData);
    }
  else if (DebugCommand==Read_mStarADC)
    { mStar_WriteByte(REGBK, REGBANKADC);
      DebugData=mStar_ReadByte(DebugAddress);
      mStar_WriteByte(REGBK, REGBANKSCALER);
    }
  else if (DebugCommand==Write_mStarADC)
    { mStar_WriteByte(REGBK, REGBANKADC);
      mStar_WriteByte(DebugAddress, DebugData);
      mStar_WriteByte(REGBK, REGBANKSCALER);
    }
  else if (DebugCommand==Read_mStarTCON)
    { mStar_WriteByte(REGBK, REGBANKTCON);
      DebugData=mStar_ReadByte(DebugAddress);
      mStar_WriteByte(REGBK, REGBANKSCALER);
    }
  else if (DebugCommand==Write_mStarTCON)
    { mStar_WriteByte(REGBK, REGBANKTCON);
      mStar_WriteByte(DebugAddress, DebugData);
      mStar_WriteByte(REGBK, REGBANKSCALER);
    }
  else if (DebugCommand==Read_mStarOSD)
    { DebugData=mStar_ReadOSDByte(DebugAddress);
    }
  else if (DebugCommand==Write_mStarOSD)
    { mStar_WriteOSDByte(DebugAddress, DebugData);
    }
  else if (DebugCommand==Read_NVRam)
    { NVRam_ReadByte(DebugAddress|((WORD)DebugAddressBank<<8), &DebugData);
    }
  else if (DebugCommand==Write_NVRam)
    { NVRam_WriteByte(DebugAddress|((WORD)DebugAddressBank<<8), DebugData);
    }
  else if (DebugCommand==Read_Device)
    { i2c_ReadTBL(DebugDeviceAddr, DebugAddress, &DebugData, 1);
    }
  else if (DebugCommand==Write_Device)
    {  i2c_WriteTBL(DebugDeviceAddr, DebugAddress, &DebugData, 1);
    }



  if (!(DebugCommand&BIT0))
    DebugData=((WORD)DebugData+DebugAddress)&0xFF;

  putSIOChar(DebugData);

#endif  
}

Bool GetCommand(void)
{ 
   if (ReSyncCounter)
    { if (RxBusyFlag)
        return TRUE;
      if(EnableAutoColorTempFlag)
        return FALSE;
      if (ReSyncCounter<5)
        { Clr_RxBusyFlag();
          SIORxIndex=0;
		  ReSyncCounter=0;
  		}
    }
  else if (SIORxIndex)
    { SIORxIndex=0;
    }

  return FALSE;
}
void DebugHandler(void)
{
if (GetCommand())
    { 
      ProcessCommand();
      SIORxIndex=0;
      ReSyncCounter=0;
      Clr_RxBusyFlag();
      Power_TurnOffAmberLed();
    }
}

void putSIOChar(unsigned char sendData)
{
#if MTV512
if (!ES) return;
#endif
ES = 0;

  SBUF=sendData;

while (TI);
ES = 1;
  
  ForceDelay1ms(2);
}
void printMsg(char *str)
{ char sendData;

  //sendData=Send_Msg;
  sendData=*(str++);
  while (sendData)//!='\0')
    { putSIOChar((unsigned char)sendData);
      sendData=*(str++);
    }
  putSIOChar(0xd);
  //putSIOChar((char)'\n');
}

#if    1 //0
void printData(char *str, WORD value)
{ char sendData=Send_MsgValue;
#if 0
  putSIOChar(Send_MsgValue);
  putSIOChar(value>>8);
  putSIOChar(value&0xFF);
#endif
  while (sendData=*(str++))
    { if (sendData==(char)'%') // %
        { sendData=*(str++);
          if (sendData==(char)'d' || sendData==(char)'x') // d
            { if (value)
                { Bool noneZero=FALSE;
                  WORD divider=10000;
                  char dispValue;

                  if (sendData==(char)'x')
		    divider=0x1000;
                  while (divider)
		    { dispValue=value/divider;
		      value-=dispValue*divider;
                      if (dispValue)
                      	noneZero=TRUE;
                      if (noneZero)
                      	{ if (dispValue>9)
                      	    dispValue+=55;
                          else
                          	dispValue+=0x30;
                          putSIOChar(dispValue);
                        }
                      if (sendData==(char)'d')
                      	divider/=10;
                      else
                      	divider/=0x10;
                    }
                }
              else
  	        putSIOChar('0');
  	    }
  	}
      else
        putSIOChar(sendData);
    }
  putSIOChar(0xd);
  putSIOChar((char)'\n');
}
#endif

#if !(MTV512)
////////////////zwtan add for pc adjust color
/*void SetTempContrast(BYTE TempContrast)
{
  BYTE temp;
  if (TempContrast<MinContrastValue) TempContrast=MinContrastValue;
  if (TempContrast>MaxContrastValue) TempContrast=MaxContrastValue;
  temp=UserPrefContrast;
  DebugData=TempContrast;
  UserPrefContrast=TempContrast;
  mStar_AdjustRedColor(UserPrefRedColor);
  mStar_AdjustGreenColor(UserPrefGreenColor);
  mStar_AdjustBlueColor(UserPrefBlueColor);
  UserPrefContrast=temp;
}

Bool CheckError(void)
{
Delay1ms(10);
if ((DebugCommand+DebugAddress+DebugData+DebugDeviceAddr)&0xff!=0x00) return FALSE;
return TRUE;
}*/
#endif

⌨️ 快捷键说明

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