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

📄 main.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
字号:
/*
 * Module: MAIN.C
 * Modified by: X.C.Zheng WeiHua
 * Modified on: Date:  03-8-11 14:02
 * Copyright(c) WeiHua Tech Ltd.
 */
#include "ECRSYS.h"
#include "ftype.h"
#include "disp.h"
#include "data.h"
#include "ADS7846.h"
#include "tft.h"
#include "sysdata.h"
#include "font.h"
#include "Tft_disp.h"
#include "font.h"

/*=============================================================================*
*	Main resource usage listing:
*	a)	Timmer
		-- TA0 === System timer with 1ms interval
*		-- TA1 === RTC timmer with 0.5Seconds interval
*		-- TA2 === Printer Heater timer with various interval accorind
*		-- TA3 === Keyboard scanning with 3 Seconds interval
*		-- TA4 === Printer Step motor feed timer with various interval
   ##########################################################################
*		-- TB2 === Touch Panel delay timmer with 3mSeconds interval
*	b)	UART
*		-- UART0,1,2 == Normal UART
*		-- UART3     == RS-485 mode
*		-- UART4     == Printer data/clock genertates
*
*=============================================================================*/

void	buzzer_test(byte	times)
{
	DEBUG_BUZZER(		// 硬件调试
	byte	ii;
	word	i;
	// Debug:
	disint();
	BUZZER_DIR = 1;
	for(ii = 0; ii < times; ii ++)
	{
		BUZZER = 1;
		i = 0;do{i++;}while(i);
		BUZZER = 0;
		i = 0;do{i++;}while(i);
	}
	i = 0;do{i++;}while(i);
	i = 0;do{i++;}while(i);
	i = 0;do{i++;}while(i);
	i = 0;do{i++;}while(i);
	i = 0;do{i++;}while(i);
	enint();
	)
}

/*==========================================================================================*
*  System_Init(void)
*  Initialize the MCU system, including the CPU port, and the timmer mode and interrupt 
*  Preset etc.
*  Note, only used once when power on.
*  03-4-7 9:55 
*==========================================================================================*/
void  System_Init(void)
{
   InitialPwrDwn();
   InitialRtcTimer();			/* Initialize the real time clock timer */
   enint();
//	asm("jsr.a 2680h");				// wait /pfo signal
	Init_ADC();						/* Initialize the AD covert control register */
	InitialKey();              /* Initialize keyboard port and keyboard timer. */ Init_TFT();					/*Initialize the TFT display*/
	Init_TFT();					/*Initialize the TFT display*/
//	Init_Prn();						/* Initialize the printer using parameter */
//   Sw_Init();
   InitialSysTimer();			/* Initialize the system timer */
   InitSerial_PwrOn();
   Init_Drawer();
	InitialWatchDog();         /* Initialize the watch dog. */
	Fls_Inital();
	#if	SW_VER == SW_NE2
//	Fm_Init();
	#endif
//	InitIccardPort();
	Init_Disp();
	Init_Ts();
   Data_Initial();
   Prn_SyncMotor();
}

/*
	Check the control lock change.
*/
BOOL check_mode_chg(void)
{
	byte curmd;

	delay_cnt = 0;
	while (delay_cnt < 300) { 	// 300ms
		curmd = GetMainMode();
		if (curmd != CurrMode)
			return TRUE;
	}

	return FALSE;
}


#ifdef	STACK_CHK
extern byte *stack_top;
/*
	堆栈Initialize
*/
void Stk_Init(void)
{
	static word i;
	memset(stack_top-0x1000, 0, 0x1000-100);
}

/*
	Stack check
*/
void Stk_Chk(void)
{
	byte *ptr = stack_top-0x1000;
	word j;

	for (j = 0; j < 0x1000; j++)
	{
		Insert_Byte(ptr[j], 0);
		GetKey();
		#if 0
		if (ptr[j] != 0)
			break;
		#endif
	}
	Clr_Dsp_Data();
	RightDisp(0x1000 - j, 0);
	GetKey();
}
#endif // STACK_CHK

