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

📄 msp430zwtqq.c

📁 tiMSP430F147体能监测设备源码
💻 C
📖 第 1 页 / 共 5 页
字号:
			         P5OUT&=~BIT0; 
		                 /*prep_led = 0;*/
			         P5OUT|=BIT2;
			         FLAG|=BIT3;                 //////////建立插卡测试标志位
			         FLAG2&=~BIT3;               //////////清除空闲标志
			         delay(20);                 //延时60ms
			         ycsjre64();
	                         goto next_test;
	                     }   
	                     
	                 }
	                 m=0;
	                 disp_lcd(0xd,0xd,0xd,0xd,0x0);
	                 while((P1IN&BIT2)!=0)
	                 {
	                    jcqy();
	                    TBCTL|=TBIE;
	                    P3OUT&=~BIT0;                         //关断外部电源 
	                    FLAG2|=BIT3;                      //
	                    //delay(200);                       //延时60ms
			    //if((P2IN&BIT1)==0)
			    //m++;
			    //else m=0;                         //如果按下确认键则m一直加一,否则m=0
			    P5OUT&=~BIT0;
			    P5OUT&=~BIT1;
	                    P5OUT&=~BIT2;
	                    P5OUT|=BIT3;
	                    if(exitjsq>100)
	                    {
	                       disp_lcd(0,0,0,0,0);
		               tljish = 0;
			       //timeoverf = 0;
			       FLAG&=~BIT5;
	                       //testend_led = 1;
			       P5OUT&=~BIT0;
			       P5OUT&=~BIT1;
			       P5OUT&=~BIT3; 
			       /*prep_led = 0;*/
			       P5OUT|=BIT2;
			       FLAG2&=~BIT3;                //////////清除空闲标志
			       delay(200);                  //延时60ms
			       ycsjre64();
			       FLAG&=~BIT3;                 //////////建立插卡测试标志位
	                       goto next_test;	
	                     }
	                   }
	                   goto mainloop; 
	                }
	  next_test:  
	              P3OUT|=BIT0;                          //打开外部电源
	              P3OUT|=BIT4;                          //
		      delay(200);
		      delay(200);
		      delay(200);
		      delay(200);
	              /*prep_led =1;*/
	              //P5OUT|=BIT1; 
	              /*incard_led =1;*/
                      P5OUT&=~BIT0;
          nexttest:   //EX0 = 0;
		      P2IE&=~BIT6; 
		      tljish = 0;
		      c = 0x0d;
		      disp_lcd(c,2,0,0,3);
	              m=0;
	              sound_s();
	              delay(200);
		      delay(200);
		      delay(200);
	              subf = 0xb0;
	              //IT0 = 1;
	              //EX0 = 1;
		      P2IE|=BIT6;
		      exitjsq=0;
		      TBCTL|=TBIE;
		      while(tljish <= 10)
		      {     
		             if(((P1IN&BIT2)!=0)&&((FLAG&BIT3)!=0))
		             {
				     uint i = 0;
				     //tljish = 0;
				     //EX0 = 0;
				     P2IE&=~BIT6;
				     num = 20;
				     subf = 0xb0;
				     goto testend;
			      }
			      if(exitjsq>700)
			      {
			      	 delay(200);
		                 delay(200);
			      	 sound_s();
			      	 delay(200);
		                 delay(200);
		                 delay(200);
		                 delay(200);
		                 delay(200);
		                 delay(200);
			      	 goto testend;
			      }
		              if (tljish <= 100)
			      {
				   b = 100 - tljish ;
				   c = 0x0d;
			       }
			       else
			       {
				    b = tljish - 100 ;
				    c = 0;
				}
				   	//prenum = tljish;
				   	//b = b*2 ;				
				   	//HEX_BCD(b);
				   	//disp_lcd(c,BCD[5],BCD[6],BCD[7],3);
		        }
		        TBCTL&=~TBIE;
		        /*prep_led = 1;*/
			 P5OUT|=BIT1; 	
			 /*test_led = 0;*/		//测试开始
			 P5OUT&=~BIT2;
			m=0;
			while (num != 0)
		        {  
		        	_EINT();
		               	IE2 &=~URXIE1;
		        	if(((P1IN&BIT2)!=0)&&((FLAG&BIT3)!=0))
				{
			             uint i = 0,num = 20;
				     //tljish = 0;
				     //EX0 = 0; 
				     P2IE&=~BIT6;	
				     goto testend;
 				
		                 }
			    if (prenum == tljish)
		            num--;
			    else
			    num = 20;
			    if (tljish <= 100)
			    {
				b = 100 - tljish;
				c = 0x0d;
		             }
		             else
			     {
				b = tljish - 100;
				c = 0;
			      }
			      prenum = tljish;
			      b = b *2;
			      HEX_BCD(b);
			      //if(zwtqqjsq>2)
			      //{
			       //   disp_lcd(c,BCD[5],BCD[6],BCD[7],3);
			       //   zwtqqjsq=0;
			       //}
			      disp_lcd(c,BCD[5],BCD[6],BCD[7],3);
			      delay(15);
			  }
			  IE2 |= URXIE1;
			  e = rand();		
			  HEX_BCD(e);
			  switch (BCD[7])
			  {
				case 1:
				case 2:
				case 3:
				case 5:
				case 7:
				if (c == 0)
				b = b+1;
				else
				b = b-1;
				break;	
			  }		
			  HEX_BCD(b);
			  disp_lcd(c,BCD[5],BCD[6],BCD[7],3);
			  //EX0 = 0;
			  P2IE&=~BIT6;
			  num = 20;
			  repeatestnum = tljish;
			  prenum = 0;
			  delay(255);
			  delay(255);
			  delay(255);
			  delay(255);
			  delay(255);
			  //tljish = 0;
			  if (testnum == 1)
		          { 
			      testnum = 2;
			      HEX_BCD(b);
			      IC_error = 0;
			      
			      ////////////////////////////////////////////////////////////
			      if(((P1IN&BIT2)==0)&&((FLAG&BIT3)!=0))
			      {
			                 ME2&=~URXE1;
			                 delay(50);
	                                 HEX_BCD(b);
	                                 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
				         lsbuf=(uint)(re1byte(0x00));
                                         lsbuf=(uint)(lsbuf*256+re1byte(0x01));
                                         if(lsbuf<2700) 
                                         {  
                                //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	                                 readicid();                     //读取卡号
		                         result[0]=0x00;
		                         result[1]=0x00;
		                         if (c == 0x0d)
				         a = BCD[5] + 0xf0;
				         else   
			                 a=BCD[5];
		                         result[2]=a;
		                         result[3]=(BCD[6]<<4)+BCD[7];
		                          //FLAG2|=BIT0;                    //置数据有标志,可进行发送
		                          ////disp_lcd(0x01,0x01,0x01,0x01,0);
		                          //for(i=0;i<30;i++)
		                          //delay(200);
                                          //FLAG2&=~BIT0;
                                          lsbuf=(uint)(re1byte(0x00));
                                          lsbuf=(uint)(lsbuf*256+re1byte(0x01));
                                          for(ii=0;ii<8;ii++)
                                          {
                                             temp=icidbuf[ii];
                                             wr1byte(0x40+12*lsbuf+ii,temp);
                                             delay(50);
                                          }
                                          for(ii=0;ii<4;ii++)
                                          {
                                              temp=result[ii];
                                              wr1byte(0x40+12*lsbuf+8+ii,temp);
                                              delay(50);
                                          }
                                          lsbuf++;
                                          at64count++;
                                          temp=(uchar)(lsbuf/256);
                                          wr1byte(0x00,temp);
                                          delay(50);
                                          temp=(uchar)(lsbuf%256);
                                          wr1byte(0x01,temp);
                                          delay(50);
                                          sound_s();
			                  delay(50);
			                 }
	                  ////////////////////////////////////////////////////////////
			                  a = (BCD[6]<<4)+BCD[7];
			                  IC_write(FYS_save1,a);
			                  delay(30);
			                  if (c == 0x0d)
			                  a = BCD[5] + 0x10;
			                  else 
			                  a = BCD[5];
			                  IC_write(FYS_save0,a);	
			                  delay(30);
			                  IC_write(FYS_flag,1);
			                  delay(50);
			      }
			      disp1 = 0;
			      disp2 = 0;
			      disp3 = 0;
			      disp4 = 2;
			      sound_s();
			      subf = 0xb0;
			      //EX0 = 0;
			      P2IE&=~BIT6;
			      num = 20;
			      resultnum = b;
			      resultf = c;
			      sound_s();
			      subf = 0xc0;
			      //IT0 = 1;
			      //EX0 = 1;
			      P2IE|=BIT6;
			      //IT0 = 1;
			      while (1)
			      {
				   if (tljish > 30)
				   {
				       if(((P1IN&BIT2)!=0)&&((FLAG&BIT3)!=0))
				       {
				               //EX0 = 0;
				               P2IE&=~BIT6;
				               subf = 0xb0;
				               num = 20;
				               tljish = 0;
				               goto testend;
				             
				         }  
				    }
				     else
				    {
				          sound_s();
				          subf = 0xb0;
				          //EX0 = 0;
				          P2IE&=~BIT6;
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  delay(200);
				 	  tljish = 0;
				  	  break;
				     } 
				 }
				 tljish = 0;
				 subf = 0xb0;
				 goto nexttest;
		            }
		            testnum = 1;
		            if((resultf==0x0d)&&(c==0x00))
		            {
		               resultnum = b;
		               c=0x00;
		               goto skipskip;
		            }
		            if (resultf < c)
			     {
			     	c = 0;
			     	
			     }
			    else
			       if (resultf == 0)
			       {
				   if (resultnum <= b)
				   resultnum = b; 
			        }
				else
				{
				   if (resultnum >=b)
				   resultnum = b;
				}
				/*if (resultnum <= 100)
				      {
				      b = 100 - resultnum;
				      c = 0x0b;
				      }
				 else
				      {
				      b = resultnum - 100;
				      c = 0;
				      } */ 
		    skipskip:
			     //if (ncardtf == 0)
			     if((FLAG5&BIT0)==0) 
			     {
				  repeatestf = 0xb0;
				  disp_lcd(0x0d,0x0a,0x0a,0x0d,0);
				  for(a=0;a<3;a++)
				  {
					delay(255);
					//TR1 = 0;
					delay(255);
					delay(255);
					//TR1 = 0;
					delay(255);
					delay(255);
					//TR1 = 0;
					delay(255);
					//TR1 =1;
				  }
				  HEX_BCD(resultnum);
				  sound_s();
				  disp_lcd(c,BCD[5],BCD[6],BCD[7],3);
				  subf = 0xc0;
				  //test_led = 1;
				  //P5OUT&=~BIT2;
				  //testend_led = 0;
				  //P5OUT|=BIT3;
				  tljish = repeatestnum;
				  if (tljish > 0 )
				  {
				    //IT0 = 1;
				    //EX0 = 1;
				    P2IE|=BIT6; 
				    //IT0 = 1;
				    subf = 0xc0;
				   }
				  while (tljish > 0)
				   {
				     waitjish--;
				     if (waitjish == 0)
				       {
				        //EX0 = 0;
				        P2IE&=~BIT6; 
				        waitjish = 25;
				        num = 20;
				        break;
				       }
				      if(((P1IN&BIT2)!=0)&&((FLAG&BIT3)!=0))
				       {
				           //EX0 = 0;
				           P2IE&=~BIT6;
				           num = 20;
				           //test_led = 1;
				           /*test_led = 1;*/
	                                   P5OUT&=~BIT2;
	                                   P5OUT&=~BIT1;
	                                   P5OUT&=~BIT2;
				           goto testend;
				          
				       }
				      delay(255);
				} 
				  //EX0 = 0;
				  P2IE&=~BIT6;  
				  subf = 0xb0;
				  delay(255);
				  delay(255);
				  delay(255);
				  delay(255);
				  delay(255);
				  delay(255);
				  if (tljish <= 0)
				      repeatestf = 0xc0;
				  goto testend;

⌨️ 快捷键说明

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