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

📄 console.cpp

📁 用C语言设计的EPSON LCD控制器S1D13700驱动。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		printf( " %*.*s16 [StartAddr [EndAddr|Len]]\n", argn, argn, argv[0] );
		printf( " %*.*s32 [StartAddr [EndAddr|Len]]\n\n", argn, argn, argv[0] );
		//		 --------------------------------------80 COLS----------------------------------
		printf( " Shows a memory dump starting at StartAddr.\n" );
		printf( " 8|16|32     - Unit size (8-bit|16-bit|32-bit). If the number is missing, this\n" );
		printf( "               command will use whatever unit size you used in your last Dump\n" );
		printf( "               command (default:8-bit).\n" );
		printf( " StartAddr   - The starting address to write data to. If you use a period (.),\n" );
		printf( "               it will use the same address you gave in your last Dump command.\n" );
		printf( " EndAddr|Len - Determines where to stop dumping. If this term starts with 'L',\n" );
		printf( "               then the number that follows represents Len, for instance, 'L8'\n" );
		printf( "               (length=8). Otherwise, the number represents EndAddr.\n" );
		return TRUE;
	}

	// Check parameters.
	if ( ConParseCommand(argv[0],ConDumpUnitSize[ConContext],&ConDumpUnitSize[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid command.\n", argv[0] );
		return FALSE;
	}
	if ( ConParseStartAddr(argv[1],ConDumpStartAddr[ConContext],ConDumpLen[ConContext],&ConDumpStartAddr[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid start address.\n", argv[1] );
		return FALSE;
	}
	if ( ConParseLen(argv[2],ConDumpStartAddr[ConContext],ConDumpUnitSize[ConContext],ConDumpLen[ConContext],&ConDumpLen[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid end address or length.\n", argv[2] );
		return FALSE;
	}
	StartAddrAligned = (ConDumpStartAddr[ConContext]/16)*16;

	// Do operation.
	for ( i=(Int32)StartAddrAligned-ConDumpStartAddr[ConContext]; i<(Int32)ConDumpLen[ConContext]; i+=16 )
	{
		int ii;
		printf( "%08lX:  ", ConDumpStartAddr[ConContext]+i );
		for ( ii=0; ii<16; ii+=ConDumpUnitSize[ConContext] )
		{
			if ( (ii+8)%16 == 0 )
				printf( " " );
			if ( (i+ii)<=(-ConDumpUnitSize[ConContext]) || (i+ii)>=(Int32)ConDumpLen[ConContext] )
				printf( (ConDumpUnitSize[ConContext]==1?"-- ":(ConDumpUnitSize[ConContext]==2?"---- ":"-------- ")) );
			else
			{
				UInt32 Data = (*ConReadMem)( ConBaseAddr+ConDumpStartAddr[ConContext]+i+ii, ConDumpUnitSize[ConContext] );
				switch ( ConDumpUnitSize[ConContext] )
				{
					default:
					case 1:   *(pUInt8)(LineCache+ii)= (UInt8)Data;  printf("%02X ",*(pUInt8)(LineCache+ii));    break;
					case 2:  *(pUInt16)(LineCache+ii)=(UInt16)Data;  printf("%04X ",*(pUInt16)(LineCache+ii));   break;
					case 4:  *(pUInt32)(LineCache+ii)=(UInt32)Data;  printf("%08lX ",*(pUInt32)(LineCache+ii));  break;
				}
			}
		}
		printf( " \'" );
		for ( ii=0; ii<16; ii++ )
		{
			if ( (i+ii)<=(-ConDumpUnitSize[ConContext]) || (i+ii)>=(Int32)ConDumpLen[ConContext] )
				printf( "-" );
			else
			{
				UInt32 dw = (UInt32)LineCache[ii];
				ConPrintCharData( &dw, 1 );
			}
		}
		printf( "\'\n" );

		if (!ConNextLine( iLine++, Halt ))
			break;
	}
	ConDumpStartAddr[ConContext] += ConDumpLen[ConContext];
	return TRUE;
}




Boolean ConFillCommand( int Halt, int argc, argvtype argv )
//
//	Fill memory with given data.
//
//	PARAMETERS:
//
//		Halt      [in] - The number of lines to show at a time. If 0, then
//						 halt is disabled.
//		argc,argv [in] - The whole command-line (if you don't have an argv,
//						 call ConArgvAlloc() and ConArgvParse() first).
//
{
	UInt32  i, iData;
	int     nData, ErrorCode;
	arglist	Data;

	Halt = 0; // Must reference un-used parameters to avoid stupid compiler warnings.

	if ( argv[1][0] == '?' )
	{
		int argn = ConParseCommandLen( argv[0] );
		printf( "\n" );
		printf( " %*.*s   StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s8  StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s16 StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s32 StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n\n", argn, argn, argv[0] );
		//		 --------------------------------------80 COLS----------------------------------
		printf( " Fills memory with the given data.\n" );
		printf( " 8|16|32     - Unit size (8-bit|16-bit|32-bit). If the number is missing, this\n" );
		printf( "               command will use whatever unit size you used in your last Fill\n" );
		printf( "               command (default:8-bit).\n" );
		printf( " StartAddr   - The starting address to write data to. If you use a period (.),\n" );
		printf( "               it will use the same start address you gave in your last Fill\n" );
		printf( "               command.\n" );
		printf( " EndAddr|Len - Determines where to stop filling. If this term starts with 'L',\n" );
		printf( "               then the number that follows represents Len, for instance, 'L8'\n" );
		printf( "               (length=8). Otherwise, the number represents EndAddr. If you\n" );
		printf( "               use a period (.), it will use the last EndAddr|Len you gave in\n" );
		printf( "               your last Fill command.\n" );
		printf( " Data#       - The values to fill memory with. If multiple values are given,\n" );
		printf( "               then the pattern will repeat through memory. Values can be\n" );
		printf( "               combinations of \'text\' or numbers (BINi, OCTo, DECt, HEXh).\n" );
		return TRUE;
	}

	// Check parameters.
	if ( argc < 4 )
	{
		printf( "ERROR: Not enough parameters.\n" );
		return FALSE;
	}
	if ( ConParseCommand(argv[0],ConFillUnitSize[ConContext],&ConFillUnitSize[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid command.\n", argv[0] );
		return FALSE;
	}
	if ( ConParseStartAddr(argv[1],ConFillStartAddr[ConContext],ConFillLen[ConContext],&ConFillStartAddr[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid start address.\n", argv[1] );
		return FALSE;
	}
	if ( ConParseLen(argv[2],ConFillStartAddr[ConContext],ConFillUnitSize[ConContext],ConFillLen[ConContext],&ConFillLen[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid end address or length.\n", argv[2] );
		return FALSE;
	}
	ErrorCode = ConParseData( &Data, &nData, 16, 3, argc, argv );
	if ( ErrorCode )
	{
		printf( "ERROR: '%s' isn't a valid data parameter.\n", argv[ErrorCode] );
		return FALSE;
	}

	// Do operation.
	for ( i=0; i<ConFillLen[ConContext]/ConFillUnitSize[ConContext]; i++ )
	{
		iData = i % nData;
		(*ConWriteMem)( ConBaseAddr+ConFillStartAddr[ConContext]+(i*ConFillUnitSize[ConContext]), Data[iData], ConFillUnitSize[ConContext] );
	}

	ConFillStartAddr[ConContext] += ConFillLen[ConContext];
	return TRUE;
}




Boolean ConReadCommand( int Halt, int argc, argvtype argv )
//
//	Reads memory at the address locations given.
//
//	PARAMETERS:
//
//		Halt      [in] - The number of lines to show at a time. If 0, then
//						 halt is disabled.
//		argc,argv [in] - The whole command-line (if you don't have an argv,
//						 call ConArgvAlloc() and ConArgvParse() first).
//
{
	UInt32	Data;

	if ( argv[1][0] == '?' )
	{
		int argn = ConParseCommandLen( argv[0] );
		printf( "\n" );
		printf( " %*.*s   [Addr1 Addr2 Addr3 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s8  [Addr1 Addr2 Addr3 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s16 [Addr1 Addr2 Addr3 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s32 [Addr1 Addr2 Addr3 ...]\n\n", argn, argn, argv[0] );
		//		 --------------------------------------80 COLS----------------------------------
		printf( " Reads memory at the Addr locations given.\n" );
		printf( " 8|16|32 - Unit size (8-bit|16-bit|32-bit). If the number is missing, this\n" );
		printf( "           command will use whatever unit size you used in your last Read\n" );
		printf( "           command (default:8-bit).\n" );
		printf( " Addr#   - The address to read data from. Multiple addresses can be given.\n" );
		return TRUE;
	}

	// Check parameters.
	if ( ConParseCommand(argv[0],ConReadUnitSize[ConContext],&ConReadUnitSize[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid command.\n", argv[0] );
		return FALSE;
	}

	// Do operation.
	if ( argc==1 || argv[1][0]=='.' )
	{
		Data = (*ConReadMem)( ConBaseAddr+ConReadStartAddr[ConContext], ConReadUnitSize[ConContext] );
		switch ( ConReadUnitSize[ConContext] )
		{
		  default:
		  case 1:  printf("%08lX:  %02lX  \'",ConReadStartAddr[ConContext],Data);  break;
		  case 2:  printf("%08lX:  %04lX  \'",ConReadStartAddr[ConContext],Data);  break;
		  case 4:  printf("%08lX:  %08lX  \'",ConReadStartAddr[ConContext],Data);  break;
		}
		ConPrintCharData( &Data, ConReadUnitSize[ConContext] );
		printf( "\'\n" );
	}
	else
	{
		int i;

		for ( i=1; i<argc; i++ )
		{
			UInt32 Addr;

			if ( ConParseNumber(argv[i],16,&Addr) )
			{
				printf( "ERROR: '%s' isn't a valid address.\n", argv[i] );
				return FALSE;
			}

			if ( i == 1 )
				ConReadStartAddr[ConContext] = Addr;

			Data = (*ConReadMem)( ConBaseAddr+Addr, ConReadUnitSize[ConContext] );
			switch ( ConReadUnitSize[ConContext] )
			{
			  default:
			  case 1:  printf("%08lX:  %02lX  \'",Addr,Data);  break;
			  case 2:  printf("%08lX:  %04lX  \'",Addr,Data);  break;
			  case 4:  printf("%08lX:  %08lX  \'",Addr,Data);  break;
			}
			ConPrintCharData( &Data, ConReadUnitSize[ConContext] );
			printf( "\'\n" );

			if (!ConNextLine( i, Halt ))
				break;
		}
	}
	return TRUE;
}




Boolean ConSearchCommand( int Halt, int argc, argvtype argv )
//
//	Search memory for the given data.
//
//	PARAMETERS:
//
//		Halt      [in] - The number of lines to show at a time. If 0, then
//						 halt is disabled.
//		argc,argv [in] - The whole command-line (if you don't have an argv,
//						 call ConArgvAlloc() and ConArgvParse() first).
//
{
	UInt32  i, iData, nDataMatches=0;
	int     nData, isDataMatch, ErrorCode;
	Boolean ExitFunction = FALSE;
	arglist	Data;

	if ( argv[1][0] == '?' )
	{
		int argn = ConParseCommandLen( argv[0] );
		printf( "\n" );
		printf( " %*.*s   StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s8  StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s16 StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n", argn, argn, argv[0] );
		printf( " %*.*s32 StartAddr EndAddr|Len Data1 [Data2 Data3 Data4 ...]\n\n", argn, argn, argv[0] );
		//		 --------------------------------------80 COLS----------------------------------
		printf( " Search memory for the given data.\n" );
		printf( " 8|16|32     - Unit size (8-bit|16-bit|32-bit). If the number is missing, this\n" );
		printf( "               command will use whatever unit size you used in your last\n" );
		printf( "               Search command (default:8-bit).\n" );
		printf( " StartAddr   - The starting address to start the search from. If you use a\n" );
		printf( "               period (.), it will use the same start address you gave in your\n" );
		printf( "               last Search command.\n" );
		printf( " EndAddr|Len - Determines where to stop searching. If this term starts with\n" );
		printf( "               'L', then the number that follows represents Len, for instance,\n" );
		printf( "               'L8' (length=8). Otherwise, the number represents EndAddr. If\n" );
		printf( "               you use a period (.), it will use the last EndAddr|Len you gave\n" );
		printf( "               in your last Search command.\n" );
		printf( " Data#       - The values to search memory for. If multiple values are\n" );
		printf( "               permitted. Values can be combinations of \'text\' or numbers\n" );
		printf( "               (BINi, OCTo, DECt, HEXh).\n" );
		return TRUE;
	}

	// Check parameters.
	if ( argc < 4 )
	{
		printf( "ERROR: Not enough parameters.\n" );
		return FALSE;
	}
	if ( ConParseCommand(argv[0],ConSearchUnitSize[ConContext],&ConSearchUnitSize[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid command.\n", argv[0] );
		return FALSE;
	}
	if ( ConParseStartAddr(argv[1],ConSearchStartAddr[ConContext],ConSearchLen[ConContext],&ConSearchStartAddr[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid start address.\n", argv[1] );
		return FALSE;
	}
	if ( ConParseLen(argv[2],ConSearchStartAddr[ConContext],ConSearchUnitSize[ConContext],ConSearchLen[ConContext],&ConSearchLen[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid end address or length.\n", argv[2] );
		return FALSE;
	}
	ErrorCode = ConParseData( &Data, &nData, 16, 3, argc, argv );
	if ( ErrorCode )
	{
		printf( "ERROR: '%s' isn't a valid data parameter.\n", argv[ErrorCode] );
		return FALSE;
	}

	// Do operation.
	for ( i=0; i<ConSearchLen[ConContext]/ConSearchUnitSize[ConContext] && !ExitFunction; i++ )
	{
		for ( iData=0,isDataMatch=1; isDataMatch && !ExitFunction; iData++ )
		{
			isDataMatch = 0;
			if ( iData == (UInt32)nData )
			{
				printf( "Found: %08lX\n", ConSearchStartAddr[ConContext]+(i*ConSearchUnitSize[ConContext]) );
				nDataMatches++;
				
				if (!ConNextLine( nDataMatches, Halt ))
					ExitFunction = TRUE;
			}
			if ( Data[iData] == (*ConReadMem)(ConBaseAddr+ConSearchStartAddr[ConContext]+((i+iData)*ConSearchUnitSize[ConContext]),ConSearchUnitSize[ConContext]) )
				isDataMatch = 1;
		}
	}
	printf( "%ld match%s found.\n", nDataMatches, (nDataMatches?"es":"") );

	ConSearchStartAddr[ConContext] += ConSearchLen[ConContext];
	return TRUE;
}




Boolean ConWriteCommand( int Halt, int argc, argvtype argv )
//
//	Writes the given Data sequence to memory starting at StartAddr location.
//
//	PARAMETERS:
//
//		Halt      [in] - The number of lines to show at a time. If 0, then
//						 halt is disabled.
//		argc,argv [in] - The whole command-line (if you don't have an argv,
//						 call ConArgvAlloc() and ConArgvParse() first).
//
{
	int		i, nData, ErrorCode;
	arglist	Data;

	if ( argv[1][0] == '?' )
	{
		int argn = ConParseCommandLen( argv[0] );
		printf( "\n" );
		printf( " %*.*s   [StartAddr [Data1 Data2 Data3 Data4 ...]]\n", argn, argn, argv[0] );
		printf( " %*.*s8  [StartAddr [Data1 Data2 Data3 Data4 ...]]\n", argn, argn, argv[0] );
		printf( " %*.*s16 [StartAddr [Data1 Data2 Data3 Data4 ...]]\n", argn, argn, argv[0] );
		printf( " %*.*s32 [StartAddr [Data1 Data2 Data3 Data4 ...]]\n\n", argn, argn, argv[0] );
		//		 --------------------------------------80 COLS----------------------------------
		printf( " Writes the given Data sequence to memory starting at StartAddr location.\n" );
		printf( " 8|16|32   - Unit size (8-bit|16-bit|32-bit). If the number is missing, this\n" );
		printf( "             command will use whatever unit size you used in your last Write\n" );
		printf( "             command (default:8-bit).\n" );
		printf( " StartAddr - The starting address to write data to. If you use a period (.),\n" );
		printf( "             it will use the same address you gave in your last Write command.\n" );
		printf( " Data#     - Values to write to memory. If no Data is given, then this\n" );
		printf( "             function will prompt the user in a MODIFY mode. This mode will\n" );
		printf( "             prompt the user showing the address and it's current Data, and\n" );
		printf( "             ask for new Data. While in this mode, the user can type in the\n" );
		printf( "             following:\n" );
		printf( "             --Hex digits        - new value\n" );
		printf( "             --ENTER,SPACE       - move to next memory location (if no Data\n" );
		printf( "                                   value is given, no change is made)\n" );
		printf( "             --MINUS             - move to previous memory location\n" );
		printf( "             --Q,PERIOD,anything - leaves MODIFY mode.\n" );
		return TRUE;
	}

	// Check parameters.
	if ( ConParseCommand(argv[0],ConWriteUnitSize[ConContext],&ConWriteUnitSize[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid command.\n", argv[0] );
		return FALSE;
	}
	if ( ConParseStartAddr(argv[1],ConWriteStartAddr[ConContext],ConWriteLen[ConContext],&ConWriteStartAddr[ConContext]) )
	{
		printf( "ERROR: '%s' isn't a valid start address.\n", argv[1] );
		return FALSE;
	}
	ErrorCode = ConParseData( &Data, &nData, 16, 2, argc, argv );
	if ( ErrorCode )
	{
		printf( "ERROR: '%s' isn't a valid data parameter.\n", argv[ErrorCode] );
		return FALSE;
	}

	// Do operation.
	if ( nData )
	{
		// Data was given, so write it.
		for ( i=0; i<nData; i++ )
		{
			(*ConWriteMem)( ConBaseAddr+ConWriteStartAddr[ConContext]+(i*ConWriteUnitSize[ConContext]), Data[i], ConWriteUnitSize[ConContext] );
			switch ( ConWriteUnitSize[ConContext] )
			{
			  default:
			  case 1:  printf("%08lX:  %02lX  \'",ConWriteStartAddr[ConContext]+(i*ConWriteUnitSize[ConContext]),Data[i]);  break;
			  case 2:  printf("%08lX:  %04lX  \'",ConWriteStartAddr[ConContext]+(i*ConWriteUnitSize[ConContext]),Data[i]);  break;
			  case 4:  printf("%08lX:  %08lX  \'",ConWriteStartAddr[ConContext]+(i*ConWriteUnitSize[ConContext]),Data[i]);  break;
			}
			ConPrintCharData( &(Data[i]), ConWriteUnitSize[ConContext] );
			printf( "\'\n" );

			if (!ConNextLine( i+1, Halt ))
				break;
		}
		ConWriteLen[ConContext] += (nData * ConWriteUnitSize[ConContext]);
	}
	else
	{
		// No data was given, so go into MODIFY mode.
		int  ci, progress, exit;
		char Str[64];

		i = 0;
		exit = 0;
		while ( !exit )

⌨️ 快捷键说明

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