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

📄 main.c

📁 此程序为twell8806驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
			switch(arg[0]) 
			{

			//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			case '(':	// New read
				indirect=0;
				i = ReadI2C( arg[1], arg[2] );
				Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], arg[2], i);
				break;

			case ')':	// New write
				indirect=0;
				WriteI2C( arg[1], arg[2], arg[3] );

				i = ReadI2C( arg[1], arg[2] );
				Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], arg[2], i);
				break;

			case '&':	// New Dump
				indirect=0;
				for(i=arg[2]; i<=arg[3]; i++) {
					Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], i, ReadI2C(arg[1], i) );
					if( i==0xff ) break;
				}
				break;
			case '^':
				for(i=0x80; i<=0xfe; i++) { //Access Ticon Register.
					WriteI2C( arg[1], 0xc5, i );
					Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], 0xc5, ReadI2C(arg[1], 0xc5) );
					Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], 0xc6, ReadI2C(arg[1], 0xc6) );
				}
				break;

			case '%':	// Dump OSD
				for(i=0; i<8; i++) {
					BYTE a;
					WriteI2C( arg[1], 0x9e, i );
					Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], 0x9e, ReadI2C(arg[1], 0x9e) );
					for(a=0x9e; a<=0xad; a++) {
						Printf("\n<R>%02bx[%02bx]=%02bx", arg[1], a, ReadI2C(arg[1], a) );
					}
				}
				break;
					
			//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			//------------------------------------------------------------------
/*
			case '#':
				{
					BYTE i, j;

					for(j=0; j<8; j++) {
						Printf("\r\nWindow %bd :", j );
						WriteTW88(0x9e, j);
						for(i=0x9e; i<=0xad; i++) {
							Printf(" %02bx", ReadTW88(i) );
						}
					}
				}
				break;


			case 'a':
			case 'A':
				switch( arg[1] ) {
				case 0:
					while(1) {
						Printf("\r\nReg1:0x%x, Reg1C:0x%x", (WORD)ReadDecoder(CSTATUS), (WORD)ReadDecoder(SDT) );
						if( RS_ready() ) {
							RS_rx();
							break;
						}
					}
					break;

				case 1:
					{
					BYTE IRint;
					while(1) {
						
						IRint = P3_2;
						Printf("\r\nIR Int:%d", (WORD)IRint );
						if( RS_ready() ) {
							RS_rx();
							break;
						}
					}
					}
					break;


				}
				break;
*/
			case '*':
				if( argn==1 ) Printf("\r\n  * 2 : Execute Loader");
				else          Loader(arg[1]);
				break;
			
			#ifdef SUPPORT_PC
			case '1':

				tm001 = tic_pc = 0;
				DetectAndSetForVGAInput(0);
				Printf("\r\n--- Execute Auto Mode:%d  Time: %d.%02d sec", (WORD)PcMode, (WORD)tic_pc/100, (WORD)tic_pc%100);
				LCDPowerON(0);		// HHY 1.63

				break;

			case '3':
				//AutoColorAdjust(arg[1]);
				break;

			#ifdef SUPPORT_DTV
			case '4':
				//AutoColorAdjustForDTV(arg[1]);
				break;

/*				
			case 'v':
			case 'V':
				{
				WORD i, h;

				SetMeasureWindowV(100, 120);
				for(i=0; i<86; i++) {
					h = i*10;
					SetMeasureWindowH(h, h+10);
					MeasureAndWait(3);

					Printf("\r\n---- Window H=(%3d ~ %3d) ", h, h+10);

					// read Y
					WriteTW88(0x5b, 0x30);
					Printf("  Y=(%3d ~ ", (WORD)ReadTW88(0x59) );
					WriteTW88(0x5b, 0x40);
					Printf("%3d)", (WORD)ReadTW88(0x59) );

					// read Pb
					WriteTW88(0x5b, 0x30);
					Printf("  Pb=(%3d ~ ", (WORD)ReadTW88(0x58) );
					WriteTW88(0x5b, 0x40);
					Printf("%3d)", (WORD)ReadTW88(0x58) );

					// read Pr
					WriteTW88(0x5b, 0x30);
					Printf("  Pr=(%3d ~ ", (WORD)ReadTW88(0x57) );
					WriteTW88(0x5b, 0x40);
					Printf("%3d)", (WORD)ReadTW88(0x57) );

				}

				break;

				}
*/				#endif // SUPPORT_DTV
				
			case '7':
				GetHpnVpn(1);
				break;

			case '9':
				GetActiveRegion();
				break;
