📄 qa.c
字号:
#include "ecrsys.h"
#include "data.h"
#include "ftype.h"
#include "sysdata.h"
#include "disp.h"
#include "keydef.h"
#include <string.h>
/*
check Version & type.
// if sram error, not check it.
Print it and error sram when version is not same.
*/
void ChkVersion(void)
{
word chkSum;
if ((VERSION_RAM != Version) || (memcmp(VERSION_TYPE, Ver_Prn, VERSION_TYPE_LEN) != 0))
VERSION_RAM = Version;
memcpy(VERSION_TYPE, Ver_Prn, VERSION_TYPE_LEN);
CMOS_Illegal();
}
/************************************************************************/
CHR CMOS_Legl_Chk(void)
{
CHR i;
for (i=0; i<40; i++)
{
if (cmosValid[i] != i)
return(NG);
if (cmosValid2[i] != ~i)
return (NG);
}
return(OK);
}
/************************************************************************/
void CMOS_Legl_Set(void)
{
CHR i;
for (i=0; i<40; i++) {
cmosValid[i] = i;
cmosValid2[i] = ~i;
}
}
/************************************************************************/
void CMOS_Illegal(void)
{
memset(cmosValid, 0, 40);
memset(cmosValid2, 0, 40);
}
void Lcd_Qc_Ok(void)
{
disp_Char_Str("PASS------",0);
bellcnt = 30;
}
void Lcd_Qc_Err(void)
{
Insert_Char('E', 7);
Insert_Char('R', 8);
Insert_Char('R', 9);
bellcnt = 0xfe;
}
WORD Get_CS(void)
{
CHR *p = (CHR*)ROM_FE_TOP;
long sum = 0;
DWORD i;
#if ROM_FE_TOP == 0xf80000
#if MODEL_VER == WD3_HK
for ( i = 0; i < 1024*1024; i ++ )
sum += *p ++;
#else
for ( i = 0; i < 512*1024; i ++ )
sum += *p ++;
sum *= 2;
#endif
#elif ROM_FE_TOP == 0xfC0000
for ( i = 0; i < 256*1024; i ++ )
sum += *p ++;
#else
#endif
return (sum);
}
void Version_Check(void)
{
WORD sum;
byte i;
byte len;
char lcd_buf[3][MAX_LCD_TEXT+1];
const char check_sum[] = {"Check Sum"};
const char issue_date[] = {"Issue date"};
Rst_Lcd_Text();
Lcd_Send_Text_Buff_Str(BUF_ID_TL_TITLE, 2, "Version information" ,ALIGN_MID);
Lcd_Disp_Text_Buff(BUF_ID_TL_TITLE);
Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT,1, "Version checking ..." ,ALIGN_MID);
Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
for(i = 0; i < 3; i++)
{
memset(lcd_buf[i], 0x20, MAX_LCD_TEXT);
lcd_buf[i][MAX_LCD_TEXT] = '\0';
}
sum = Get_CS();
Rst_Lcd_Text();
memcpy(lcd_buf[0]+2, Current_Version, strlen(Current_Version));
LongtoAsc(&lcd_buf[0][MAX_LCD_TEXT-4], Version, 4);
//display the version
Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, lcd_buf[0], ALIGN_LEFT);
Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
memcpy(lcd_buf[1]+2, check_sum,strlen(check_sum));
LHextoAsc(&lcd_buf[1][MAX_LCD_TEXT-4], sum, 4);
//display the Check sum
Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, lcd_buf[1], ALIGN_LEFT);
Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
//display the issue time
memcpy(lcd_buf[2]+2, issue_date, strlen(issue_date));
len = strlen(Ver_Date);
memcpy(&lcd_buf[2][MAX_LCD_TEXT- len], Ver_Date, len);
Lcd_Send_Text_Buff_Str(BUF_ID_LCD_TEXT, 1, lcd_buf[2], ALIGN_LEFT);
Lcd_Disp_Text_Buff(BUF_ID_LCD_TEXT);
while(1)
{
if(Key_Poll_Chk() == TRUE)
break;
}
}
void Version_Cs_Chk(byte flag)
{
WORD sum;
Lcm_Disp_Str(Current_Version ,LCM_LINE_2 ,ALIGN_MID, FALSE);
disp_Char_Str("----------",0);
sum = Get_CS();
//Clr_Dsp_Data();
Lcm_Disp_Clr(LCM_LINE_1 ,FALSE);
Insert_Byte(sum,8);
Insert_Byte(sum>>8,6);
Insert_Num(Version/1000%10, 0);
Insert_Num(Version/100%10, 1);
Insert_Num(Version/10%10, 2);
Insert_Num(Version/1%10, 3);
Insert_Char('-',4);
if (flag == 1)
{
while(GetKey() != KD_CASH)
{
GetMainMode();
if(MainMode != CurrMode)
break;
}
}
else
{
// print out.
memcpy(&prn_Buf[1], "SW VER:", 7);
prn_Buf[9] = (Version / 1000) % 10 + '0';
prn_Buf[10] = (Version / 100) % 10 + '0';
prn_Buf[11] = (Version / 10) % 10 + '0';
prn_Buf[12] = Version % 10 + '0';
memcpy(&prn_Buf[15], "SW CS:", 6);
prn_Buf[21] = sum / 0x1000 + '0';
if (prn_Buf[21] > '9')
prn_Buf[21] += 7;
prn_Buf[22] = sum / 0x100 % 0x10 + '0';
if (prn_Buf[22] > '9')
prn_Buf[22] += 7;
prn_Buf[23] = sum / 0x10 % 0x10 + '0';
if (prn_Buf[23] > '9')
prn_Buf[23] += 7;
prn_Buf[24] = sum % 0x10 + '0';
if (prn_Buf[24] > '9')
prn_Buf[24] += 7;
prn_Str();
prn_Stamp();
}
}
/***********************************************************************
* flag -- 0 means 128K, 1 means 512K, 2 means 1024K.
*
***********************************************************************/
#define RAM_BASE_ADDR 0x100000
void Sram_Test(byte flag)
{
byte *ptr;
dword i, maxAddr;
byte tmpChar;
dword j;
// if (Flag_FM_Mode == TRUE)
// {
// bellcnt = 30;
// bellcnt = 30;
// return;
// }
if (flag == 0)
{
maxAddr = 0x20000;
}
else if (flag == 1)
{
maxAddr = 0x80000;
}
else
{
maxAddr = 0x100000;
}
disp_Char_Str("----------", 0);
disint();
ClsVfd();
ta0s = 0;
ta1s = 0;
ta2s = 0;
ta3s = 0;
ta4s = 0;
tb0s = 0;
tb1s = 0;
tb2s = 0;
tb3s = 0;
tb4s = 0;
CloseBuzzer();
ptr = (byte *)RAM_BASE_ADDR;
for (i = RAM_BASE_ADDR; i < (RAM_BASE_ADDR + maxAddr); i++)
{
*ptr++ = (char)(i & 0xff) + (char)((i >> 8) & 0xff) + (char)((i >> 16) & 0xff);
wdts = 0xff;
}
ptr = (byte *)RAM_BASE_ADDR;
for (i = RAM_BASE_ADDR; i < (RAM_BASE_ADDR + maxAddr); i++)
{
if (*ptr++ != ((char)(i & 0xff) + (char)((i >> 8) & 0xff) + (char)((i >> 16) & 0xff)))
{
break;
}
wdts = 0xff;
}
if (i < (RAM_BASE_ADDR + maxAddr))
{
Clr_All_Dsp_Data(FALSE);
Insert_Num(1, 0);
Insert_Num(0, 1);
Lcd_Qc_Err();
OpenBuzzer();
while (1)
{
for (i=0; i<0x3f; i++)
for (j=0; j<0xfff; j++)
wdts = 0xff;
}
}
else
{
Clr_All_Dsp_Data(FALSE);
Insert_Num(1, 0);
Insert_Num(0, 1);
Lcd_Qc_Ok();
OpenBuzzer();
for (i=0; i<0x7; i++)
for (j=0; j<0xfff; j++)
wdts = 0xff;
}
CloseBuzzer();
// Auto all clear operation
memset(cmosValid, 0, 40);
memset(cmosValid2, 0, 40);
// auto reset.
prc1 = 1;
pm03 = 1;
prc1 = 0;
while (1);
}
#ifdef SCANNER /* Support the scanner function */
extern volatile byte SpluKeyIn;
#endif /* End SCANNER */
byte Uart_Test(byte port, byte flag2)
{
const byte sendData[10] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x55, 0xaa};
byte recData[10];
byte port_sel = DEV_TYPE_NONE;
if (port == PORT0)
{
port_sel = port_sel1;
port_sel1 = DEV_TYPE_PC;
}
else if (port == PORT1)
{
port_sel = port_sel2;
port_sel2 = DEV_TYPE_PC;
}
Wr_Str_Uart(port, sendData, 10);
if (Uart_ReadStr(port, recData, 10) == 0)
{
if (memcmp(sendData, recData, 10) == 0)
{
if (flag2 == 1)
Lcd_Qc_Ok();
if (port == PORT0)
memcpy(&prn_Buf[1],"***Serial1 Test OK***",MAX_PRN_LEN);
else if (port == PORT1)
memcpy(&prn_Buf[1],"***Serial2 Test OK***",MAX_PRN_LEN);
else if (port == PORT3)
memcpy(&prn_Buf[1],"***Serial3 Test OK***",MAX_PRN_LEN);
print();
prn_Stamp();
if (port == PORT0)
port_sel1 = port_sel;
else if (port == PORT1)
port_sel2 = port_sel;
if (flag2 == 1)
GetKey();
return OK;
}
}
if (port == PORT0)
port_sel1 = port_sel;
else if (port == PORT1)
port_sel2 = port_sel;
if (flag2 == 1)
{
Lcd_Qc_Err();
GetKey();
}
return NG;
}
void Prn_Test(byte flag)
{
byte i;
byte tmpChar;
byte cntr=' ';
byte feedCnt = 0;
while (1)
{
tmpChar = 0x20;
for (i = 1; i < MAX_PRN_LEN+1; i++)
prn_Buf[i] = cntr + i;
print();
if ((feedCnt++ > 20) && (flag == 0))
{
break;
}
cntr ++;
if ( cntr >= 0x80 )
cntr = 0x20;
if (Key_Poll_Chk() == TRUE)
{
if (GetKey() == KD_CASH)
break;
}
}
prn_Stamp();
}
void Prn_Disc_Test(void)
{
wait_prn_Stop();
ta0s = 0;
ta4s = 0;
Clr_All_Dsp_Data(FALSE);
while(1)
{
wdts = 0xff;
if ( Key_Poll_Chk() && GetKey() == KD_CASH ) break;
if ( ad1 > 0xf0 )
Insert_Num(1, 9);
else
Insert_Num(0, 9);
}
ta0s = 1;
ta4s = 1;
Clr_All_Dsp_Data(FALSE);
Insert_Byte(0,8);
}
void Prn_PaperOut_Test(void)
{
#define RECEIPT_PAPER p10_3
#define JOURNAL_PAPER p10_2
Clr_All_Dsp_Data(FALSE);
while(1)
{
if ( Key_Poll_Chk() && GetKey() == KD_CASH ) break;
if ( RECEIPT_PAPER == 0 )
Insert_Num(0, 8);
else
Insert_Num(1, 8);
if ( JOURNAL_PAPER == 0 )
Insert_Num(0, 9);
else
Insert_Num(1, 9);
}
Clr_All_Dsp_Data(FALSE);
Insert_Byte(0,8);
}
void LCD_Back(CHR flag);
void Lcd_Test(void)
{
byte i, j=0,k = 0;
LCD_Back(ON);
Clr_Period();
disp_Num_Str("8888888888", 0);
Delay(500);
Clr_All_Dsp_Data(FALSE);
for ( i = 0; i < 10; i ++ )
{
for ( j = 0; j < MAX_LCD_NUM; j ++ )
Insert_Num(i,j);
Clr_Period();
Insert_Period(i);
if ((i % 2) != 0)
{
g_LCDBLCnt = 5000;
LCD_Back(ON); // OFF backlight
}
else
{
g_LCDBLCnt = 5;
LCD_Back(OFF); // OFF backlight
}
Delay(500);
if ( Key_Poll_Chk() )
{
if (GetKey() == KD_CASH )
break;
}
}
g_LCDBLCnt = 5;
LCD_Back(OFF); // OFF backlight
bellcnt = 30;
}
char Key_Seq_Cvt(char key_code)
{
const char keycode[38] = {
#if KB == KB_59N24
// 7 * 9 keyboard.
0x0F,0x0A,0x0B, 0x36,0x37,
0x09,0x0E,0x0C, 0x34,0x35,
0x05,0x15,0x1D, 0x25,0x2D, 0x3D,0x45,
0x04,0x14,0x1C, 0x24,0x2C, 0x3C,0x44,
0x06,0x16,0x1E, 0x26,0x2E, 0x3E,0x46,
0x03,0x13,0x1B, 0x23,0x2B, 0x3B,0x43,
0x02,0x12,0x1A, 0x22,0x2A, 0x3A,0x42,
0x01,0x11,0x19, 0x21,0x29, 0x39,0x41,
0x07,0x17,0x1F, 0x27,0x2F, 0x3f,0x47, // CASH & SUBTTL occupy two positions
// 3 * 8 keyboard.
0x4D,0x55,0x49, 0x4A,0x4B,0x4C,
0x4E,0x56,0x51, 0x52,0x53,0x5C,
0x4F,0x57,0x59, 0x5A,0x5B,0x54,
0x50,0x58,0x60, 0x5F,0x5D,0x5E
#elif KB == KB_38
// 5 * 8 keyboard.
1, 2, 3, 4, 5, 7, 9, 10, 11, 13, 6, 8, 17, 18, 19, 12,
14, 16, 25, 26, 27, 20, 22, 15, 37, 35, 36, 28, 21, 23,
38, 29, 30, 24, 39, 40, 31, 32
#endif
};
char i;
for ( i = 0; i < 38; i ++ )
{
if ( key_code == keycode[i] )
break;
}
return(i+1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -