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

📄 main.c

📁 tw9910的驱动源码,来自techwell的FAE
💻 C
📖 第 1 页 / 共 5 页
字号:
		if (cerror) {
			Puts(" <- Error!!");
			Prompt();
			commdptr = bptr = 0;
			return;
		}

		//----- Command ---------------------------

		switch(arg[0]) {

		case 'l':
		case 'L':
			{
			static bit logo=0;

			if( logo ) {
				Printf("\r\nClear OSD Logo ");
				OSDClear();
			}
			else {
				Printf("\r\nDisplay OSD Logo ");
				OSDLogo();
			}
			logo = !logo;
			break;
			}

		case 'j':
		case 'J':
			if( argn>=2 ) {
				NewLine();
				MonWriteI2Cn_(I2CAddressDeb, &arg[1], argn-1);
			}
			break;

		case 'x':
		case 'X':
			if( argn>=2 ) {
				NewLine();
				MonWriteI2Cn_(I2CAddressDeb, &arg[1], argn-1);
			}
			break;
			
		case 'w':
		case 'W':
			if(argn == 3) {
				NewLine();
				MonWriteI2C(I2CAddressDeb, arg[1], arg[2]);	
				MonReadI2C(I2CAddressDeb, arg[1]);
	
				DetScaleMode(I2CAddressDeb, arg[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;

		#ifdef TEST_SERCOM
		case '&':
			i = ReadI2C(I2CAddressDeb, arg[1]);
			Printf("%02x",(WORD)i);
			break;

		case '$':
			delay(10);
			WriteI2C(I2CAddressDeb, arg[1] + AddressOffset, arg[2]);
			StoreArg1 = arg[1] + AddressOffset;
			StoreArg2 = arg[2];

			DetScaleMode(I2CAddressDeb, arg[1]);

			break;

		case '^':				// serial communication commander group
			delay(1);
			switch(arg[1]){
			case 1:						// 
				Puts("S1"); delay(1); Puts("15"); // start header of dump data
				for(i=0 ; i < 128 ; i++){
					buf = ReadI2C(I2CAddressDeb, i + arg[2]);
					Printf("%02x",(WORD)buf);
					AddressOffset = arg[2];
					StoreArg1 = 0;	StoreArg2 = 0;
//					delay(1);
				}
				Printf("%02x",(WORD)I2CAddressDeb);
				delay(1);
				Puts("N1"); delay(1);	// end header of dump data
//				Prompt();
				break;
			case 2:						// device address
				I2CAddressDeb = arg[2];				break;
			case 3:
				if(arg[2] == 1){		// increase or decrease
					WriteI2C(I2CAddressDeb, StoreArg1, ++StoreArg2);
					Printf("%02x",(WORD)StoreArg2);

					DetScaleMode(I2CAddressDeb, StoreArg1);

				}else if(arg[2] == 2){
					WriteI2C(I2CAddressDeb, StoreArg1, --StoreArg2);
					Printf("%2x",(WORD)StoreArg2);

					DetScaleMode(I2CAddressDeb, StoreArg1);

				}
													break;
			case 4:
					i = ReadI2C(I2CAddressDeb, arg[2] + AddressOffset);
//					Printf("%02x",(WORD)i);
					StoreArg1 = arg[2] + AddressOffset;
					StoreArg2 = i;
													break;	

			case 8:
					i = ReadI2C(I2CAddressDeb, arg[2] + AddressOffset);
					Printf("%02x",(WORD)i);
					StoreArg1 = arg[2] + AddressOffset;
					StoreArg2 = i;
														break;

			default:								break;
			}
			break;
	

	   	#endif //TEST_SERCOM
			
		case 'Z':	// Closed Caption On/Off
		case 'z':
			if(argn == 2) {
				if( arg[1]==0 ) CCFlag = 0;
				else            CCFlag = 1;
			}
			CaptionOn(CCFlag);
			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;
			for (i=arg[1]; i<=arg[2] && i<0xff; i++) {
				NewLine();
				MonReadI2C(I2CAddressDeb, i);	
			}
			break;
			
		case 'C':	/* Change I2C Address	*/
		case 'c':
			if(argn == 2)
				I2CAddressDeb = arg[1];
			Printf("\r\nI2C address : %02x", I2CAddressDeb);
			break;
			
		case 't':
		case 'T':
			ColorBar = ~ColorBar;
			if(ColorBar) {
				WriteENC(0x01, 0x80);
				Puts(" Test Pattern On");
			}
			else {	
				WriteENC(0x01, 0x00);
				Puts(" Test Pattern Off");
			}
			break;

		case 'i':
		case 'I':
			ChangeInputSW(arg[1]);
			SelectedSW = arg[1];
			break;

		case 'k':
		case 'K':
			if(arg[1] == 1){
				BUSY = 1;
				Puts("\r\n Test NTSC forcing Mode");
				#ifdef	ADV717X
				if(EncoderID == 0x54)
					I2CDeviceSet( ADV7176_NTSC_DataSet );		// P->N
				else if(EncoderID == 0xd4)
					I2CDeviceSet( ADV7175_NTSC_DataSet );
				#elif defined	SAA71XX	//ADV717X
				I2CDeviceSet( SAA7129_NTSC_DataSet );
				#endif	//SAA71XX
			}
			else if(arg[1] == 2){
				BUSY = 0;
				Puts("\r\n Test PAL forcing Mode");
				#ifdef	ADV717X
				if(EncoderID == 0x54)
					I2CDeviceSet( ADV7176_PAL_DataSet );		// N->P
				else if(EncoderID == 0xd4)
					I2CDeviceSet( ADV7175_PAL_DataSet );
				#elif defined	SAA71XX	//ADV717X
				I2CDeviceSet( SAA7129_PAL_DataSet );
				#endif	//SAA71XX
			}
			break;


		case 'o':
		case 'O':
			OutSel++;
			if( OutSel >= 3) OutSel = 0;

			switch( OutSel ) {
			case 0: // YUV
				WriteENC(0x0D, 0x40);
				WriteENC(0x00, 0x70); /* 0x06->0x07 JR081100*/
				Puts(" YUV Output ");
				break;
			
			case 1: // RGB
				WriteENC(0x0D, 0x00);
				WriteENC(0x00, 0x70); /* 0x06->0x07 JR081100*/
				Puts(" RGB Output  ");
				break;
			
			case 2: // YC
				WriteENC(0x00, 0x50); /* 0x04->0x05 JR081100*/
				Puts(" YC Output  ");
				break;
			}
			//Prompt();
			//bptr = 0;commdbuf[0]='\0';
			break;

		case 'S':
		case 's':
			ClosedCaptionToSerial(arg[1],arg[2]);// , OneMenuIndex);
			break;
		
			#ifdef SUPPORT_TELETEXT

			case 'p':	// command	
//			case 'X':
					if(arg[1] != 0x27){
						OSDInitial();
						Puts("\r\nTeletext Command Mode\r");
						WriteI2Cn(TEXTAddress, &arg[1], (argn - 1));
					} else{
						CaptionOn(0);
					}
						
				break;


//			case 'x':	
			case 'P':	// read

					Puts("\r\nTeletext Read Mode (FF : Don't Care)\r");
//					ReadTeleText(&arg[1], (argn - 1));

					ReData[0] = 0xff; ReData[1] = 0xff; ReData[2] = 0xff; ReData[3] = 0xff; ReData[4] = 0xff;
					WriteI2Cn(TEXTAddress, &arg[1], (argn - 1) );
					ReadI2Ctt(TEXTAddress, 0);

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

			case 'q':		// for long command, store

					for(i=0 ; i<3 ; i++)
						ReData[arg[1] + i] = arg[i+2];

					for(i=0 ; i<9 ; i++)
						Printf("\r\nReData[%2x] : %2x",(WORD)i, (WORD)ReData[i]);	
				break;


			case 'Q':		// for long command, execute
					WriteI2Cn(TEXTAddress, ReData, arg[1]);	
				break;

			case 'g':	// Closed Caption Start
					Puts("\r\nClosed Caption On(TeleText)");
					OsdTextInit();
					ReData[0] = 0x49, ReData[1] = 0x0a, ReData[2] = 0x00;    
					WriteI2Cn(TEXTAddress, ReData, 3);	// Set CC Mode
					ReData[0] = 0x49, ReData[1] = 0x0c, ReData[2] = 0x15;    
					WriteI2Cn(TEXTAddress, ReData, 3);	// Set CC Decoder Line
					ReData[0] = 0x48, ReData[1] = 0x26, ReData[2] = 0x04, ReData[3] = 0x58;   
					WriteI2Cn(TEXTAddress, ReData, 4);	// Set CC Display Position
					ReData[0] = 0x49, ReData[1] = 0x02;    
					WriteI2Cn(TEXTAddress, ReData, 2);	// Set CC Mode
				break;
			case 'G':	// Closed Caption Stop
					Puts("\r\nClosed Caption Off(TeleText)");
					CaptionOn(0);
					ReData[0] = 0x49, ReData[1] = 0x06;    
					WriteI2Cn(TEXTAddress, ReData, 2);	// Set CC Mode
				break;

			#endif	// SUPPORT_TELETEXT	

		case 'H':
		case 'h':
		case '?':
			Usage();
			break;

		case 'M':
		case 'm':
			OSDCmd1( arg[1]);
			break;

		case 'Y':
		case 'y':
			OSDCmd2( arg[1] , arg[2]);
			break;

		#ifdef	TMPLL	
		case 'v':			
		case 'V':
			VCOWriteData(arg[1], arg[2], arg[3]);
			Puts("\r\nVCO CLK1 Write : ");
			Printf(" %2x",(WORD)arg[1]);    
			Printf(" %2x",(WORD)arg[2]);     
			Printf(" %2x\r\n",(WORD)arg[3]); 
			break;
		#endif	//TMPLL

		}
		#ifdef TEST_SERCOM
		if(arg[0] != '&' && arg[0] != '^' && arg[0] != '$')
		#endif //TEST_SERCOM
			Prompt();
		commdptr = 0;
		commdbuf[0]='\0';
	}

	//----- 1 byte command ----------------------------
	else {
		switch(ikey) {
		
		case 0x08:		// back space
			if(commdptr>0) {
				commdbuf[commdptr--]='\0';
				RS_tx(ikey);
				RS_tx(' ');
				RS_tx(ikey);
			}
			break;

		case 0x1B:		// Esc 
			Prompt();
			commdptr = 0;commdbuf[0]='\0';
			break;

		case ',':
		case '<':
			RS_tx('\r');
			MonWriteI2C(I2CAddressDeb, arg[1], --arg[2]);
			MonReadI2C(I2CAddressDeb, arg[1]);

			DetScaleMode(I2CAddressDeb, arg[1]);

			Prompt();
			commdptr = 0;commdbuf[0]='\0';
			break;

		case '.':
		case '>':
			RS_tx('\r');
			MonWriteI2C(I2CAddressDeb, arg[1], ++arg[2]);
			MonReadI2C(I2CAddressDeb, arg[1]);

			DetScaleMode(I2CAddressDeb, arg[1]);

			Prompt();
			commdptr = 0;commdbuf[0]='\0';
			break;



		default:
			#ifdef TEST_SERCOM
			if(ikey == '^' || ikey == '$')
 		    	MaskEcho = 1;

			if(!MaskEcho)
			#endif //TEST_SERCOM	
				RS_tx(ikey);

			commdbuf[commdptr++] = ikey;

			break;
		}
	}

}
/*=========================================================================*/
/*        Check Switch                                                     */
/*=========================================================================*/

void CheckSwitch(void)
{
	BYTE i;//, j;
	KeyOn=0;

	
	if(OsdErasingTime == 0x00 && GateET == 1){
		CaptionOn(0x00);
		GateET = 0;
		delay(100);
	}
//	Printf("\r\n(Debug)OsdErasingTime : %02x", (WORD)OsdErasingTime);
	// Switch ON
	if( !(P4 & 0x04) ) {
		
		OsdErasingTime = 0x05;
		GateET = 1;

		for(i=50; i>0; i--) {
			if( P4 & 0x04 ) break;
			delay(2);
		}

		// Short Key
		if( i ) {
//			Printf("\r\n---------> Short Key");
			if(SelectedSW < 1)
				SelectedSW++;
			else
				SelectedSW = 0;

			if(SelectedSW == 0 || SelectedSW == 1)
				ChangeInputSW(SelectedSW);
			DisInput(SelectedSW);

⌨️ 快捷键说明

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