/*
			case 'q':
			case 'Q':
				if( argn==1 ) {
					NewLine();
					break;
				}
				switch (arg[1]) {
				case 0:	ResetPCValue();		break;
				case 1:	MoveActiveHpos(UP);	break;	// Shift Left
				case 2:	MoveActiveHpos(DN);	break;	// Shift Right
				case 3:	MoveActiveVpos(UP);	break;	// Shift Up
				case 4:	MoveActiveVpos(DN);	break;	// Shift Down
				}
				break;
*/
/****
			case 'l':
			case 'L':
				TuneLineBuffer(0);
				TuneLineBuffer(1);
				break;
****/

			#endif	// SUPPORT_PC

			#ifdef CHIP_MANUAL_TEST
			case '0':
				OnChipTest = 1;		
				break;

			#endif

			#ifdef DEBUG_TV
			case '5':
				//Printf("\r\nTV Status(I2C Address:0x%02x):0x%02x", (WORD)TVTunerI2CAddress, (WORD)ReadI2CStatus(TVTunerI2CAddress) );
				Printf("\r\nRead Status(I2C Address:0x%02x):0x%02x", (WORD)I2CAddressDeb, (WORD)ReadI2CStatus(I2CAddressDeb) );
				break;
			#endif	// DEBUG_TV

			#ifdef DEBUG_OSD
			case 'f':
			case 'F':
				if( argn==1 )         ClearOSD();
				else if( arg[1]==0 )  DisplayROMFont(arg[2]);		//with start code.
				else if( arg[1]==1 )  DisplayRAMFont();
				else if( arg[1]==2 )  DisplayInput();
				else if( arg[1]==3 )  ClearInput();
				#ifdef SUPPORT_CCD_VCHIP
				InitClosedCaption();
				#endif
				break;
			#else
			case 'f':
				if( arg[1]==0 ) {
					ChangeVol(-1);
					DisplayVol();
				}
				else if( arg[1]==1 ) {
					ChangeVol(1);
					DisplayVol();
				}
				#ifdef SUPPORT_CCD_VCHIP
				else if( arg[1]==2 ) {
					CheckAndBlockInput(arg[2]);	// Movie
				}
				else if( arg[1]==3 ) {
					CheckAndBlockInput(arg[2]);	// TV
				}
				#endif //SUPPORT_CCD_VCHIP
				else if( arg[1]==4 ) {
					DisplayMuteInfo();
				}
				break;
			#endif	// DEBUG_OSD

			case 'm':
			case 'M':
				if( argn==1 )
					ChangeInput(GetNextInputSelection());			// Input - Input Source Change Key
				else
					ChangeInput(arg[1]);
				break;

			case 'e':
			case 'E':
				if( argn>1 ) {
					switch( arg[1] ) {
/*
					case 0x08:		//test to readEEP several times
						if( argn==3 ) {
							BYTE dt1=0, dt2=0;
							
							Printf("\r\nTest ReadEEP and WriteEEP:(indx:0x%x) 20 times", (WORD)arg[2]);
							for(i=0; i<20; i++) {
								WriteEEP(0x80,0);
								dt2 = ReadEEP(arg[2]);
								if( dt2 != dt1 ) {
									dt1 = dt2;
									Printf("\r\n   data[%d]:0x%x", (WORD)i, (WORD)dt1);
								}
							}
						}
						break;
					
					case 0x09:
						if( argn==2 ) {
							i=(BYTE)Flag4AutoPanelRegs;
							Printf("\r\nAuto change of FPHS period: %02x", (WORD)i);
						}
						else if( arg[2]==0 || arg[2]==1 ) {
							Printf("\r\nAuto change of FPHS period: %02x", (WORD)arg[2]);
							Flag4AutoPanelRegs = (bit)arg[2];
						}
						break;

					case 0x0a:
						if( argn==3 ) ChangeVInputStdDetectMode(arg[2]);
						Printf("\r\nCurrent Video Mode Detect: %s", struct_VInputStd[GetVInputStdInx()].Name);
						break;
*/						
					#ifdef DEBUG_CCEDS
					case 0xd:	//Choose type of debugging message for CC/EDS
						if( argn==2 ) {
							Printf("\r\nCurrent type of debugging message for CC/EDS: %02x", (WORD)GetDebugTypeCCEDS());
						}
						else if( arg[2] <=3 ) {
							Printf("\r\nType of debugging message for CC/EDS: %02x", (WORD)arg[2]);
							SetDebugTypeCCEDS (arg[2]);
						}
						#ifdef TEST_WSS
						else if( arg[2]==4 ) {	//test_wss
							BYTE val;

							Printf("\r\nEnable and monitor WSS");
							WriteDecoder(VBI_CNTL2, ReadDecoder(VBI_CNTL2) | 0x20);		// 0x34, enable WSS
							while(1) {
								if( ReadDecoder(CSTATUS3) & 0x04 ) {
									val = ReadDecoder(WSS1);
									if( val & 0x80 )
										Printf("\r\n--CRC error");
									else 
										Printf("\r\n--%c [%2x] [%2x]", 
										(val & 0x40 ? 'E' : 'O'),
										(WORD)(val & 0x3f), 
										(WORD)ReadDecoder(WSS2) );
								}
								if( RS_ready() ) {
									RS_rx();
									break;
								}
							}
						}
						#endif // TEST_WSS
						break;
					#endif // DEBUG_CCEDS

					case 0xe:	//DebugLevel
						if( argn==3 ) {
							DebugLevel = arg[2];
							SaveDebugLevelEE(DebugLevel);
						}
						Printf("\r\nCurrent DebugLevel: %02x", (WORD)DebugLevel);
						break;

					case 0xf:	//clear user-defined value	//1.07
						Printf("\r\nInitalized total EEPROM!!");
						ClearBasicEE();

						#ifdef SUPPORT_PC
						ResetPanelAttributeValue();
						SaveDefaultPCDataAllEE();
						//AutoColorAdjust(0);
						
						#endif

//						#ifdef SUPPORT_DTV
//						SaveADCGainOffsetForDTVEE(0);
//						#endif
						
						#ifdef SUPPORT_TV
						ResetTVValue();
						#endif
						break;

					default:
						Puts("\r\nInvalid command. please read Help...");
						break;
					}
				}
				break;

			case 'p':
			case 'P':
				LCDPower();
				break;

			case 'w': // TW98>W 01 55 ; Write 55 to index 01 register
			case 'W': // Write with 2 args and Read it back.
				if(argn == 3) {
					NewLine();
					MonWriteI2C(I2CAddressDeb, arg[1], arg[2]);
					MonReadI2C(I2CAddressDeb, arg[1]);
				}
				break;

			case 'o': // Indirect write: o index data
			case 'O': // 
				if(argn == 3) {
					NewLine();
					MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
					RS_tx('\r');
					MonWriteI2C(I2CAddressDeb, 0xc6, arg[2]);
					RS_tx('\r');
					MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
					MonReadI2C(I2CAddressDeb, 0xc6);
				}
				break;


			#if defined SUPPORT_TELETEXT && defined DEBUG_TELETEXT

			case 'x':	// teletext command	
					dPuts("\r\nTeletext Command Mode\r");
					