void main(void)
{
	byte	ii;
	word	i;
    
    
   System_Init();
   bellcnt = 90;
    
    LCD_Test();
        
	if (0){
		void	TFT_Test(byte step);
        for(ii = 4; ii<6; ii++)
        {
		TFT_Test(ii);
        for(i =0; i <0xfff; i++);
        }
	}


	#ifdef	POWER_SUPPLY_TEST
	Dbg_Power();						// 电源负载能力调试.
	#endif

	#ifdef	HIGH_LOW_TEMPERATURE_TEST
	Qa_HighLowTemperatureTest();
	#endif

//	Sys_ChkBatteryLow();


//	DEBUG_SET(
//		Delay(3000);		// 等待足够的时间让LCD刷新显示
//	)
//	ChkVersion();
//    protest();
	if(Chk_Init() == OK)				/* Check for the initial operation */
	{
      protest();
	}
   if (CMOS_Legl_Chk() != OK)  	/* If the check false, indicate the SRAM's data is wrong */
   {
//   	if (Isp_CmosChk() == OK)	// ISP, auto all clear
//   	{
//			Clr_All_Dsp_Data(FALSE);
   		protest();
//   	}
//   	else
//   	{
//			DEBUG_TMP(
//				errorType(ERR_SRAM_WRONG);
//				while(1);
//				protest();		// 暂时自动做全情
//			)
//		}
   }
//	DEBUG_TMP(Lcd_DownLoad_Logo(LCD_LOGO_STORE_SDRAM, LCD_LOGO_SDRAM_ADDR);)
{
	void	Test_UartPort(char port_idx);
//	Test_UartPort(PORT3);
}
{
    void Lcd_Down_Logo_Pos(void);
    Lcd_Down_Logo_Pos();
}

//	{
//		void isp_chk(void);
//		isp_chk();
//	}

    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;
    }
   #ifdef	PC_COMM
   #ifdef	ELEC_JRNL
   EJ_Tax_Process();					/* 还原Tax税率的设置 */
   #endif
   #endif

/*>>>>>>>>>>>>>>--------------------Used for debug the HW ---------------------
{
	void	Flsh_Test(void);
	Flsh_Test();
}

{
	void	Test_Chine_Display(void);
	Test_Chine_Display();
}

	text("啊阿埃挨哎唉", FONT_HZ_16x16, 0x23, NULL, 0x0e0, 0, 200);
	text("啊阿埃挨哎唉", FONT_HZ_16x16, 0x22, NULL, 0x0e0, 400, 200);
	text("啊12阿ab埃AB挨-=哎()唉{}", FONT_HZ_16x16, 0x11, NULL, 0x0e0, 00, 250);
	text("我是中国人!", FONT_HZ_16x16, 0x11, NULL, 0x0e0, 400, 250);
	
	GetKey();
	GetKey();
	GetKey();
	GetKey();
	
*<<<<<<<<<<<<<<<--------------------------------------------------------------*/

//	Lcd_Init_Color();
   while (TRUE)
   {
		Comm_SetStatus(STATUS_IDLE);

        Clr_Period();					/* Clear the decimal point display */
        Disp_Spec_Period();			/* Dispaly the special period */
        Clr_All_Dsp_Data(FALSE);
        Trng_Flag = 0;
		Lcd_Opn_Text_Refresh();

        CurrMode = GetMainMode();
		if (check_mode_chg() == TRUE)		/* 检查是否快速切换了控制锁 */
			continue;
		Envir_Mode_Clear();					/*清除工作用的环境变量,*/			
        
        switch (CurrMode)
        {
            case  REGISTER:         /* Register mode */
            case  TRAINING:         /* Training  mode */
			    VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1, CLR);
                salemain();
                break;

            case  XREPORT:          /* X report */
            case  ZREPORT:          /* Z report */
				disp_report_flag = 1;
				VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1, CLR);
				Vfd_Off();
                xzrepmain();
				Vfd_On();
				disp_report_flag = 0;
                break;

            case  PROGRAM:          /* Program  mode */
				VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1, CLR);
                Vfd_Off();
                progmain();
                Vfd_On();
                break;

            default:                /* X-OFF mode */
				VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1, CLR);
				Vfd_Off();
                lock();
				Vfd_On();
                break;
      }  /* end switch */
   }/* end while */
}

/*-------------------------------------------------------------------------------
*  Lock the machine, 
*  Disable keyboard input,
*  Loop here until the control lock mode changed, then return to main() function.
*  03-8-13 10:31  
*-------------------------------------------------------------------------------*/
extern	volatile byte SpluKeyIn;
void lock(void)
{
typedef struct {
  U16 ID;           /* Version 1.00 => 100*/
  U16 Version;
  U16 XSize;
  U16 YSize;
  U16 BytesPerLine;
  U16 BitsPerPixel;
  U16 NumColors;
  U16 HasTrans;
} GUI_BITMAP_STREAM;
extern  const byte Pic_Dta_1[];
 void TFT_Lcd_Disp_Bitmap(GUI_BITMAP_STREAM *src, int x0, int y0);
    
	Clr_Period();
	Clr_All_Dsp_Data(FALSE);
	if(sysflag->soft_lock_flag) {
		Lcm_Disp_Str(Disp_Mode_Lock, LCM_LINE_2, ALIGN_MID, FALSE);
	}
   g_LCDBLCnt = 0;
	LCD_Back (OFF);					/* Clear the LCD backlight */

    TFT_Lcd_Disp_Bitmap((GUI_BITMAP_STREAM *)Pic_Dta_1, 0, 0);
    TFT_Lcd_Disp_Bitmap((GUI_BITMAP_STREAM *)Pic_Dta_1, 0, 300);
    while(1)
    {
        if (GetMainMode() != CurrMode)
        {
            Clr_Key_Buff();
            return;
        }
    }

    
	while(1)
     {
		void	TFT_Test(byte step);
        byte ii;
        word jj, i;
        
	    TFT_Test(4);
	    TFT_Test(6);
        
        for(i =0; i <0xfff; i++)
        for(jj = 0; jj <0xfff; jj++)
        {
            if(GetMainMode() != CurrMode)
                return;
        }
	}
   /* the key board lock has do in the KeyScan, so in this not need to lock the keyboard */
	Lcd_Screen_Protest_Logo();

	#if 0
	while(TRUE)
	{
		if(GetIn() == NG)
			continue;
		GetMainMode();
		if(MainMode != X_OFF)
			break;

      #ifdef PC_COMM
		if (InCmd == KD_PCLINK)
		{
			Comm_SetStatus(STATUS_COMM);
			Communication();
			Comm_SetStatus(STATUS_IDLE);

			Clr_Period();
			Clr_All_Dsp_Data(FALSE);
			if(sysflag->soft_lock_flag) {
				Lcm_Disp_Str(Disp_Mode_Lock, LCM_LINE_2, ALIGN_MID, FALSE);
			}
		   g_LCDBLCnt = 0;
			LCD_Back (OFF);					/* Clear the LCD backlight */
		   /* the key board lock has do in the KeyScan, so in this not need to lock the keyboard */
		}
		#endif
	}
	#endif
}










