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

📄 monitor.c

📁 车载DVD osdIC TW8816原厂代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		}
		else
			MonIncDecI2C(0);
		break;

	case '<':
		if( incnt ) {
			Mon_tx(ch);
			monstr[incnt++] = ch;
		}
		else
			MonIncDecI2C(10);
		break;
	//--- increamental write
	case '.':
		if( incnt ) {
			Mon_tx(ch);
			monstr[incnt++] = ch;
		}
		else
			MonIncDecI2C(1);
		break;

	case '>':
		if( incnt ) {
			Mon_tx(ch);
			monstr[incnt++] = ch;
		}
		else
			MonIncDecI2C(11);
		break;

	default:
		Mon_tx(ch);
		monstr[incnt++] = ch;
		break;
	}

	if( ret ) {
		comment = 0;
		last_argc = argc;
		return ret;
	}
	else {
		return ret;
	}
}

//*****************************************************************************
//				Monitoring Command
//*****************************************************************************

void Monitor(void)
{
	if( !MonGetCommand() ) return;

	//--------------------------------------------------
	// Check Indirect command
	/*
	if( !stricmp( argv[0], "I" ) ) 			indirect=1;	
	else if( !stricmp( argv[0], "O" ) ) 	indirect=1;	

	else if( !stricmp( argv[0], "," ) ) 	indirect=0;	
	else if( !stricmp( argv[0], ">" ) ) 	indirect=0;	
	else if( !stricmp( argv[0], "<" ) ) 	indirect=0;	
	else if( !stricmp( argv[0], "." ) ) 	indirect=0;	
	else  indirect=0;	
	*/
	indirect = 0;

	//---------------- Write Register -------------------
	if( !stricmp( argv[0], "W" ) ) {
		MonWriteI2C();
	}
	else if( !stricmp( argv[0], ")" ) ) {
		indirect=0;
		MonNewWriteI2C();
	}
	/*
	else if( !stricmp( argv[0], "O" ) ) {			// inderect addressing for 8806
		MonIndex = Asc2Bin( argv[1] );
		MonWdata = Asc2Bin( argv[2] );
		WriteI2C(MonAddress, 0xc5, MonIndex);
		WriteI2C(MonAddress, 0xc6, MonWdata);
		MonRdata = ReadI2C(MonAddress, 0xc6);
		Printf("\r\n==> Read %2xh:%2xh", (WORD)MonIndex, (WORD)MonRdata);
	}
	*/
	//---------------- Read Register --------------------
	else if ( !stricmp( argv[0], "R" ) ) {
		MonReadI2C();
	}
	else if ( !stricmp( argv[0], "(" ) ) {
		indirect=0;
		MonNewReadI2C();
	}
	/*
	else if( !stricmp( argv[0], "i" ) ) {
		MonIndex = Asc2Bin( argv[1] );
		WriteI2C(MonAddress, 0xc5, MonIndex);
		MonRdata = ReadI2C(MonAddress, 0xc6);
		Printf("\r\n==> Read %2xh:%2xh", (WORD)MonIndex, (WORD)MonRdata);

	}
	*/
	//---------------- Dump Register --------------------
	else if( !stricmp( argv[0], "D" ) ) {
		Puts("\r\ndump start");
		MonDumpI2C();
	}
	else if( !stricmp( argv[0], "&" ) ) {
		indirect=0;
		MonNewDumpI2C();
	}

	//---------------- Bit Operation --------------------
	else if( !stricmp( argv[0], "B" ) ) {// Write bits - B AA II bb DD
		MonWriteBit();
	}
	/*	no indirect addressing in TW8816
    //---------------------------------------------------
	else if( !stricmp( argv[0], "@" ) ) { // Indirect address bit access

					BYTE Slave, mask, FromBit, ToBit,  MonMask, val,i;
					// @ 8a iaddr idata index  startbit|endbit  data
					// 0  1   2    3     4     5                 6

					if( argc<7 ) {
						Printf("   --> Missing parameter !!!");
						return;
					}

					Slave = Asc2Bin(argv[1]);
					
					FromBit = Asc2Bin( argv[5] );
					FromBit  = ( FromBit >> 4) & 0x0f;
					ToBit = Asc2Bin( argv[5] );
					ToBit  =  ToBit & 0x0f;
					MonMask  = Asc2Bin( argv[6] );

					if( FromBit<ToBit || FromBit>7 || ToBit>7) {
						Printf("\r\n   --> Wrong range of bit operation !!!");
						return;
					}
	
					mask = 0xff; 
					val=0x7f;
					for(i=7; i>FromBit; i--) {
						mask &= val;
						val = val>>1;
					}

					val=0xfe;
					for(i=0; i<ToBit; i++) {
						mask &= val;
						val = val<<1;
					}

					// @ 8a iaddr idata index  startbit|endbit  data
					// 0  1   2    3     4     5                 6
					MonIndex = Asc2Bin(argv[2]);
					MonWdata = Asc2Bin(argv[4]);
					WriteI2C( Slave, MonIndex, MonWdata);

					MonRdata = ReadI2C(Slave, Asc2Bin( argv[3]));
					MonWdata = (MonRdata & (~mask)) | (MonMask & mask);
					MonIndex = Asc2Bin(argv[3]);
					WriteI2C(Slave, MonIndex, MonWdata);

					MonRdata = ReadI2C(Slave, MonIndex);

					Printf("\r\n<R>%2x[%2x]=%2x", (WORD)Slave, (WORD)MonIndex, (WORD)MonRdata);

	}
	//------------------------------------------------------------------				
	else if( !stricmp( argv[0], "!" ) ) //  Indirect address write access
	{
					BYTE Slave;
					// @ 8a iaddr idata index data
					if( argc<6 ) {
						Printf("   --> Missing parameter !!!");
						return;
					}

					Slave = Asc2Bin(argv[1]);

					MonIndex = Asc2Bin(argv[2]);
					MonWdata = Asc2Bin(argv[4]);
					WriteI2C(Slave, MonIndex, MonWdata);

					MonIndex = Asc2Bin(argv[3]);
					MonWdata = Asc2Bin(argv[5]);
					WriteI2C(Slave, MonIndex, MonWdata);

					MonRdata = ReadI2C(Slave, MonIndex);

					Printf("\r\n<R>%2x[%2x]=%2x", (WORD)Slave, (WORD)MonIndex, (WORD)MonRdata);

	}
	*/    

	//---------------- Change I2C -----------------------
	else if( !stricmp( argv[0], "C" ) ) {
		MonAddress = Asc2Bin( argv[1] );
	}

	//---------------- Help -----------------------------
	else if( !stricmp( argv[0], "H" ) || !stricmp( argv[0], "HELP" ) || !stricmp( argv[0], "?" ) ) {
		MonHelp();

	}
	//---------------------------------------------------
	else if( !stricmp( argv[0], "*" ) ) {
			
				if( argc==1 ) {
					Printf("\r\n  * 0 : Program default Loader");
					Printf("\r\n  * 1 : Program external Loader");
					Printf("\r\n  * 2 : Execute Loader");
				}
				else { 
					BYTE mode;
					mode = Asc2Bin(argv[1]);
					Loader(mode);
				}
	}

	//---------------------------------------------------
#if defined( SUPPORT_PC ) || defined( SUPPORT_DTV )
	else if( !stricmp( argv[0], "PCLK" ) ) {
		PclkAccess();			
	}
#endif	
	//---------------------------------------------------
	else if( !stricmp( argv[0], "POWER" ) ) {
		LCDPower();
	}	
	//---------------------------------------------------
#if defined( SUPPORT_PC ) || defined( SUPPORT_DTV )
	else if( !stricmp( argv[0], "M" ) ) {
		if( argc==2 ) {
			if( !stricmp( argv[1], "?" ) ) {
				BYTE i;
				Printf("\r\nCurrent Input:%d \r\n", (WORD)InputSelection);
				for(i=1; struct_InputSelection[i].Id!=0 ; i++)
						Printf("%s:%d  ",struct_InputSelection[i].Name,(WORD)struct_InputSelection[i].Id );
				Printf("\r\n");
			}
			else
				ChangeInput(Asc2Bin( argv[1] ));
		}
		else
			ChangeInput(GetNextInputSelection());
	}	
	//---------------------------------------------------
	else if( !stricmp( argv[0], "PCAUTO" ) ) {
		Puts("\r\nPC Auto Measurement");
		AutoAdjust();
	}	
#endif
	//---------------------------------------------------
	else if( !stricmp( argv[0], "AUTODETECT" ) ) {
		if( argc==2 ) {
			AutoDetect = Asc2Bin(argv[1]);
		}
		Printf("\r\nAuto Detect = %d", (WORD)AutoDetect);
	}	
	//---------------- Debug Level ---------------------
	else if ( !stricmp( argv[0], "DEBUG" ) ) {
		if( argc==2 ) {
			DebugLevel = Asc2Bin(argv[1]);
			SaveDebugLevelEE(DebugLevel);
		}
		Printf("\r\nDebug Level = %2x", (WORD)DebugLevel);
	}
	
	//---------------- Display on/off -------------------
	else if ( !stricmp( argv[0], "echo" ) ) {
		if( !stricmp( argv[1], "off" ) ) {
			echo = 0;
			Printf("\r\necho off");
		}
		else {
			echo = 1;
			Printf("\r\necho on");
		}
	}
	//---------------- OSD test for parallel -----------------------------------
	else if( !stricmp( argv[0], "OSD" ) ) {
		if( !stricmp( argv[1], "logo" ) ) {
			DisplayLogo();
		}
		else if( !stricmp( argv[1], "input" ) ) {
			DisplayInput();
		}
		else if( !stricmp( argv[1], "off" ) ) {
			ShowOSDWindowAll(OFF);
		}
	}
	
	//---------------- serial tx test with some number -----------------------------------
	else if( !stricmp( argv[0], "TX" ) ) {
		MonTxDump();
	}
	//---------------- OSD FONTtest for parallel -----------------------------------
	else if( !stricmp( argv[0], "FONT" ) ) {
		if ( !stricmp( argv[1], "RAM" ) ) {
			DisplayRAMFont( Asc2Bin(argv[2]) );
		}
		else if ( !stricmp( argv[1], "ROM" ) ) {
			DisplayROMFont(Asc2Bin(argv[2]));
		}
		else {
			Puts("\r\n Font ROM # or Font RAM # for testing");
		}
	}
#ifdef INTERNAL_MCU
	//---------------- interrrupt control for MCU -----------------------------------
	else if( !stricmp( argv[0], "IRQ" ) ) {
		if ( !stricmp( argv[1], "TW" ) ) {
			if ( Asc2Bin(argv[2]) == 1 )
				EIE |= 0x02;	// set interrupt Enable
			else
				EIE &= 0xFD;	// set interrupt Disable
		}
		else if ( !stricmp( argv[1], "PDN" ) ) {
			if ( Asc2Bin(argv[2]) == 1 )
				EIE |= 0x08;	// set interrupt Enable
			else
				EIE &= 0xF7;	// set interrupt Disable
		}
		else {
			Printf("\r\n EIE register value: %2x", (WORD)EIE);
		}
	}
	//---------------- I2c port test for MCU -----------------------------------
	else if( !stricmp( argv[0], "I2C" ) ) {
		if ( !stricmp( argv[1], "SCL" ) ) {
			if ( Asc2Bin(argv[2]) == 1 )
				I2C_SCL = 1;	
			else
				I2C_SCL = 0;	
		}
		else if ( !stricmp( argv[1], "SDA" ) ) {
			if ( Asc2Bin(argv[2]) == 1 )
				I2C_SDA = 1;	
			else
				I2C_SDA = 0;	
		}
		else {
			Printf("\r\n SCL:%1d, SDA:%1d", (WORD)I2C_SCL, (WORD)I2C_SDA);
		}
	}
	//---------------- LED port test for MCU -----------------------------------
	else if( !stricmp( argv[0], "LED" ) ) {
		#define GREEN_LED	P1_7
		#define RED_LED		P1_6
		if ( argc == 3 ) {
			if ( !stricmp( argv[1], "RED" ) ) {
				if ( Asc2Bin(argv[2]) == 1 )
					RED_LED = 1;	
				else
					RED_LED = 0;	
			}
			else if ( !stricmp( argv[1], "GREEN" ) ) {
				if ( Asc2Bin(argv[2]) == 1 )
					GREEN_LED = 1;	
				else
					GREEN_LED = 0;	
			}
		}
		else {
			Printf("\r\n RED:%1d, GREEN:%1d", (WORD)RED_LED, (WORD)GREEN_LED);
		}
	}
	//---------------- LED port test for MCU -----------------------------------
	else if( !stricmp( argv[0], "REMOTE" ) ) {
		if ( argc == 2 ) {
			if ( Asc2Bin(argv[1]) == 1 )
				P3_2 = 1;	
			else
				P3_2 = 0;	
		}
		else {
			Printf("\r\n IR:%1d", (WORD)P3_2);
		}
	}
	//---------------- Access direct memory space -----------------------------------
	else if( !stricmp( argv[0], "MEMR" ) ) {
		BYTE	xdata * xDataPtr;

		if ( argc == 2 ) {
			xDataPtr = Asc2Bin(argv[1]);
			Printf("\r\n %04x:%02x", (WORD)xDataPtr, (WORD)*xDataPtr);
		}
	}
	
	//---------------- Access direct memory space -----------------------------------
	else if( !stricmp( argv[0], "MEMW" ) ) {
		WORD	val;
		BYTE	xdata * xDataPtr;

		if ( argc == 3 ) {
			val = Asc2Bin(argv[2]);
			xDataPtr = Asc2Bin(argv[1]);
			*xDataPtr = val;
		}
	}
	
	//---------------- Access direct register space -----------------------------------
	else if( !stricmp( argv[0], "REGR" ) ) {
		BYTE	xdata * xDataPtr;

		if ( argc == 2 ) {
			xDataPtr = Asc2Bin(argv[1]) + 0xc000;
			Printf("\r\n %04x:%02x", (WORD)xDataPtr, (WORD)*xDataPtr);
		}
	}
	
	//---------------- Access direct register space -----------------------------------
	else if( !stricmp( argv[0], "REGW" ) ) {
		WORD	val;
		BYTE	xdata * xDataPtr;

		if ( argc == 3 ) {
			val = Asc2Bin(argv[2]);
			xDataPtr = Asc2Bin(argv[1]) + 0xc000;
			*xDataPtr = val;
		}
	}
	
	//---------------- Direct entering STOP mode -----------------------------------
	else if( !stricmp( argv[0], "STOP" ) ) {
		PowerDown();	// enter stop mode
	}
	
	//---------------- Timer divider for MCU CORE -----------------------------------
	else if( !stricmp( argv[0], "TIMER0" ) ) {
		WORD	val;
		if ( argc == 1 ) {
			val = T0HIGH;
			val <<= 8;
			val |= T0LOW;
			Printf( "\r\n divide number for Timer 0: %4x ", val );
		}
		else {
			val = (WORD)a2i(argv[1]);
			T0LOW = val;
			T0HIGH = (val >> 8);
		}			
	}
	
	//---------------- Timer divider for MCU CORE -----------------------------------
	else if( !stricmp( argv[0], "TIMER1" ) ) {
		WORD	val;
		if ( argc == 1 ) {
			val = T1HIGH;
			val <<= 8;
			val |= T1LOW;
			Printf( "\r\n divide number for Timer 1: %4x ", val );
		}
		else {
			val = (WORD)a2i(argv[1]);
			T1LOW = val;
			T1HIGH = (val >> 8);
		}			
	}
	
	//---------------- Timer divider for MCU CORE -----------------------------------
	else if( !stricmp( argv[0], "TIMER2" ) ) {
		WORD	val;
		if ( argc == 1 ) {
			val = T2HIGH;
			val <<= 8;
			val |= T2LOW;
			Printf( "\r\n divide number for Timer 2: %4x ", val );
		}
		else {
			val = (WORD)a2i(argv[1]);
			T2LOW = val;
			T2HIGH = (val >> 8);
		}			
	}
	//---------------- SPI flash control -----------------------------------
	else if( !stricmp( argv[0], "SPI" ) ) {
		WORD	val;
		if ( argc == 1 ) {
			val = SPICONTROL;
			Printf( "\r\n SPI control Register: %2x", val );
		}
		else {
			val = Asc2Bin(argv[1]);
			SPICONTROL = val;
		}			
	}
	//---------------- SPI flash control -----------------------------------
	else if( !stricmp( argv[0], "PORT" ) ) {
		WORD	val;
		if ( argc == 1 ) {
			val = P2;
			Printf( "\r\n MCU PORT(2) value: %2x", val );
		}
		else {
			val = Asc2Bin(argv[1]);
			P2 = val;
		}			
	}
	//---------------- BANK control -----------------------------------
	else if( !stricmp( argv[0], "BANK" ) ) {
		WORD	val;
		if ( argc == 1 ) {
			val = BANKREG;
			Printf( "\r\n BANK(0x9a) value: %2x", val );
		}
		else {
			val = Asc2Bin(argv[1]);
			BANKREG = val;
		}			
	}
#endif //INTERNAL_MCU
	
	//---------------- Delta RGB Panel Test -------------------------
	#ifdef SUPPORT_DELTA_RGB

	else if( !stricmp( argv[0], "delta" ) ) {
		if( argc==1 )	DeltaRGBPanelInit();
		else {
			
			if( !stricmp( argv[1], "w" ) ) {

				WORD val;
				val= Asc2Bin(argv[3])<<8 | Asc2Bin(argv[4]);
				Printf("\r\n SPI Write: Addr:%2x  Data:%4x", (WORD)Asc2Bin(argv[2]), val);
				WriteSPI(Asc2Bin(argv[2]), val );
			}
			else if( !stricmp( argv[1], "r" ) ) {
				WORD val;
				val = ReadSPI(Asc2Bin(argv[2]));
				Printf("\r\n SPI Read: Addr:%2x  Data:%4x", (WORD)Asc2Bin(argv[2]), val);
			}
		}
	}
	#endif
	//----------------------------------------------------
	else {
		Printf("\r\nInvalid command...");
	}


	Prompt();


}


//-------------------------------------------------------------------------


#endif

⌨️ 快捷键说明

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