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

📄 task.s

📁 AVR单片机 C语言程序设计经典实用
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module Task.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
	.dbfunc e Task1_Init _Task1_Init fV
	.even
_Task1_Init::
	.dbline -1
	.dbline 28
; //******************************************************************************
; // File Name : Task.c
; // Author    : Steaven
; // Created   : 2008-06-09
; // Modified  : 
; // Revision  : V0.0
; //******************************************************************************
; 
; #include "app.h"
; 
; //local function declaration
; void Task1_Init(void);
; void Task2_Init(void);
; void Task3_Init(void);
; void Task4_Init(void);
; void Task1(void);
; void Task2(void);
; void Task3(void);
; void Task4(void);
; 
; //******************************************************************************
; // Function    : Task1_Init
; // Input       : none
; // Output      : none
; // Description : Initialization of task1,off LED1
; //******************************************************************************
; void Task1_Init(void)
; {
	.dbline 29
; 	LED_OFF(cLED1);
	ldi R16,4
	.dbline -2
	.dbline 30
; }
L1:
	.dbline 0 ; func end
	xjmp _LED_OFF
	.dbend
	.dbfunc e Task2_Init _Task2_Init fV
	.even
_Task2_Init::
	.dbline -1
	.dbline 39
; 
; //******************************************************************************
; // Function    : Task2_Init
; // Input       : none
; // Output      : none
; // Description : Initialization of task2,off LED2
; //******************************************************************************
; void Task2_Init(void)
; {
	.dbline 40
; 	LED_OFF(cLED2);
	ldi R16,5
	.dbline -2
	.dbline 41
; }
L2:
	.dbline 0 ; func end
	xjmp _LED_OFF
	.dbend
	.dbfunc e Task3_Init _Task3_Init fV
	.even
_Task3_Init::
	.dbline -1
	.dbline 50
; 
; //******************************************************************************
; // Function    : Task3_Init
; // Input       : none
; // Output      : none
; // Description : Initialization of task3,off LED3
; //******************************************************************************
; void Task3_Init(void)
; {
	.dbline 51
; 	LED_OFF(cLED3);
	ldi R16,6
	.dbline -2
	.dbline 52
; }
L3:
	.dbline 0 ; func end
	xjmp _LED_OFF
	.dbend
	.dbfunc e Task4_Init _Task4_Init fV
	.even
_Task4_Init::
	.dbline -1
	.dbline 61
; 
; //******************************************************************************
; // Function    : Task4_Init
; // Input       : none
; // Output      : none
; // Description : Initialization of task4,off LED4
; //******************************************************************************
; void Task4_Init(void)
; {
	.dbline 62
; 	LED_OFF(cLED4);
	ldi R16,7
	.dbline -2
	.dbline 63
; }
L4:
	.dbline 0 ; func end
	xjmp _LED_OFF
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
L6:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
	.dbfunc e Task1 _Task1 fV
	.dbsym s bKey_Status L6 c
;    wTask_Event -> R20,R21
	.even
_Task1::
	xcall push_gset1
	.dbline -1
	.dbline 72
; 
; //******************************************************************************
; // Function    : Task1
; // Input       : none
; // Output      : none
; // Description : Task1 process,Control LED1
; //******************************************************************************
; void Task1(void)
; {
	xjmp L8
L7:
	.dbline 76
; 	INT16U wTask_Event;
;     static INT8U bKey_Status = cOFF_Status;
;     while(1)
; 	{
	.dbline 78
; 		//task switch
; 		if(OS_Task_Switch(cPrioTask1) == true)
	clr R16
	xcall _OS_Task_Switch
	cpi R16,1
	ldi R30,0
	cpc R17,R30
	brne L10
	.dbline 79
; 		{
	.dbline 80
; 			return;
	xjmp L5
L10:
	.dbline 83
; 		}
; 		//get event
; 		wTask_Event = OS_Event_Pend(cPrioTask1);
	clr R16
	xcall _OS_Event_Pend
	movw R20,R16
	.dbline 85
;         //event check
;         if(wTask_Event == 0)
	cpi R16,0
	cpc R16,R17
	brne L12
X0:
	.dbline 86
;         {
	.dbline 87
;             return;
	xjmp L5
L12:
	.dbline 90
;         }
; 		//event parsing : timer event
; 		if(wTask_Event & (1 << eTask1_Timer))
	sbrs R20,0
	rjmp L14
	.dbline 91
; 		{
	.dbline 92
; 			if(bKey_Status == cOFF_Status)
	lds R2,L6
	tst R2
	brne L16
	.dbline 93
; 			{
	.dbline 94
; 				LED_OFF(cLED1);
	ldi R16,4
	xcall _LED_OFF
	.dbline 95
; 			}
	xjmp L17
L16:
	.dbline 96
; 			else if(bKey_Status == cON_Status)
	lds R24,L6
	cpi R24,1
	brne L18
	.dbline 97
; 			{
	.dbline 98
; 				LED_ON(cLED1);
	ldi R16,4
	xcall _LED_ON
	.dbline 99
; 			}
	xjmp L19
L18:
	.dbline 100
; 			else if(bKey_Status == cTOGGLE_Status)
	lds R24,L6
	cpi R24,2
	brne L20
	.dbline 101
; 			{
	.dbline 102
; 				LED_TOGGLE(cLED1);
	ldi R16,4
	xcall _LED_TOGGLE
	.dbline 103
; 			}
L20:
L19:
L17:
	.dbline 104
; 		}
L14:
	.dbline 106
; 		//event parsing : key event
; 		if(wTask_Event & (1 << eTask1_Key))
	sbrs R20,1
	rjmp L22
	.dbline 107
; 		{
	.dbline 108
; 			if(bKey_Status == cOFF_Status)
	lds R2,L6
	tst R2
	brne L24
	.dbline 109
; 			{
	.dbline 110
; 				bKey_Status = cTOGGLE_Status;
	ldi R24,2
	sts L6,R24
	.dbline 111
; 			}
	xjmp L25
L24:
	.dbline 112
; 			else if(bKey_Status == cTOGGLE_Status)
	lds R24,L6
	cpi R24,2
	brne L26
	.dbline 113
; 			{
	.dbline 114
; 				bKey_Status = cOFF_Status;
	clr R2
	sts L6,R2
	.dbline 115
; 			}
	xjmp L27
L26:
	.dbline 116
; 			else if(bKey_Status == cON_Status)
	lds R24,L6
	cpi R24,1
	brne L28
	.dbline 117
; 			{
	.dbline 118
; 				bKey_Status = cOFF_Status;
	clr R2
	sts L6,R2
	.dbline 119
; 			}
L28:
L27:
L25:
	.dbline 120
; 		}
L22:
	.dbline 121
L8:
	.dbline 75
	xjmp L7
X1:
	.dbline -2
	.dbline 122
; 	}
; }
L5:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r wTask_Event 20 i
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
L31:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\多任务模拟系统设计\Task.c
	.dbfunc e Task2 _Task2 fV
	.dbsym s bKey_Status L31 c
