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

📄 necdecode.s

📁 MCU控制程序
💻 S
📖 第 1 页 / 共 3 页
字号:
	.dbend
	.dbfunc e Nec_Decode _Nec_Decode fV
	.even
_Nec_Decode::
	.dbline -1
	.dbline 513
; }
; void Nec_Decode()
; {
	.dbline 516
; 	 
; //  if(((NecData[1]==0xbf)||(NecData[1]==0xfc))&&(NecData[0]==0x00)) //用户码正确 for hisense
;   if((NecData[1]==0x05)&&(NecData[0]==0x86)) //用户码正确 for bestbuy
	lds R24,_NecData+1
	cpi R24,5
	brne L129
	lds R24,_NecData
	cpi R24,134
	brne L129
	.dbline 517
;   {
	.dbline 522
; //    UDR=0x66;
; //	while(!(UCSRA&(1<<UDRE)));
; //	UDR=NecData[2];
; 	
; 	Nec_consumer_map();
	xcall _Nec_consumer_map
	.dbline 525
; // 	ResultNec=NecData[2];
; //	UDR=0x10;
; 	irda_num++;  
	lds R24,_irda_num
	subi R24,255    ; addi 1
	sts _irda_num,R24
	.dbline 526
; 	irda_b=1;
	ldi R24,1
	sts _irda_b,R24
	.dbline 527
; 	if(System_State==standby||System_State==working)
	lds R2,_System_State
	tst R2
	breq L134
	lds R24,_System_State
	cpi R24,3
	brne L130
L134:
	.dbline 528
; 	{
	.dbline 529
;     	Nec_data_deal_fun();
	xcall _Nec_data_deal_fun
	.dbline 530
; 	}		
	.dbline 531
;   }
	xjmp L130
L129:
	.dbline 533
;   else
;   {
	.dbline 535
; 
;     if((NecData[1]==0xfc)&&(NecData[0]==0x00)) //用户码正确 for bestbuy
	lds R24,_NecData+1
	cpi R24,252
	brne L135
	lds R2,_NecData
	tst R2
	brne L135
	.dbline 536
;     {
	.dbline 538
; //	  UDR=0x10;
; 	  Nec_fac_map();		
	xcall _Nec_fac_map
	.dbline 541
; // 	  ResultNec=NecData[2];
; //    UDR=0x10;
; 	  irda_num++;  
	lds R24,_irda_num
	subi R24,255    ; addi 1
	sts _irda_num,R24
	.dbline 542
; 	  irda_b=1;
	ldi R24,1
	sts _irda_b,R24
	.dbline 543
; 	  if(System_State==standby||System_State==working)
	lds R2,_System_State
	tst R2
	breq L140
	lds R24,_System_State
	cpi R24,3
	brne L138
L140:
	.dbline 544
; 	  {
	.dbline 545
; 	     Nec_data_deal_fun();
	xcall _Nec_data_deal_fun
	.dbline 546
;       }		 
L138:
	.dbline 547
; 	}  	  
L135:
	.dbline 548
;   }
L130:
	.dbline 549
;   HasR_Head_Reset_Nec_receive();
	xcall _HasR_Head_Reset_Nec_receive
	.dbline -2
L128:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e RepeatReceive _RepeatReceive fV
	.even
_RepeatReceive::
	.dbline -1
	.dbline 552
; }
; void RepeatReceive()
; {	
	.dbline 553
; 	if(RepeatCountFlag==0)
	lds R2,_RepeatCountFlag
	tst R2
	breq X16
	xjmp L142
X16:
	.dbline 554
; 	{
	.dbline 555
; 		if(BRepeatStar==0)           
	lds R2,_BRepeatStar
	tst R2
	brne L144
	.dbline 556
; 		{
	.dbline 557
;     	 	if((RNecRepeatCodeNum>=TimeNecRepeatMins)&&(RNecRepeatCodeNum<=TimeNecRepeatMaxs))                        //识别是否在重复码的最大发送时间之内
	lds R24,_RNecRepeatCodeNum
	lds R25,_RNecRepeatCodeNum+1
	cpi R24,116
	ldi R30,1
	cpc R25,R30
	brlo L146
	ldi R24,450
	ldi R25,1
	lds R2,_RNecRepeatCodeNum
	lds R3,_RNecRepeatCodeNum+1
	cp R24,R2
	cpc R25,R3
	brlo L146
	.dbline 558
; 	    	{
	.dbline 560
; //				UDR=0x65;
; 				BRepeatStar=1;                               
	ldi R24,1
	sts _BRepeatStar,R24
	.dbline 561
; 				return;
	xjmp L141
L146:
	.dbline 564
; 			}
; 			else
; 			{
	.dbline 565
; 		   	    BHasReceiveNec=0;                         
	clr R2
	sts _BHasReceiveNec,R2
	.dbline 566
; 		   		RNecRepeatCodeNum=0;
	clr R3
	sts _RNecRepeatCodeNum+1,R3
	sts _RNecRepeatCodeNum,R2
	.dbline 567
;     	   		Head_Reset_Nec_receive();
	xcall _Head_Reset_Nec_receive
	.dbline 568
; 		   		return;
	xjmp L141
L144:
	.dbline 572
; 			}
; 		}
; 		else
; 		{
	.dbline 573
; 			if((RNecRepeatCodeNum>=NecRepeatBitMin)&&(RNecRepeatCodeNum<=NecRepeatBitMax))
	lds R24,_RNecRepeatCodeNum
	lds R25,_RNecRepeatCodeNum+1
	cpi R24,103
	ldi R30,0
	cpc R25,R30
	brlo L148
	ldi R24,115
	ldi R25,0
	lds R2,_RNecRepeatCodeNum
	lds R3,_RNecRepeatCodeNum+1
	cp R24,R2
	cpc R25,R3
	brlo L148
	.dbline 574
; 		    {
	.dbline 576
; //			   UDR=0x66;																		  
; 			   RepeatCountFlag=1;                 
	ldi R24,1
	sts _RepeatCountFlag,R24
	.dbline 577
; 		       BRepeatStar=0;
	clr R2
	sts _BRepeatStar,R2
	.dbline 578
; 		       Deal_Repeat();
	xcall _Deal_Repeat
	.dbline 580
; //		       Head_Reset_Nec_receive();
; 		       return;
	xjmp L141
L148:
	.dbline 583
; 		    }
; 		    else
; 		    {
	.dbline 584
; 		      BHasReceiveNec=0;
	clr R2
	sts _BHasReceiveNec,R2
	.dbline 585
; 		      BRepeatStar=0;
	sts _BRepeatStar,R2
	.dbline 586
; 		      Head_Reset_Nec_receive();
	xcall _Head_Reset_Nec_receive
	.dbline 587
; 			  return;
	xjmp L141
L142:
	.dbline 591
; 		    }
; 		}		
; 	}
; 	if(RepeatCountFlag==1)
	lds R24,_RepeatCountFlag
	cpi R24,1
	breq X17
	xjmp L150
X17:
	.dbline 592
; 	{
	.dbline 593
; 		if(BRepeatStar==0)
	lds R2,_BRepeatStar
	tst R2
	brne L152
	.dbline 594
; 		{
	.dbline 595
; 			if((RNecRepeatCodeNum>=TimeNecRepeatMin)&&(RNecRepeatCodeNum<=TimeNecRepeatMax))
	lds R24,_RNecRepeatCodeNum
	lds R25,_RNecRepeatCodeNum+1
	cpi R24,112
	ldi R30,3
	cpc R25,R30
	brlo L154
	ldi R24,1180
	ldi R25,4
	lds R2,_RNecRepeatCodeNum
	lds R3,_RNecRepeatCodeNum+1
	cp R24,R2
	cpc R25,R3
	brlo L154
	.dbline 596
; 			{
	.dbline 598
; //				UDR=0x67;
; 				BRepeatStar=1;
	ldi R24,1
	sts _BRepeatStar,R24
	.dbline 599
; 				return;
	xjmp L141
L154:
	.dbline 602
; 			}
; 			else
; 			{
	.dbline 604
; //		   	    UDR=0x91;
; 				BHasReceiveNec=0;
	clr R2
	sts _BHasReceiveNec,R2
	.dbline 605
; 				NecRepeatCodeNum=0;
	clr R3
	sts _NecRepeatCodeNum+1,R3
	sts _NecRepeatCodeNum,R2
	.dbline 606
; 		   		RNecRepeatCodeNum=0;
	sts _RNecRepeatCodeNum+1,R3
	sts _RNecRepeatCodeNum,R2
	.dbline 607
; 				RepeatCountFlag=0;
	sts _RepeatCountFlag,R2
	.dbline 608
;     	   		Head_Reset_Nec_receive();
	xcall _Head_Reset_Nec_receive
	.dbline 609
; 		   		return;
	xjmp L141
L152:
	.dbline 613
; 			}
;         }
; 		else
; 		{
	.dbline 614
; 		    if((RNecRepeatCodeNum>=NecRepeatBitMin)&&(RNecRepeatCodeNum<=NecRepeatBitMax))
	lds R24,_RNecRepeatCodeNum
	lds R25,_RNecRepeatCodeNum+1
	cpi R24,103
	ldi R30,0
	cpc R25,R30
	brlo L156
	ldi R24,115
	ldi R25,0
	lds R2,_RNecRepeatCodeNum
	lds R3,_RNecRepeatCodeNum+1
	cp R24,R2
	cpc R25,R3
	brlo L156
	.dbline 615
; 		    {
	.dbline 617
; //		       UDR=0x68;
; 			   BRepeatStar=0;
	clr R2
	sts _BRepeatStar,R2
	.dbline 618
; 		       Deal_Repeat();
	xcall _Deal_Repeat
	.dbline 620
; //		       Head_Reset_Nec_receive();
; 		       return;
	xjmp L141
L156:
	.dbline 623
	.dbline 624
	clr R2
	sts _RepeatCountFlag,R2
	.dbline 625
	sts _BHasReceiveNec,R2
	.dbline 626
	clr R3
	sts _NecRepeatCodeNum+1,R3
	sts _NecRepeatCodeNum,R2
	.dbline 627
	sts _RNecRepeatCodeNum+1,R3
	sts _RNecRepeatCodeNum,R2
	.dbline 628
	sts _RepeatCountFlag,R2
	.dbline 629
	sts _BRepeatStar,R2
	.dbline 630
	xcall _Head_Reset_Nec_receive
	.dbline 631
L150:
	.dbline -2
L141:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Nec_Receive _Nec_Receive fV
	.even
_Nec_Receive::
	.dbline -1
	.dbline 637
; 		    }
; 		    else
; 		    {
; 			   RepeatCountFlag=0;		 	
; 		       BHasReceiveNec=0;
; 			   NecRepeatCodeNum=0;
;        		   RNecRepeatCodeNum=0;
; 			   RepeatCountFlag=0;
; 		       BRepeatStar=0;
; 		       Head_Reset_Nec_receive();
; 			   return;
; 		    }
; 	   }
; 	}
; }
; void Nec_Receive()
; {
	.dbline 638
;  i=NecDecodeNum/8;
	lds R2,_NecDecodeNum
	lds R3,_NecDecodeNum+1
	lsr R3
	ror R2
	lsr R3
	ror R2
	lsr R3
	ror R2
	sts _i+1,R3
	sts _i,R2
	.dbline 639
;  if(BNecStartBit==0)
	lds R2,_BNecStartBit
	tst R2
	brne L159
	.dbline 640
;  {
	.dbline 641
; 	if((RTimeNecFallEdge>=NecStartBitMin)&&(RTimeNecFallEdge<=NecStartBitMax))  //识别起始位
	lds R24,_RTimeNecFallEdge
	cpi R24,118
	brlo L161
	ldi R24,147
	lds R2,_RTimeNecFallEdge
	cp R24,R2
	brlo L161
	.dbline 642
; 	{
	.dbline 643
; 		BNecStartBit=1;
	ldi R24,1
	sts _BNecStartBit,R24
	.dbline 644
; 		return;
	xjmp L158
L161:
	.dbline 647
;     }
; 	else
; 	{
	.dbline 648
; 		Head_Reset_Nec_receive();
	xcall _Head_Reset_Nec_receive
	.dbline 649
; 	    return;
	xjmp L158
L159:
	.dbline 653
; 	}
;  }	
;  else
;  {
	.dbline 655
; 
;    if((RTimeNecFallEdge>=NecBit0Min)&&(RTimeNecFallEdge<=NecBit0Max)) 
	lds R24,_RTimeNecFallEdge
	cpi R24,10
	brlo L163
	ldi R24,13
	lds R2,_RTimeNecFallEdge
	cp R24,R2
	brlo L163
	.dbline 656
;    {
	.dbline 657
; 		NecData[i]>>=1;
	ldi R24,<_NecData
	ldi R25,>_NecData
	lds R2,_i
	lds R3,_i+1
	add R2,R24
	adc R3,R25
	movw R30,R2
	ldd R4,z+0
	lsr R4
	std z+0,R4
	.dbline 658
; 	    NecDecodeNum++;
	lds R24,_NecDecodeNum
	lds R25,_NecDecodeNum+1
	adiw R24,1
	sts _NecDecodeNum+1,R25
	sts _NecDecodeNum,R24
	.dbline 659
;    }
	xjmp L164
L163:
	.dbline 661
;    else
;    {
	.dbline 662
;    	   if((RTimeNecFallEdge>=NecBit1Min)&&(RTimeNecFallEdge<=NecBit1Max))
	lds R24,_RTimeNecFallEdge
	cpi R24,20
	brlo L165
	ldi R24,25
	lds R2,_RTimeNecFallEdge
	cp R24,R2
	brlo L165
	.dbline 663
;    	   {
	.dbline 664
; 			NecData[i]>>=1;
	ldi R24,<_NecData
	ldi R25,>_NecData
	lds R2,_i
	lds R3,_i+1
	add R2,R24
	adc R3,R25
	movw R30,R2
	ldd R4,z+0
	lsr R4
	std z+0,R4
	.dbline 665
; 			NecData[i]+=0x80;
	lds R2,_i
	lds R3,_i+1
	add R2,R24
	adc R3,R25
	movw R30,R2
	ldd R24,z+0
	subi R24,128    ; addi 128
	std z+0,R24
	.dbline 666
; 			NecDecodeNum++;
	lds R24,_NecDecodeNum
	lds R25,_NecDecodeNum+1
	adiw R24,1
	sts _NecDecodeNum+1,R25
	sts _NecDecodeNum,R24
	.dbline 667
;        }
	xjmp L166
L165:
	.dbline 669
;   		else 									//如果不是0或1,重新开始
; 		{
	.dbline 670
; 			Head_Reset_Nec_receive();
	xcall _Head_Reset_Nec_receive
	.dbline 671
; 			return;
	xjmp L158
L166:
	.dbline 673
; 		}
;    }
L164:
	.dbline 674
	.dbline 676
	lds R24,_NecDecodeNum
	lds R25,_NecDecodeNum+1
	cpi R24,32
	ldi R30,0
	cpc R25,R30
	brne L167
	.dbline 677
	.dbline 678
	ldi R24,1
	sts _BHasReceiveNec,R24
	.dbline 679
	clr R2
	sts _RepeatControl,R2
	.dbline 680
	sts _BNecStartBit,R2
	.dbline 681
	xcall _Nec_Decode
	.dbline 682
L167:
	.dbline -2
L158:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e IR_var_init _IR_var_init fV
	.even
_IR_var_init::
	.dbline -1
	.dbline 687
;  }  
; 
;  if(NecDecodeNum==32)                  //一个NEC码接收完成
;  {									   
; 	BHasReceiveNec=1;
; 	RepeatControl=0;
; 	BNecStartBit=0;
; 	Nec_Decode();
;  	return;  			 
;  }
; }
; //call this routine to initialize all peripherals
; void IR_var_init()
; {
	.dbline 688
;  BTheFirstFallEdge=0;
	clr R2
	sts _BTheFirstFallEdge,R2
	.dbline 689
;  BReceiveStart=0;
	sts _BReceiveStart,R2
	.dbline 690
;  BNecFallEdge=0;
	sts _BNecFallEdge,R2
	.dbline 691
;  TimeNecFallEdge=0;
	sts _TimeNecFallEdge,R2
	.dbline 692
;  RTimeNecFallEdge=0;
	sts _RTimeNecFallEdge,R2
	.dbline 693
;  BNecStartBit=0;
	sts _BNecStartBit,R2
	.dbline 694
;  NecData[0]=0;
	sts _NecData,R2
	.dbline 695
;  NecData[1]=0;
	sts _NecData+1,R2
	.dbline 696
;  NecData[2]=0;
	sts _NecData+2,R2
	.dbline 697
;  NecData[3]=0;
	sts _NecData+3,R2
	.dbline 698
;  NecDecodeNum=0;
	clr R3
	sts _NecDecodeNum+1,R3
	sts _NecDecodeNum,R2
	.dbline 699
;  BHasReceiveNec=0;
	sts _BHasReceiveNec,R2
	.dbline 700
;  BPowerButton=0;
	sts _BPowerButton,R2
	.dbline 701
;  NecRepeatCodeNum=0;
	sts _NecRepeatCodeNum+1,R3
	sts _NecRepeatCodeNum,R2
	.dbline 702
;  BNecRepeat=0;
	sts _BNecRepeat,R2
	.dbline 703
;  RepeatCountFlag=0;
	sts _RepeatCountFlag,R2
	.dbline 704
;  i=0;
	sts _i+1,R3
	sts _i,R2
	.dbline 705
;  RepeatControl=0;
	sts _RepeatControl,R2
	.dbline 706
;  Powerdown_signal=0;
	sts _Powerdown_signal,R2
	.dbline 707
;  Fac_mode=EEPROMread(0x90);
	ldi R16,144
	ldi R17,0
	xcall _EEPROMread
	sts _Fac_mode,R16
	.dbline 708
;  Fac_aging=0;
	clr R2
	sts _Fac_aging,R2
	.dbline -2
L169:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile G:\McuControl\necdecode.c
_NecTimeTest::
	.blkb 2
	.dbunion 0 2 NecTime
	.dbfield 0 NecRepeatNum i
	.dbfield 0 a A[2:2]c
	.dbend
	.dbsym e NecTimeTest _NecTimeTest S[NecTime]
_Fac_aging::
	.blkb 1
	.dbsym e Fac_aging _Fac_aging c
_Fac_mode::
	.blkb 1
	.dbsym e Fac_mode _Fac_mode c
_Powerdown_signal::
	.blkb 1
	.dbsym e Powerdown_signal _Powerdown_signal c
_RepeatControl::
	.blkb 1
	.dbsym e RepeatControl _RepeatControl c
_irda_data::
	.blkb 1
	.dbsym e irda_data _irda_data c
_i2c_public::
	.blkb 1
	.dbsym e i2c_public _i2c_public c
_irda_b::
	.blkb 1
	.dbsym e irda_b _irda_b c
_irda_num::
	.blkb 1
	.dbsym e irda_num _irda_num c
_tv_state::
	.blkb 1
	.dbsym e tv_state _tv_state c
_power_on_close_enable::
	.blkb 1
	.dbsym e power_on_close_enable _power_on_close_enable c
_power_key_open_enable::
	.blkb 1
	.dbsym e power_key_open_enable _power_key_open_enable c
_NecData_Map::
	.blkb 1
	.dbsym e NecData_Map _NecData_Map c
_BRepeatStar::
	.blkb 1
	.dbsym e BRepeatStar _BRepeatStar c
_RepeatCountFlag::
	.blkb 1
	.dbsym e RepeatCountFlag _RepeatCountFlag c
_ResultNec::
	.blkb 1
	.dbsym e ResultNec _ResultNec c
_BNecRepeat::
	.blkb 1
	.dbsym e BNecRepeat _BNecRepeat c
_RNecRepeatCodeNum::
	.blkb 2
	.dbsym e RNecRepeatCodeNum _RNecRepeatCodeNum i
_NecRepeatCodeNum::
	.blkb 2
	.dbsym e NecRepeatCodeNum _NecRepeatCodeNum i
_BPowerButton::
	.blkb 1
	.dbsym e BPowerButton _BPowerButton c
_BHasReceiveNec::
	.blkb 1
	.dbsym e BHasReceiveNec _BHasReceiveNec c
_i::
	.blkb 2
	.dbsym e i _i i
_NecDecodeNum::
	.blkb 2
	.dbsym e NecDecodeNum _NecDecodeNum i
_NecData::
	.blkb 4
	.dbsym e NecData _NecData A[4:4]c
_BNecStartBit::
	.blkb 1
	.dbsym e BNecStartBit _BNecStartBit c
_RTimeNecFallEdge::
	.blkb 1
	.dbsym e RTimeNecFallEdge _RTimeNecFallEdge c
_TimeNecFallEdge::
	.blkb 1
	.dbsym e TimeNecFallEdge _TimeNecFallEdge c
_BNecFallEdge::
	.blkb 1
	.dbsym e BNecFallEdge _BNecFallEdge c
_BReceiveStart::
	.blkb 1
	.dbsym e BReceiveStart _BReceiveStart c
_BTheFirstFallEdge::
	.blkb 1
	.dbsym e BTheFirstFallEdge _BTheFirstFallEdge c

⌨️ 快捷键说明

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