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

📄 debug.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 3 页
字号:
void Dbg_Power(void)
{
	byte i;

	for (i=0; i<3; i++)
	{
		bellcnt = 50;
		Wait(1000);
	}
	if (CMOS_Legl_Chk() != OK) { 	/* If the check false, indicate the SRAM's data is wrong */
		Clr_All_Dsp_Data(FALSE);
		protest();
	}
	
	while (1)
	{
		disp_Char_Str("PRN DBG---", 0);
		while (!Key_Poll_Chk());
		if (GetKey() == KD_SUBTTL)
		{
			break;
		}
		Dbg_PrintPower();
		bellcnt = 250;
	}
}



void debug(void)
{
	void  System_Init(void);
	// debug
	{
   	InitialPwrDwn();
   	InitialRtcTimer();			/* Initialize the real time clock timer */
	  InitialKey();              /* Initialize keyboard port and keyboard timer. */
   	InitialSysTimer();			/* Initialize the system timer */
   	InitialSerial();
   	enint();
   	Init_Lcd();                /* Initialize the LCD controller and clear the display */
   	#if	SW_VER == SW_NE2
		Fm_Init();
		#endif
//   	VfdClr();
  		bellcnt = 50;

	disp_Char_Str("---1234---", 0);

		//Rtc_Debug();

	Vfd_Debug();

   	Prn_Debug();

	   	while (1)
	   	{
	   		bellcnt = 2;
			Wait(1000);
		}
	}

   Power_Dwn_Chk();
   System_Init();
   bellcnt = 90;                 /* When the start is right, sound a voice. */

//	{
//		extern byte SpluKeyIn;
//		
//	   #ifdef SCANNER			/* Support the scanner function */
//		BarRecFlag = 1;		/* Shield the bar code receive */
//		SpluKeyIn = 1;
//	   #endif /* End SCANNER */
//	   
//	   Uart_WriteByte(PORT1, 0x1b);
//	   Uart_WriteByte(PORT3, 0x1b);
//
////		Prn_Debug();
//
//		Prn_Dot_Ring[phead][0] = 20;
//		Prn_Dot_Ring[phead][1] = 0;
//		phead++;
//
////		{
////			extern const word motorAccTime[9];
////			extern const word heatTime[];
////			byte i;
////			
////			for (i=0; i<9; i++)
////			{
////		   	Uart_WriteByte(PORT1, (byte)(motorAccTime[i]>>8));
////		   	Uart_WriteByte(PORT1, (byte)(motorAccTime[i]));
////		   }
////	   	Uart_WriteByte(PORT1, 0x55);
////	   	Uart_WriteByte(PORT1, 0x55);
////	   	Uart_WriteByte(PORT1, 0x55);
////			for (i=0; i<8; i++)
////			{
////		   	Uart_WriteByte(PORT1, (byte)(heatTime[i]>>8));
////		   	Uart_WriteByte(PORT1, (byte)(heatTime[i]));
////		   }
////		}
//
//		Vfd_Debug();
//		
//		while (1)
//		{
//			byte i, idx, cmd;
//
////			for (i=0; i<240; i++)
////			{
////				Prn_Dot_Ring[phead][0] = 2;
////				memset(&Prn_Dot_Ring[phead][7], 0xff, 32);
////				memset(&Prn_Dot_Ring[phead][7+32], 0, 8);
////				memset(&Prn_Dot_Ring[phead][7+32+8], 0xff, 32);
////				phead++;
////			}
////			continue;
//
//			
////			Prn_Dot_Ring[phead++][0] = 200;
////			Prn_Dot_Ring[phead++][0] = 200;
////			continue;
//			
////			for (i=0; i<100; i++)
////			{
////				Prn_Dot_Ring[i][0] = 2;
////				memset(&Prn_Dot_Ring[i][7], 0x55, 48);
////			}
////			prear = phead = 0;
////			phead = 100;
//
////			Prn_Dot_Ring[phead][0] = 50;
////			Prn_Dot_Ring[phead][1] = 0;
////			phead++;
//
////			prn_Line('*');
////			memcpy(prn_Buf+1, "1234567890ABCDEFGHIJKLMNOPQRSTUV", 32);
////			prn_Str();
////			memcpy(prn_Buf+1, "================================", 32);
////			prn_Str();
////			memcpy(prn_Buf+1, "================================", 32);
////			prn_Str();
////			memcpy(prn_Buf+1, "================================", 32);
////			prn_Str();
////			memcpy(prn_Buf+1, "Hello, China! Hi, World! Hi, ABC", 32);
////			prn_Str();
//
////			memcpy(prn_Buf+1, "Hello, CHINA!Hello, CHINA!abcdef", 32);
////			prn_Str();
////			prn_Line('*');
////			prn_Line('x');
//
////			for (i=0; i<50; i++)
////			{
////				Prn_Dot_Ring[phead][0] = 2;
////				memset(&Prn_Dot_Ring[phead][1], 0, 6);
////				memset(&Prn_Dot_Ring[phead][7], 1, 48+24);
////				phead++;
////			}
////
////			Wait(1000);
////			
////			for (i=0; i<50; i++)
////			{
////				Prn_Dot_Ring[phead][0] = 2;
////				memset(&Prn_Dot_Ring[phead][1], 0, 6);
////				memset(&Prn_Dot_Ring[phead][7], 4, 48+24);
////				phead++;
////			}
//
//			
//			while (Uart_ReadByte(PORT1, &cmd) != OK);
//			switch (cmd)
//			{
//			case 1:
//				Prn_Dot_Ring[phead][0] = 100;
//				Prn_Dot_Ring[phead][1] = 0;
//				phead++;
//				break;
//			case 2:
//				memcpy(prn_Buf+1, "===================== ==========", 32);
//				prn_Str();
//				break;
//			case 3:
//				memcpy(prn_Buf+1, " = = = = = = = = = =   = = = = =", 32);
//				prn_Str();
//				break;
//			case 4:
//				memcpy(prn_Buf+1, " == == == == == == == == == == =", 32);
//				prn_Str();
//				break;
//			case 5:
//				memcpy(prn_Buf+1, " =  =  =  =  =  =  =  =  =  =  =", 32);
//				prn_Str();
//				break;
//			case 6:
//				memcpy(prn_Buf+1, "1234567890ABCDEFGHIJK MNOPQRSTUV", 32);
//				prn_Str();
//				break;
//			case 7:
//				memcpy(prn_Buf+1, "1 3 5 7 9 A C E G I K M O Q S U ", 32);
//				prn_Str();
//				break;
//			case 8:
//				memcpy(prn_Buf+1, "1   5   9   C   G   K   O   S   ", 32);
//				prn_Str();
//				break;
//			case 9:											// 等待转换完毕后再启动打印,测试其噪音.
//				disint();
//				memcpy(prn_Buf+1, "===================== ==========", 32);
//				prn_Str();
//				memcpy(prn_Buf+1, " = = = = = = = = = =   = = = = =", 32);
//				prn_Str();
//				memcpy(prn_Buf+1, " == == == == == == == == == == =", 32);
//				prn_Str();
//				memcpy(prn_Buf+1, " =  =  =  =  =  =  =  =  =  =  =", 32);
//				prn_Str();
//				memcpy(prn_Buf+1, "1234567890ABCDEFGHIJK MNOPQRSTUV", 32);
//				prn_Str();
//				memcpy(prn_Buf+1, "1 3 5 7 9 A C E G I K M O Q S U ", 32);
//				prn_Str();
//				memcpy(prn_Buf+1, "1   5   9   C   G   K   O   S   ", 32);
//				prn_Str();
//				enint();
//				break;
//			case 10:
//				{
//					void Prn_StepDebug(byte flag);
//					extern byte totalStepLine;
//	
//					Prn_StepDebug(0);
//					while (totalStepLine);
//					Prn_StepDebug(1);
//				}
//				break;
//			default:
//				break;	
//			}
//
////			Wait(5000);
//		}
//	}


	Chk_Init();							/* Check for the initial operation */
   if (CMOS_Legl_Chk() != OK)  	/* If the check false, indicate the SRAM's data is wrong */
   {
		errorType(ERR_SRAM_WRONG);
		while (1);
   }

   Cont_Sale_Check();            /* Check the last powerdown's sale is complete or not. */
   if(Flag_Prgm_Head)            /* Check the last powerdown's programing is complete or not */
   {
   	prn_Power_Dwn_Info();
      prn_Line('-');
      prn_Stamp();               /* Print the stamp */
      Flag_Prgm_Head = 0;
   }

   while (TRUE)
   {
      Clr_Period();					/* Clear the decimal point display */
		Disp_Spec_Period();
      Clr_Dsp_Data();
      Trng_Flag = 0;

      CurrMode = GetMainMode();
      switch (CurrMode)
      {
         case  REGISTER:         /* Register mode */
         case  TRAINING:         /* Training  mode */
               salemain();
               break;

         case  XREPORT:          /* X report */
         case  ZREPORT:          /* Z report */
               xzrepmain();
               break;

         case  PROGRAM:          /* Program  mode */
               progmain();
               break;

         default:                /* X-OFF mode */
               lock();
               break;
      }  /* end switch */
   }/* end while */
}

