   1                     ; C Compiler for STM8 (COSMIC Software)
   2                     ; Parser V4.12.9 - 19 Apr 2023
   3                     ; Generator (Limited) V4.5.6 - 18 Jul 2023
  16                     	switch	.data
  17  0000               _bMiddleWaitTimerID:
  18  0000 ff            	dc.b	255
  19  0001               _bMidWait:
  20  0001 00            	dc.b	0
  65                     ; 10 void ConvertDown1(void *p)
  65                     ; 11 {
  67                     .text:	section	.text,new
  68  0000               _ConvertDown1:
  72                     ; 12 		UNLockAllMotor();
  74  0000 cd0000        	call	_UNLockAllMotor
  76                     ; 13 		EnableBrakPower(TRUE); 
  78  0003 a601          	ld	a,#1
  79  0005 cd0000        	call	_EnableBrakPower
  81                     ; 14 		StartDC2ACConvert(); 
  83  0008 cd0000        	call	_StartDC2ACConvert
  85                     ; 15 		ActiveTask(TASK_BREAK,DC_DN_PR);//
  87  000b ae0032        	ldw	x,#50
  88  000e 89            	pushw	x
  89  000f ae0000        	ldw	x,#0
  90  0012 89            	pushw	x
  91  0013 a612          	ld	a,#18
  92  0015 cd0000        	call	_ActiveTask
  94  0018 5b04          	addw	sp,#4
  95                     ; 16 }
  98  001a 81            	ret
 136                     ; 18 void ConvertDown(char bEnable)
 136                     ; 19 {
 137                     .text:	section	.text,new
 138  0000               _ConvertDown:
 142                     ; 20 	if(bEnable)
 144  0000 4d            	tnz	a
 145  0001 271c          	jreq	L34
 146                     ; 22 		UNLockAllMotor();
 148  0003 cd0000        	call	_UNLockAllMotor
 150                     ; 23 		EnableBrakPower(TRUE); 
 152  0006 a601          	ld	a,#1
 153  0008 cd0000        	call	_EnableBrakPower
 155                     ; 24 		StartDC2ACConvert(); 
 157  000b cd0000        	call	_StartDC2ACConvert
 159                     ; 25 		ActiveTask(TASK_BREAK,DC_DN_PR);//
 161  000e ae0032        	ldw	x,#50
 162  0011 89            	pushw	x
 163  0012 ae0000        	ldw	x,#0
 164  0015 89            	pushw	x
 165  0016 a612          	ld	a,#18
 166  0018 cd0000        	call	_ActiveTask
 168  001b 5b04          	addw	sp,#4
 170  001d 200d          	jra	L54
 171  001f               L34:
 172                     ; 29 		EnableBrakPower(FALSE); 
 174  001f 4f            	clr	a
 175  0020 cd0000        	call	_EnableBrakPower
 177                     ; 30 		SuspendTask(TASK_BREAK);//
 179  0023 a612          	ld	a,#18
 180  0025 cd0000        	call	_SuspendTask
 182                     ; 31 		StopDC2ACConvert(0);
 184  0028 5f            	clrw	x
 185  0029 cd0000        	call	_StopDC2ACConvert
 187  002c               L54:
 188                     ; 33 }
 191  002c 81            	ret
 217                     ; 35 void DCManualCtrl(void)
 217                     ; 36 {  
 218                     .text:	section	.text,new
 219  0000               _DCManualCtrl:
 223                     ; 37 	switch(gcKey)
 225  0000 c60000        	ld	a,_gcKey
 227                     ; 46 			break;
 228  0003 4a            	dec	a
 229  0004 270b          	jreq	L15
 230  0006 a003          	sub	a,#3
 231  0008 260b          	jrne	L35
 232                     ; 39 		case KEY_DOWN:  
 232                     ; 40 			ConvertDown(1);
 234  000a a601          	ld	a,#1
 235  000c cd0000        	call	_ConvertDown
 237                     ; 41 			break;
 239  000f 2005          	jra	L76
 240  0011               L15:
 241                     ; 42 		case KEY_STOP:
 241                     ; 43 			ConvertDown(0);
 243  0011 4f            	clr	a
 244  0012 cd0000        	call	_ConvertDown
 246  0015               L35:
 247                     ; 45 			nop();
 250  0015 9d            nop
 252                     ; 46 			break;
 255  0016               L76:
 256                     ; 48 }
 259  0016 81            	ret
 291                     ; 50 void ACManualCtrl(void)
 291                     ; 51 {
 292                     .text:	section	.text,new
 293  0000               _ACManualCtrl:
 297                     ; 56 			switch(gcKey&KEY_HANDCTRL)	 //(KEY_UP|KEY_DOWN|KEY_STOP)
 299  0000 c60000        	ld	a,_gcKey
 300  0003 a40f          	and	a,#15
 302                     ; 88 					break;	    
 303  0005 4a            	dec	a
 304  0006 2765          	jreq	L57
 305  0008 4a            	dec	a
 306  0009 2706          	jreq	L17
 307  000b a002          	sub	a,#2
 308  000d 272f          	jreq	L37
 309  000f 205f          	jra	L111
 310  0011               L17:
 311                     ; 58 				case KEY_UP:
 311                     ; 59 					if(IED.cMoving==1)
 313  0011 c60002        	ld	a,_IED+2
 314  0014 a101          	cp	a,#1
 315  0016 2620          	jrne	L311
 316                     ; 61 						if(IED.Direction!=MOTOR_UP)
 318  0018 725d0011      	tnz	_IED+17
 319  001c 2752          	jreq	L111
 320                     ; 63 							StopMotor();
 322  001e cd0000        	call	_StopMotor
 324                     ; 64 							StartTimer(TIMER_MODE_ONCEROUTINE,100L,MotorUp,0);
 326  0021 5f            	clrw	x
 327  0022 89            	pushw	x
 328  0023 ae0000        	ldw	x,#_MotorUp
 329  0026 89            	pushw	x
 330  0027 ae0064        	ldw	x,#100
 331  002a 89            	pushw	x
 332  002b ae0000        	ldw	x,#0
 333  002e 89            	pushw	x
 334  002f a601          	ld	a,#1
 335  0031 cd0000        	call	_StartTimer
 337  0034 5b08          	addw	sp,#8
 338  0036 2038          	jra	L111
 339  0038               L311:
 340                     ; 69 						MotorUp(0);
 342  0038 5f            	clrw	x
 343  0039 cd0000        	call	_MotorUp
 345  003c 2032          	jra	L111
 346  003e               L37:
 347                     ; 72 				case KEY_DOWN: 
 347                     ; 73 					if(IED.cMoving==1)
 349  003e c60002        	ld	a,_IED+2
 350  0041 a101          	cp	a,#1
 351  0043 2621          	jrne	L121
 352                     ; 75 						if(IED.Direction!=MOTOR_DOWN)
 354  0045 c60011        	ld	a,_IED+17
 355  0048 a101          	cp	a,#1
 356  004a 2724          	jreq	L111
 357                     ; 77 							StopMotor();
 359  004c cd0000        	call	_StopMotor
 361                     ; 78 							StartTimer(TIMER_MODE_ONCEROUTINE,100L,MotorDown,0); 
 363  004f 5f            	clrw	x
 364  0050 89            	pushw	x
 365  0051 ae0000        	ldw	x,#_MotorDown
 366  0054 89            	pushw	x
 367  0055 ae0064        	ldw	x,#100
 368  0058 89            	pushw	x
 369  0059 ae0000        	ldw	x,#0
 370  005c 89            	pushw	x
 371  005d a601          	ld	a,#1
 372  005f cd0000        	call	_StartTimer
 374  0062 5b08          	addw	sp,#8
 375  0064 200a          	jra	L111
 376  0066               L121:
 377                     ; 83 						MovMotor(POS_BOT);//启动全降信号
 379  0066 a602          	ld	a,#2
 380  0068 cd0000        	call	_MovMotor
 382  006b 2003          	jra	L111
 383  006d               L57:
 384                     ; 86 				case KEY_STOP:
 384                     ; 87 					StopMotor();
 386  006d cd0000        	call	_StopMotor
 388                     ; 88 					break;	    
 390  0070               L111:
 391                     ; 94 }  
 394  0070 81            	ret
 418                     ; 96 void checkID(void) 
 418                     ; 97 {
 419                     .text:	section	.text,new
 420  0000               _checkID:
 424                     ; 98 	IED.nId = IED.nId>MAXID?1:IED.nId;
 426  0000 c60000        	ld	a,_IED
 427  0003 a115          	cp	a,#21
 428  0005 2504          	jrult	L61
 429  0007 a601          	ld	a,#1
 430  0009 2003          	jra	L02
 431  000b               L61:
 432  000b c60000        	ld	a,_IED
 433  000e               L02:
 434  000e c70000        	ld	_IED,a
 435                     ; 99 	IED.nId = (IED.nId==0)?MAXID:IED.nId;
 437  0011 725d0000      	tnz	_IED
 438  0015 2604          	jrne	L22
 439  0017 a614          	ld	a,#20
 440  0019 2003          	jra	L42
 441  001b               L22:
 442  001b c60000        	ld	a,_IED
 443  001e               L42:
 444  001e c70000        	ld	_IED,a
 445                     ; 100 }
 448  0021 81            	ret
 475                     ; 102 void SetID(void)
 475                     ; 103 {
 476                     .text:	section	.text,new
 477  0000               _SetID:
 481                     ; 104 	switch(gcKey)
 483  0000 c60000        	ld	a,_gcKey
 485                     ; 114 			break;
 486  0003 4a            	dec	a
 487  0004 2715          	jreq	L341
 488  0006 4a            	dec	a
 489  0007 2706          	jreq	L731
 490  0009 a002          	sub	a,#2
 491  000b 2708          	jreq	L141
 492  000d 201a          	jra	L751
 493  000f               L731:
 494                     ; 106 		case KEY_UP: 
 494                     ; 107 			IED.nId++;
 496  000f 725c0000      	inc	_IED
 497                     ; 108 			break;
 499  0013 2014          	jra	L751
 500  0015               L141:
 501                     ; 109 		case KEY_DOWN: 
 501                     ; 110 			IED.nId--;
 503  0015 725a0000      	dec	_IED
 504                     ; 111 			break;
 506  0019 200e          	jra	L751
 507  001b               L341:
 508                     ; 112 		case KEY_STOP: 
 508                     ; 113 			EEWriteStruct(&IED.nId ,sizeof(IED.nId)/sizeof(char),0); 
 510  001b 5f            	clrw	x
 511  001c 89            	pushw	x
 512  001d ae0001        	ldw	x,#1
 513  0020 89            	pushw	x
 514  0021 ae0000        	ldw	x,#_IED
 515  0024 cd0000        	call	_EEWriteStruct
 517  0027 5b04          	addw	sp,#4
 518                     ; 114 			break;
 520  0029               L751:
 521                     ; 116 	checkID();
 524  0029 cd0000        	call	_checkID
 526                     ; 117 }
 529  002c 81            	ret
 583                     .const:	section	.text
 584  0000               L63:
 585  0000 00002653      	dc.l	9811
 586  0004               L04:
 587  0004 0000006e      	dc.l	110
 589                     ; 124 void ManualCtrl(void)
 589                     ; 125 {	
 590                     .text:	section	.text,new
 591  0000               _ManualCtrl:
 593  0000 88            	push	a
 594       00000001      OFST:	set	1
 597                     ; 126 	unsigned char b_lock = (LockTime==0); //COMM?
 599  0001 ce0000        	ldw	x,_LockTime
 600  0004 2604          	jrne	L23
 601  0006 a601          	ld	a,#1
 602  0008 2001          	jra	L43
 603  000a               L23:
 604  000a 4f            	clr	a
 605  000b               L43:
 606  000b 6b01          	ld	(OFST+0,sp),a
 608                     ; 127 	gcKey=GetKey(); 
 610  000d cd0000        	call	_GetKey
 612  0010 c70000        	ld	_gcKey,a
 613                     ; 128 	checkSetIDMode();
 615  0013 cd0000        	call	_checkSetIDMode
 617                     ; 129 	if(Debug_time==1)
 619  0016 c60000        	ld	a,_Debug_time
 620  0019 a101          	cp	a,#1
 621  001b 265e          	jrne	L571
 622                     ; 131 		if(gcKey==KEY_UP)
 624  001d c60000        	ld	a,_gcKey
 625  0020 a102          	cp	a,#2
 626  0022 2617          	jrne	L771
 627                     ; 133 		 if(IED.MidTimeWait<=9810)
 629  0024 9c            	rvf
 630  0025 ae0014        	ldw	x,#_IED+20
 631  0028 cd0000        	call	c_ltor
 633  002b ae0000        	ldw	x,#L63
 634  002e cd0000        	call	c_lcmp
 636  0031 2e08          	jrsge	L771
 637                     ; 135 			IED.MidTimeWait+=100;//5S
 639  0033 ae0014        	ldw	x,#_IED+20
 640  0036 a664          	ld	a,#100
 641  0038 cd0000        	call	c_lgadc
 643  003b               L771:
 644                     ; 138 		if(gcKey==KEY_DOWN)
 646  003b c60000        	ld	a,_gcKey
 647  003e a104          	cp	a,#4
 648  0040 2617          	jrne	L302
 649                     ; 140 		  if(IED.MidTimeWait>=110)
 651  0042 9c            	rvf
 652  0043 ae0014        	ldw	x,#_IED+20
 653  0046 cd0000        	call	c_ltor
 655  0049 ae0004        	ldw	x,#L04
 656  004c cd0000        	call	c_lcmp
 658  004f 2f08          	jrslt	L302
 659                     ; 142 		    IED.MidTimeWait-=100;//5S
 661  0051 ae0014        	ldw	x,#_IED+20
 662  0054 a664          	ld	a,#100
 663  0056 cd0000        	call	c_lgsbc
 665  0059               L302:
 666                     ; 145 		if(gcKey==KEY_STOP)
 668  0059 c60000        	ld	a,_gcKey
 669  005c a101          	cp	a,#1
 670  005e 2703          	jreq	L24
 671  0060 cc0118        	jp	L112
 672  0063               L24:
 673                     ; 147 		  Debug_time=0;
 675  0063 725f0000      	clr	_Debug_time
 676                     ; 148 			EEWriteStruct(&IED.MidTimeWait ,sizeof(IED.MidTimeWait)/sizeof(char),1); 
 678  0067 ae0001        	ldw	x,#1
 679  006a 89            	pushw	x
 680  006b ae0004        	ldw	x,#4
 681  006e 89            	pushw	x
 682  006f ae0014        	ldw	x,#_IED+20
 683  0072 cd0000        	call	_EEWriteStruct
 685  0075 5b04          	addw	sp,#4
 686  0077 ac180118      	jpf	L112
 687  007b               L571:
 688                     ; 153 	if(gcKey==KEY_MUTE)
 690  007b c60000        	ld	a,_gcKey
 691  007e a108          	cp	a,#8
 692  0080 2603          	jrne	L312
 693                     ; 155 		MuteError();
 695  0082 cd0000        	call	_MuteError
 697  0085               L312:
 698                     ; 157 	if(gcKey==KEY_STOPWARN)
 700  0085 c60000        	ld	a,_gcKey
 701  0088 a103          	cp	a,#3
 702  008a 261b          	jrne	L512
 703                     ; 159 		IED.b_warning=0;
 705  008c 725f0003      	clr	_IED+3
 706                     ; 160 		 Warning_flag=0;
 708  0090 725f0000      	clr	_Warning_flag
 709                     ; 161 		StopWarning();
 711  0094 cd0000        	call	_StopWarning
 713                     ; 162 			StopMotor();
 715  0097 cd0000        	call	_StopMotor
 717                     ; 163 			StopWarning_flag=1;
 719  009a 35010000      	mov	_StopWarning_flag,#1
 720                     ; 164 	GPIO_WriteLow(GPIOA, GPIO_PIN_2);//关闭烟温电源
 722  009e 4b04          	push	#4
 723  00a0 ae5000        	ldw	x,#20480
 724  00a3 cd0000        	call	_GPIO_WriteLow
 726  00a6 84            	pop	a
 727  00a7               L512:
 728                     ; 166  if(IED.cMoving==1)
 730  00a7 c60002        	ld	a,_IED+2
 731  00aa a101          	cp	a,#1
 732  00ac 263a          	jrne	L712
 733                     ; 168 		if((pre_b_lock==0)&&(b_lock==1))
 735  00ae 725d0001      	tnz	_pre_b_lock
 736  00b2 2634          	jrne	L712
 738  00b4 7b01          	ld	a,(OFST+0,sp)
 739  00b6 a101          	cp	a,#1
 740  00b8 262e          	jrne	L712
 741                     ; 170 			if((Warning_flag==1)&&(IED.Direction==MOTOR_DOWN))
 743  00ba c60000        	ld	a,_Warning_flag
 744  00bd a101          	cp	a,#1
 745  00bf 2624          	jrne	L322
 747  00c1 c60011        	ld	a,_IED+17
 748  00c4 a101          	cp	a,#1
 749  00c6 261d          	jrne	L322
 750                     ; 172 					StopMotor();
 752  00c8 cd0000        	call	_StopMotor
 754                     ; 173 					UNLockAllMotor();
 756  00cb cd0000        	call	_UNLockAllMotor
 758                     ; 174 			    StartTimer(TIMER_MODE_ONCEROUTINE,10UL, ConvertDown1,0);
 760  00ce 5f            	clrw	x
 761  00cf 89            	pushw	x
 762  00d0 ae0000        	ldw	x,#_ConvertDown1
 763  00d3 89            	pushw	x
 764  00d4 ae000a        	ldw	x,#10
 765  00d7 89            	pushw	x
 766  00d8 ae0000        	ldw	x,#0
 767  00db 89            	pushw	x
 768  00dc a601          	ld	a,#1
 769  00de cd0000        	call	_StartTimer
 771  00e1 5b08          	addw	sp,#8
 773  00e3 2003          	jra	L712
 774  00e5               L322:
 775                     ; 179 					StopMotor();
 777  00e5 cd0000        	call	_StopMotor
 779  00e8               L712:
 780                     ; 183 	if(ID_SET)
 782  00e8 c60004        	ld	a,_SPIIO+4
 783  00eb a501          	bcp	a,#1
 784  00ed 2705          	jreq	L722
 785                     ; 185 		SetID();
 787  00ef cd0000        	call	_SetID
 790  00f2 2019          	jra	L132
 791  00f4               L722:
 792                     ; 189 		if(b_lock)		  //没有锁定,可以手动操控
 794  00f4 0d01          	tnz	(OFST+0,sp)
 795  00f6 2710          	jreq	L332
 796                     ; 191 			if((IED.Err&(MAIN_POWER_ERROR|ErrPhase))!=0)  //主电错误的情况
 798  00f8 c60005        	ld	a,_IED+5
 799  00fb a505          	bcp	a,#5
 800  00fd 2706          	jreq	L532
 801                     ; 193 				nop();
 804  00ff 9d            nop
 806                     ; 194 				DCManualCtrl();
 809  0100 cd0000        	call	_DCManualCtrl
 812  0103 2003          	jra	L332
 813  0105               L532:
 814                     ; 201 				ACManualCtrl();
 816  0105 cd0000        	call	_ACManualCtrl
 818  0108               L332:
 819                     ; 204    	pre_b_lock=	b_lock;
 821  0108 7b01          	ld	a,(OFST+0,sp)
 822  010a c70001        	ld	_pre_b_lock,a
 823  010d               L132:
 824                     ; 206 	if(gcKey==KEY_STOP2)
 826  010d c60000        	ld	a,_gcKey
 827  0110 a181          	cp	a,#129
 828  0112 2604          	jrne	L112
 829                     ; 208 	   Debug_time=1;
 831  0114 35010000      	mov	_Debug_time,#1
 832  0118               L112:
 833                     ; 213 }
 836  0118 84            	pop	a
 837  0119 81            	ret
 905                     	xref	_Warning_flag
 906                     	xref	_StopWarning_flag
 907                     	switch	.bss
 908  0000               _Debug_time:
 909  0000 00            	ds.b	1
 910                     	xdef	_Debug_time
 911  0001               _pre_b_lock:
 912  0001 00            	ds.b	1
 913                     	xdef	_pre_b_lock
 914                     	xdef	_bMidWait
 915                     	xdef	_bMiddleWaitTimerID
 916                     	xref	_EEWriteStruct
 917                     	xref	_LockTime
 918                     	xref	_GetKey
 919                     	xref	_gcKey
 920                     	xref	_MuteError
 921                     	xref	_StopWarning
 922                     	xref	_MotorUp
 923                     	xref	_MotorDown
 924                     	xref	_checkSetIDMode
 925                     	xref	_MovMotor
 926                     	xref	_StopMotor
 927                     	xref	_IED
 928                     	xref	_SPIIO
 929                     	xref	_StartDC2ACConvert
 930                     	xref	_EnableBrakPower
 931                     	xref	_StopDC2ACConvert
 932                     	xref	_UNLockAllMotor
 933                     	xref	_GPIO_WriteLow
 934                     	xdef	_SetID
 935                     	xdef	_checkID
 936                     	xdef	_ConvertDown
 937                     	xdef	_ConvertDown1
 938                     	xdef	_ManualCtrl
 939                     	xdef	_ACManualCtrl
 940                     	xdef	_DCManualCtrl
 941                     	xref	_StartTimer
 942                     	xref	_SuspendTask
 943                     	xref	_ActiveTask
 963                     	xref	c_lgsbc
 964                     	xref	c_lgadc
 965                     	xref	c_lcmp
 966                     	xref	c_ltor
 967                     	end
