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

📄 impact.c

📁 lpc2368 source files
💻 C
📖 第 1 页 / 共 3 页
字号:
    ch = ch >> 1;

    ch = *(line_no + test_msg[e_char]);
    e_dot = ch << 2;
    ch = ch >> 1;

    ch = *(line_no + test_msg[h_char]);
    h_dot = ch << 2;
    ch = ch >> 1;
}

void cf_bits(void)
{
    unsigned char ch;

    ch = *(line_no+ test_msg[c_char]);
    c_dot = ch << 2;
    ch = ch >> 1;

    ch = *(line_no + test_msg[f_char]);
    f_dot = ch << 2;
    ch = ch >> 1;
}
			
void dot_1(void)
{ 

    if(prt_dw_flag == 1)
    {
        hi_pul();
        adg_dots();
        lo_pul();
        hi_pul();
        //DATAOUT_A =0x00;
        //prt_enable();
		STROBES_OFF;
    
        beh_dots();
        lo_pul();
        hi_pul();
        //DATAOUT_A =0x00;
        //prt_enable();
		STROBES_OFF;
    
        cf_dots();
        lo_pul();
        hi_pul();
        //DATAOUT_A =0x00;
        //prt_enable();
		STROBES_OFF;
    }

    hi_pul();
    adg_dots();
	lo_pul();
	hi_pul();
    //DATAOUT_A =0x00;
    //prt_enable();
	STROBES_OFF;

    beh_dots();
    lo_pul();
	hi_pul();
    //DATAOUT_A =0x00;
    //prt_enable();
	STROBES_OFF;

	cf_dots();
	lo_pul();
	hi_pul();
    //DATAOUT_A =0x00;
    //prt_enable();
	STROBES_OFF;

    a_dot = a_dot << 1;
    b_dot = b_dot << 1;
    c_dot = c_dot << 1;
    d_dot = d_dot << 1;
    e_dot = e_dot << 1;
    f_dot = f_dot << 1;
    g_dot = g_dot << 1;
    h_dot = h_dot << 1;
}


void  adg_dots(void)
{
    unsigned char temp;//,ch;

    temp = 0x00;			//ff;

//	ch = a_dot;
//    bit_1 = ch & 0x80;
//	if(bit_1 == 1)
	if(a_dot & 0x80)
	{
        temp = (temp |0x01);   //& 0xfe);
		//temp = (temp & 0xfe);
	}

//	ch = d_dot;
//    bit_4= ch & 0x80; 
//	if(bit_4 == 1)  
	if(d_dot & 0x80)
	{
        temp = (temp | 0x08);      //& 0xf7);
		//temp = (temp & 0xf7);
	}

//    ch = g_dot;
//    bit_7= ch & 0x80;
//	if(bit_7 == 1)
    if(g_dot & 0x80)
	{
        temp = (temp |	0x40);      //& 0xbf);
		//temp = (temp & 0xbf);
	}


    //DATAOUT_A = temp;
    //prt_enable();
	FIO1PIN3 = ~temp;
}	

										
void beh_dots(void)
{
    unsigned char temp;//,ch;

    temp =0x00;		//ff;

//	ch = b_dot;
//    bit_2= ch & 0x80; 
//	if(bit_2 == 1)  
	if(b_dot & 0x80)
	{
        temp = (temp | 0x02);	// & 0xfd);
		//temp = (temp  & 0xfd);
	}
	
//	ch = e_dot;
//    bit_5= ch & 0x80; 
//	if(bit_5 == 1)  
	if(e_dot & 0x80)
	{
       temp = (temp | 0x10);  //& 0xef);
	   //temp = (temp & 0xef);
	}

//    ch = h_dot;
//    bit_8= ch & 0x80; 
//	if(bit_8 == 1)  
    if(h_dot & 0x80)
	{
        temp = (temp | 0x80);   //&0x7F);
		//temp = (temp &0x7F);
	}

    //DATAOUT_A = temp;
    //prt_enable();
	FIO1PIN3 = ~temp;
}	