const	char	*Chinese_Sample_Disp[] = 
{
	{"TE-01P 9 Inch 主要工作列表                                                 "},
	{"大的几个问题                                                               "},
	{"1.    触摸屏定位的问题                                                     "},
	{"2.    TFT显示器有时候显示不准确的问题                                      "},
	{"3.    CS1不能访问的问题                                                    "},
	{"啊阿埃挨哎唉哀癌蔼矮艾碍爱隘氨安俺按暗岸胺案肮啊阿埃挨哎唉哀癌蔼矮艾碍爱隘 "},
	{"薄雹保堡饱宝抱暴豹鲍爆杯碑悲北辈背贝钡倍狈备惫薄雹保堡饱宝抱暴豹鲍爆杯碑悲 "},
	{"病并玻菠播拨钵博勃搏铂箔伯帛脖膊渤泊驳捕卜哺补病并玻菠播拨钵博勃搏铂箔伯帛 "},
	{"场尝常长偿肠厂畅唱倡超抄钞朝潮巢吵炒车扯撤掣彻场尝常长偿肠厂畅唱倡超抄钞朝 "},
	{"啊阿埃挨哎唉哀癌蔼矮艾碍爱隘氨安俺按暗岸胺案肮啊阿埃挨哎唉哀癌蔼矮艾碍爱隘 "},
	{"问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问问 "},
	{"制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制制 "},
	{"特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特殊特 "},
	{"工作工作工作工作工作工作工作工作工作工作工作工作工作工作工作工作工作工作工 "},
	{"工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工工 "},
	{"作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作作 "},
	{"软件功能的问题                                                             "},
	{"1.    年龄控制;                                                            "},
	{"  1.1 需要编程实现此年龄的输入                                             "},
	{"  1.2 销售的时候,需要一个功能来检测(部门销售--PLU销售也归属到所连接的部门) "},
	{"2.    VAT/TAX/GST/PST/TAX TABLE                                            "},
	{"  2.1 编程实现此功能                                                       "},
	{"  2.2 销售的时候的计算                                                     "},
	{"3.    FCE的几个特殊要求                                                    "},
	{"4.    EJ                                                                   "},
	{"  4.1 采用新算法功能来实现                                                 "},
	{"  4.2 需要多一些FLASH存储空间                                              "},
	{"5.    Header/Tailler Message                                               "},
	{"  5.1 几个特殊的功能要求见客户回复邮件                                     "},
	{"6.    Scroll 功能                                                          "},
	{"7.    描述符输入的时候,软件应该支持                                        "},
	{"  7.1 单宽字体(正常字体) -- 9*17                                           "},
	{"  7.2 双宽字体 -- 18*17                                                    "},
	{"  7.3 不支持双高字体                                                       "},
	{"8.    PC通讯的功能                                                         "},
	{"  8.1 PC界面上能够实现收款机中所有参数的编程输入                           "},
	{"  8.2 PC能够收发所有的编程参数从/到收款机                                  "},
	{"  8.3 PC能够实现数据的备份                                                 "},
	{"9.    多语言版本                                                           "},
	{"                                                                           "},
	{"                                                                           "},
	{"                                                                           "},
	{"                                                                           "},
	{"                                                                           "}
};

void	Test_Chine_Display(void)
{
	int	i,j;
	
	while(1)
	{
		for (i = 0, j = 0; i < 30; i ++)
		{
//			text(Chinese_Sample_Disp[i], FONT_HZ_16x16, 0x11, NULL, 0x0e0, 0, j);
			j += 20;
		}
		GetKey();
		GetKey();
	}
}

⌨️ 快捷键说明

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