;    wTask_Event -> R20,R21
	.even
_Task2::
	xcall push_gset1
	.dbline -1
	.dbline 131
; 
; //******************************************************************************
; // Function    : Task2
; // Input       : none
; // Output      : none
; // Description : Task2 process,Control LED2
; //******************************************************************************
; void Task2(void)
; {
	xjmp L33
L32:
	.dbline 135
;     INT16U wTask_Event;	
;     static INT8U bKey_Status = cOFF_Status;
;     while(1)
; 	{
	.dbline 137
; 		//task switch
; 		if(OS_Task_Switch(cPrioTask2) == true)
	ldi R16,1
	xcall _OS_Task_Switch
	cpi R16,1
	ldi R30,0
	cpc R17,R30
	brne L35
	.dbline 138
; 		{
	.dbline 139
; 			return;
	xjmp L30
L35:
	.dbline 142
; 		}
; 		//get event
; 		wTask_Event = OS_Event_Pend(cPrioTask2);
	ldi R16,1
	xcall _OS_Event_Pend
	movw R20,R16
	.dbline 143
;         if(wTask_Event == 0)
	cpi R16,0
	cpc R16,R17
	brne L37
X2:
	.dbline 144
;         {
	.dbline 145
;             return;
	xjmp L30
L37:
	.dbline 148
;         }
; 		//event parsing : timer event
; 		if(wTask_Event & (1 << eTask2_Timer))
	sbrs R20,0
	rjmp L39
	.dbline 149
; 		{
	.dbline 150
; 			if(bKey_Status == cOFF_Status)
	lds R2,L31
	tst R2
	brne L41
	.dbline 151
; 			{
	.dbline 152
; 				LED_OFF(cLED2);
	ldi R16,5
	xcall _LED_OFF
	.dbline 153
; 			}
	xjmp L42
L41:
	.dbline 154
; 			else if(bKey_Status == cON_Status)
	lds R24,L31
	cpi R24,1
	brne L43
	.dbline 155
; 			{
	.dbline 156
; 				LED_ON(cLED2);
	ldi R16,5
	xcall _LED_ON
	.dbline 157
; 			}
	xjmp L44
L43:
	.dbline 158
; 			else if(bKey_Status == cTOGGLE_Status)
	lds R24,L31
	cpi R24,2
	brne L45
	.dbline 159
; 			{
	.dbline 160
; 				LED_TOGGLE(cLED2);
	ldi R16,5
	xcall _LED_TOGGLE
	.dbline 161
; 			}
L45:
L44:
L42:
	.dbline 162
; 		}
L39:
	.dbline 164
; 		//event parsing : key event
; 		if(wTask_Event & (1 << eTask2_Key))
	sbrs R20,1
	rjmp L47
	.dbline 165
; 		{
	.dbline 166
; 			if(bKey_Status == cOFF_Status)
	lds R2,L31
	tst R2
	brne L49
	.dbline 167
; 			{
	.dbline 168
; 				bKey_Status = cTOGGLE_Status;
	ldi R24,2
	sts L31,R24
	.dbline 169
; 			}

⌨️ 快捷键说明

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