void cf_dots(void)
{
    unsigned char temp;//,ch;
    temp =0x00;			//ff;

//	ch = c_dot;
//    bit_3= ch & 0x80;
//	if(bit_3 == 1)   
	if(c_dot & 0x80)
	{
        temp = (temp | 0x04);  // & 0xfb);
		//temp = (temp  & 0xfb);
	}

//	ch = f_dot;
//    bit_6= ch & 0x80;
//	if(bit_6 == 1)   
	if(f_dot & 0x80)
	{
        temp = (temp | 0x20);  //& 0xdf);
		//temp = (temp & 0xdf);
	}

    //DATAOUT_A = temp;
    //prt_enable();
	FIO1PIN3 = ~temp;
}
				
void chk(void)
{
    unsigned char chk_cnt;
	
    //while(res_det  == 0);
    FIO0MASK = ~(1 << 26);
	while(!FIO0PIN3);
	FIO0MASK = 0; 

    for(chk_cnt=0;chk_cnt<6;chk_cnt++)
    {
        hi_pul();
        lo_pul();
    }
    //while(res_det  == 0);
    FIO0MASK = ~(1 << 26);
	while(FIO0PIN3);
	FIO0MASK = 0; 

	//while(time_det == 0);
    FIO0MASK = ~(1 << 25);
	while(!FIO0PIN3);
	FIO0MASK = 0; 

    //while(time_det == 1);
    FIO0MASK = ~(1 << 25);
	while(FIO0PIN3);
	FIO0MASK = 0; 
	//while(time_det == 0);
	FIO0MASK = ~(1 << 25);
	while(!FIO0PIN3);
	FIO0MASK = 0; 
	
}
	
void hi_pul(void)
{
    int hi_cnt;

	//while(time_det == 0);
    FIO0MASK = ~(1 << 25);
	while(!FIO0PIN3);
	FIO0MASK = 0; 
    
	for(hi_cnt=0;hi_cnt<100;hi_cnt++);

	//while(time_det == 0);
    FIO0MASK = ~(1 << 25);
	while(!FIO0PIN3);
	FIO0MASK = 0; 
}

void lo_pul(void)
{
    int lo_cnt;

	//while(time_det == 1);
    FIO0MASK = ~(1 << 25);
	while(FIO0PIN3);
	FIO0MASK = 0; 

    for(lo_cnt=0;lo_cnt<100;lo_cnt++); 
	       
	//while(time_det == 1);
    FIO0MASK = ~(1 << 25);
	while(FIO0PIN3);
	FIO0MASK = 0; 

}


void sm_prt(unsigned char prn_msgch)
{	
	if(prn_msgch == 0x0a)
	{
			while(smprn_i<24)
			{
                test_msg[smprn_i]=0x20;
				smprn_i++;
			}
            if(prt_dh_flag == 1)
            {
                st_prt_dh();
            }
            else
            {
                st_prt();
            }
			smprn_i=0;
	}
    else
	{
        test_msg[smprn_i] = prn_msgch;
		smprn_i++;

        if(smprn_i>=24)
        {
            if(prt_dh_flag == 1)
            {
                st_prt_dh();
            }
            else
            {
                st_prt();
            }
            smprn_i=0;
        }
	}
}	

void prt_msg(char * prt_msg_data,unsigned char max_char)
{
    unsigned char count,prt_msg_ch;

    for(count=0;count<max_char;count++)
    {
        prt_msg_ch= prt_msg_data[count];
        sm_prt(prt_msg_ch);
    }            
}

void prt_msgb(char * prt_msg_data)
{
    unsigned char count,prt_msg_ch;

    count=0;
    while(prt_msg_data[count] !='\0')
    {
            prt_msg_ch= prt_msg_data[count];
            sm_prt(prt_msg_ch);
            count++;
            if(count==24) break;
    }
    
    for(;count<24;count++)
    {
      prt_msg_ch=0x20; //space
      sm_prt(prt_msg_ch);
    }
}

 void prt_msgb1(int  prt_msg_data)
{
    unsigned int count,prt_msg_ch;
	   prt_msg_ch=0;
    count=0;
    while(prt_msg_data !=0)
    {
            prt_msg_ch= prt_msg_data;
            sm_prt(prt_msg_ch);
            count++;
            if(count==24) break;
    }
    
    for(;count<24;count++)
    {
     // prt_msg_ch=0x20; //space
      sm_prt(prt_msg_ch);
    }
}