//					WriteI2CnLong(TEXTAddress, &arg[1], (argn - 1));	
					WriteI2CnLong(arg[1], &arg[2], (argn - 2));	
					break;


			case 'X':	// teletext read status
					{
					BYTE j;
					BYTE ReData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};

					Puts("\r\nTeletext Read Mode (FF : Don't Care)\r");

					WriteI2CnLong(TEXTAddress, &arg[1], (argn - 1) );
					ReadI2Ctt(TEXTAddress, ReData, 0);

					if((ReData[0] & 0x20) == 0x20){
						ReadI2Ctt(TEXTAddress, ReData, 4);		// 4 : One Status + Four Read Byte
						Printf("\r\nFirst Status:%2x", (WORD)ReData[0]);
					}
					else{ // if((ReData[0] & 0x20) != 0x20){
						for(j=0 ; j<0x0f ; j++){
							delay(1);
							ReadI2Ctt(TEXTAddress, ReData, 0);
							if((ReData[0] & 0x20) != 0x20){
								if(j == 0x0e)
									Puts("\r\nReading Fail");
									break;
							}
							else{// if((ReData[0] & 0x20) == 0x20){
								j = 0x0f;
								ReadI2Ctt(TEXTAddress, ReData, 4);
							}
						}
					}
					Printf("\r\n   Status    : %2x\r",(WORD)ReData[0]);
					for(j=0 ; j<4 ; j++)
						Printf("\r\n   DataByte%d : %2x", (WORD)(j+1), (WORD)ReData[j+1]);
					}
					break;

				
			#endif	// SUPPORT_TELETEXT