/******************************************************************************
Description: 	打印操作手册的头,及警告信息.
******************************************************************************/
void Dbg_PrintManualHead(const byte *str)
{
	prn_Line('*');
	Prn_InsStr(str, MAX_PRN_LEN/2, NM_FONT_PRN, FLUSH_MID);
	Prn_Str(1);
	prn_Line('*');
	Prn_InsStr("ATTENTION: ", PRN_START_POS, NM_FONT_PRN, FLUSH_LEFT);
	Prn_Str(1);
	Prn_InsStr("IT MAY CAUSE DAMAGE!", MAX_PRN_LEN/2, NM_FONT_PRN, FLUSH_MID);
	Prn_Str(1);
	Prn_Str(1);
}

///////////////////////////////////////////////////////////////////////////////
// Descript:	打印出内部操作步骤,供现场操作参考,需同时打印出警告提示.
///////////////////////////////////////////////////////////////////////////////
void Dbg_PrintOperateManual(void)
{
	Dbg_PrintManualHead("Inter operate manual");

	Prn_InsStr("  999-CASH   QC flag", MAX_PRN_LEN/2, NM_FONT_PRN, FLUSH_MID);
	Prn_Str(1);
	Prn_InsStr("11111-CASH      LIST", MAX_PRN_LEN/2, NM_FONT_PRN, FLUSH_MID);
	Prn_Str(1);
	Prn_InsStr("10100-CASH    EMI...", MAX_PRN_LEN/2, NM_FONT_PRN, FLUSH_MID);
	Prn_Str(1);

	prn_Stamp();
}

	typedef struct {
		byte flag : 1;
		byte suceess : 1;
		byte reverse : 5;
		byte overFlow : 1;
		} DEBUG_STRUCT;
		
		DEBUG_STRUCT debug_Struct;
		byte xxyyzz;