void prt_bcd2(unsigned char prt_bcd2_data)
{
  unsigned char prt_bcd2_data1;
  prt_bcd2_data1=((prt_bcd2_data>>4)&0x0f)+0x30;

  sm_prt((int)prt_bcd2_data1);
  prt_bcd2_data1=(prt_bcd2_data&0x0f)+0x30;
  sm_prt((int)prt_bcd2_data1);
} 

void prt_date(void)
{	date[0] = 15;	//DD
	date[1] = 1;   	//MM
	date[2] = 2009;	//YY
 // prt_bcd2(date[0]);
  prt_msg("15",2);
  prt_msg("-",1);
 // prt_bcd2(date[1]);
 prt_msg("1",1);
  prt_msg("-",1);
  prt_msg("2009",4);
 // prt_msg("20",2);    
 // prt_bcd2(date[2]);
}
//
//

void prt_time(void)
{  	time[0] = 1;   	//HH
	time[1] = 24;	//MM
	time[2] = 30;	//SS
  //prt_bcd2(time[0]);
   prt_msg("02",2);
  prt_msg(":",1);
//  prt_bcd2(time[1]);
    prt_msg("05",2);
  prt_msg(":",1);
   prt_msg("1",1);
  //prt_bcd2(time[2]);
}
 unsigned int counter;
 void count(void)
{  counter=9;	 
counter++;

   prt_bcd2(counter);
}
/*****************  FOR BAR CODE PRINTING (START)  *****************/

void bar_msg(char * prt_msg_data,unsigned char max_char)
{
    unsigned char chsum,count,bt4,buffer[30];//,bt[2];
    unsigned int  brint;
 	unsigned long checksum;
    for (count=0;count<max_char;count++)
    {
        buffer[count] = prt_msg_data[count];
    }
    checksum = 104;
    countnum = 0;

    for(count=0;count<max_char;count++) //2
	{
        if ((buffer[count] >= '0') && (buffer[count] <= '9'))
        {
            bardata[countnum] = (buffer[count]-0x30) + 16;
        }
        else
        {
            bardata[countnum] = (buffer[count] / 2);
            brint = ((unsigned int)(buffer[count]) - 64);
            bt4 = (unsigned char)(brint / 2);
            if ((brint % 2) == 1)
                bt4 = bt4 + 1;
            bardata[countnum] = bardata[countnum] + bt4;
        }
        checksum = checksum + (bardata[countnum] * (countnum + 1));
        countnum++;
    }
   
    /*bardata[countnum] = 99;    //changing to 128C
    checksum = checksum + (bardata[countnum] * (countnum + 1));
    countnum++;
    for (count=4;count<max_char;count++) //4
    {
        if ((count+1)<max_char)
			bardata[countnum] = ((buffer[count]-0x30)*10) + (buffer[count+1]-0x30);
		else
			bardata[countnum] = buffer[count]-0x30;
        checksum = checksum + (bardata[countnum] * (countnum + 1));
        countnum++;
        count++;
    }
    */
    chsum = (unsigned char)(checksum % 103);
    bardata[countnum] = chsum;
    countnum++;
    barflag = 1;
    startbit = 1;
    stopbit = 0;
}


void prt_bar(char * prt_msg_data,unsigned char max_char)
{
    unsigned char dotcnt,bit_i,count,ch,bt4=0,bt0=0;

    if ((max_char > 18) && (barflag == 1)) max_char = 18;

    for (bit_i=0;bit_i<144;bit_i++)
        barbuff[bit_i] = 0;

    prn_pow(ON);
    dotcnt = 0;
    for(count=0;count<max_char;count++)
	{
        ch = *(line_10 + prt_msg_data[count]);
        ch = ch << 2;
        for (bit_i=0;bit_i<6;bit_i++)
        {
            if ((ch & 0x80) == 0x80)
                barbuff[dotcnt] = 1;
            else
                barbuff[dotcnt] = 0;
            ch = ch << 1;
            dotcnt++;
        }
    }

    if (barflag == 1)
    {
        for (count=dotcnt;count<114;count++)
        {
             barbuff[count] = 0;
        }
        if (startbit == 1)
        {
            bt0 = 0x06;
            cntnum = 0;
        }
        else
        {
            if (stopbit == 1)
            {
                bt0 = 0x18;
            }
            else

⌨️ 快捷键说明

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