//			#ifdef MYSON_OSD
/*			case 'o':
			case 'O':

				I2CStart();
	
				Printf("\r\nWrite ");
				for(i=1; i<argn; i++) {
					I2CWriteData(arg[i]);
					Printf("[%02x] ", (WORD)arg[i]);
				}

				I2CStop();

				break;


			case 'k':
			case 'K':
				{
				BYTE j; 

				// Initial Row attr
				I2CStart();
				I2CWriteData(0x7a);		// sub addr
				I2CWriteData(0x8e);		// row addr
				for(i=0; i<15; i++) {
					I2CWriteData(i);	// col addr
					I2CWriteData(0);	// data
				}				
				I2CStop();

				// Initial Ch attr
				for(j=0; j<15; j++) {	
					I2CStart();
					I2CWriteData(0x7a);
					I2CWriteData(0xa0+j);		// row addr
					I2CWriteData(0);		// col addr
					for(i=0; i<30; i++) {
						I2CWriteData(0x16);
					}				
					I2CStop();
				}

				// Initial Ch attr
				for(j=0; j<15; j++) {	
					I2CStart();
					I2CWriteData(0x7a);
					I2CWriteData(0x80+j);		// row addr
					I2CWriteData(0);		// col addr
					for(i=0; i<30; i++) {
						I2CWriteData(i);
					}				
					I2CStop();
				}
				}
				break;

//			#endif	// MYSON_OSD

			case 'i':
			case 'I':
			{
				PDATA BYTE buf[5], i, cnt;
				if( argn==2 ) cnt = arg[1];
				else          cnt = 1;
				ReadI2CStatusn(I2CAddressDeb, cnt, buf);
				Printf("\r\nRead Status(I2C Address:0x%02x) =", (WORD)I2CAddressDeb );
				for(i=0; i<cnt; i++)
					Printf(" %02x", (WORD)buf[i] );

				break;
			}
*/
			case 'j':
			case 'J': // Write with more than 1 arg(s) and no read it back
					if( argn>=2 ) {
						NewLine();
						//MonWriteI2Cn(MSPI2CAddress, arg[1], &arg[2], argn-2);
						MonWriteI2Cn_(I2CAddressDeb, &arg[1], argn-1);
					}
					break;

			case 'r':
			case 'R':
				if( argn==2 ) {
					NewLine();
					arg[2] = MonReadI2C(I2CAddressDeb, arg[1]);

				}
				else if( argn > 2 ) {		// Read several Byte with several index.
											// r cmd1 cmd2 ... rcnt
											// ex) r 10 20 5
											// read 5 bytes from index 1020.
											// Useful for Z86129(CC Decorder).
					NewLine();
					MonReadI2Cmn(I2CAddressDeb, &arg[1], argn-1);
				}
				break;

			case 'i':
			case 'I':
				if( argn==2 ) {
					NewLine();
					MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
					arg[2] = MonReadI2C(I2CAddressDeb, 0xc6);
				}
				break;

			case 'D':
			case 'd':
				if(argn == 1) {
					arg[1]+=8;
					arg[2] = arg[1]+7;
				}
				else if(argn == 2)
					arg[2] = arg[1]+7;
				if ( arg[2] < arg[1] )	arg[2] = 0xff;
				for (i=arg[1]; i<=arg[2] /*&& i<0xff*/; i++) {
					NewLine();
					MonReadI2C(I2CAddressDeb, i);
					if( i==0xff )
						break;
				}
				break;

			case 'c':
			case 'C':	// Change I2C Address	
				if(argn == 2)
					I2CAddressDeb = arg[1];
				Printf("\r\nI2C address : %02x", (WORD)I2CAddressDeb);
				break;

#ifdef CHIP_MANUAL_TEST
			case 't':
			case 'T':	// Change Manual test loop time	
				if(argn == 2)
					ManualFrequency = arg[1];
				Printf("\r\nChanged Manual Test Speed : %02x", (WORD)ManualFrequency);
				Printf("\r\nPush number 0 of the key if manual test starts again.");
				break;

#endif

			case '\0':
				break;

/*
			case 'k':

⌨️ 快捷键说明

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