#endif

/******************************************************************************
Description: 内部调试/测试命令,小心使用.
******************************************************************************/
void Dbg_Set(dword cmd)
{
	#if 0
	if (cmd == 11111)
	{
		Dbg_PrintOperateManual();
	}
	else if (10100 <= cmd && cmd < 101200)
	{
		Dbg_EmiSet(cmd);
	}
	else
	{
		byte *ptr = malloc(20);
		enum {
			MAX_NUM = 20,
		};
		byte str[MAX_NUM];
		
		assert(ptr != NULL);
		if (ptr != NULL)
		{
			byte i;
			for (i=0; i<20; i++)
			{
//				if (isupper(i))
					ptr[i] = 0;
			}
			free(ptr);
		}
		assert(false);
	}
	#endif
}

// New add by jwm: 
void debug_key(void)
{
	word key;

    key_matrx_init(0);
    key_matrx_init(1);
    key_matrx_init(2);
	while(TRUE)
	{
      while( Ktail != Khead)
      {
         key = KeyBuffer[Ktail];
         Ktail++;
         if(Ktail == KEY_BUFF_SIZE)  
         	Ktail=0;
         if(key)
         {
         	Insert_Byte(key, 0);
            key = key_logi_get(key_logic,key,MAX_KEY_CNT);           /* Return the logical key code. */
            Insert_Byte(key, 4);
            key = FF_Key_Get(key);
            Insert_Byte(key, 8);
         }
      }
	}
}

void debug_ser(byte port)
{
	byte i;
	byte j;

	for (j = 0; j < 64; j++) {
		i = 0;
		do {
			Uart_WriteByte(port, i);
			i++;
		} while (i);
	}
}

void debug_ser2(byte port)
{
	byte data;

	while (TRUE) {
		if (Uart_ReadByte(port, &data) == OK)
			Uart_WriteByte(port, data);
	}
}

void debug_port(void)
{
	byte i;

	for (i = 0; i < 5; i++) {
		Insert_Byte(ser_port[i].device, 0);
		Insert_Byte(ser_port[i].baud_idx, 2);
		Insert_Byte(ser_port[i].parity, 4);
		Insert_Byte(ser_port[i].data_len, 6);
		Insert_Byte(ser_port[i].stop_bit, 8);
		GetKey();
	}
}

///////////////////////////////////////////////////////////////////////////////
// Descript:	LCD调试.
// In Param:	void
// Out Param:	void
// Return:		void
///////////////////////////////////////////////////////////////////////////////
void Lcm_Debug(void)
{
	#if 0
	byte i;

	Init_Lcd();
	for (i=0; i<4; i++)
	{
		Lcd_DispDigit("Welcome WeiHua 123456789", 0, i, 24);
	}
	Wait(3000);
	#endif
}

⌨️ 快捷键说明

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