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

📄 test.lst

📁 基于AVR平台的RTOS
💻 LST
📖 第 1 页 / 共 3 页
字号:
   1               		.file	"test.c"
   2               		.arch atmega8
   3               	__SREG__ = 0x3f
   4               	__SP_H__ = 0x3e
   5               	__SP_L__ = 0x3d
   6               	__tmp_reg__ = 0
   7               	__zero_reg__ = 1
   8               		.global __do_copy_data
   9               		.global __do_clear_bss
  11               		.text
  12               	.Ltext0:
  86               	.global	task1
  88               	task1:
   1:test.c        **** /*=========================================================================================
   2:test.c        **** 项目名称: 小型开源实时操作系统
   3:test.c        **** 软件版本: VER 1.0
   4:test.c        **** 目标平台: AVR系列单片机
   5:test.c        **** 工具链  : AVR-GCC(V4.1.2) WINAVR-20070525
   6:test.c        **** 开发人员: 韩骁
   7:test.c        **** 开发时间: 2007-07-05
   8:test.c        **** 版权    : GPL(GNU General Public License)
   9:test.c        **** 文件名称: test.c
  10:test.c        **** 文件说明:
  11:test.c        **** sosos系统的测试程序
  12:test.c        **** 本次测试采用ARMEL公司的MEGA8进行
  13:test.c        **** =========================================================================================*/
  14:test.c        **** #include <avr/io.h>
  15:test.c        **** #include <avr/interrupt.h>
  16:test.c        **** 
  17:test.c        **** #include "MYBIT.H"
  18:test.c        **** #include "sosos.h"
  19:test.c        **** #include "test.h"
  20:test.c        **** 
  21:test.c        **** //外部中断0 (2)
  22:test.c        **** SOSOS_ISR(SIG_INTERRUPT0)
  23:test.c        **** {
  24:test.c        **** //进入中断
  25:test.c        ****  SOSOS_ENTER_INTERRUPT();
  26:test.c        **** 
  27:test.c        ****  ENABLE_INTERRUPT();
  28:test.c        **** //触发外部中断1
  29:test.c        ****  set_bit(PORTD,3);
  30:test.c        ****  clr_bit(PORTD,3);
  31:test.c        **** 
  32:test.c        ****  counter_intr0++;
  33:test.c        ****  SososLogicSemPost(&LOG_SEM);
  34:test.c        **** 
  35:test.c        **** //离开中断
  36:test.c        ****  SOSOS_EXIT_INTERRUPT();
  37:test.c        **** }
  38:test.c        **** 
  39:test.c        **** //外部中断1 (4)
  40:test.c        **** SOSOS_ISR(SIG_INTERRUPT1)
  41:test.c        **** {
  42:test.c        **** //进入中断
  43:test.c        ****  SOSOS_ENTER_INTERRUPT();
  44:test.c        **** 
  45:test.c        ****  counter_intr1++;
  46:test.c        **** 
  47:test.c        **** //离开中断
  48:test.c        ****  SOSOS_EXIT_INTERRUPT();
  49:test.c        **** }
  50:test.c        **** 
  51:test.c        **** 
  52:test.c        **** void SososIdleHook(void){//系统空闲任务钩子
  53:test.c        **** 
  54:test.c        **** //定时器
  55:test.c        ****  if(SososGetTimer(TIMER0)==0){
  56:test.c        ****    SososSetTimer(TIMER0,TIMER0_VALUE);//定时器0
  57:test.c        ****    }
  58:test.c        ****  if(SososGetTimer(TIMER0)<5){
  59:test.c        ****    counter_hook--;
  60:test.c        **** //触发外部中断0
  61:test.c        ****    set_bit(PORTD,2);
  62:test.c        ****    clr_bit(PORTD,2);
  63:test.c        ****    }
  64:test.c        ****  else
  65:test.c        ****    counter_hook++;
  66:test.c        **** 
  67:test.c        ****  }//系统空闲任务钩子
  68:test.c        **** 
  69:test.c        **** int main(void){//主函数
  70:test.c        **** 
  71:test.c        **** //初始化外部中断0
  72:test.c        ****  MCUCR=MCUCR|(1<<ISC01);//下降延触发
  73:test.c        ****  GIMSK=GIMSK|(1<<INT0);//允许外部中断0
  74:test.c        ****  DDRD=DDRD|(1<<DDD2);//D2为输出引脚
  75:test.c        ****  set_bit(PORTD,2);
  76:test.c        **** //初始化外部中断0
  77:test.c        ****  MCUCR=MCUCR|(1<<ISC11);//下降延触发
  78:test.c        ****  GIMSK=GIMSK|(1<<INT1);//允许外部中断1
  79:test.c        ****  DDRD=DDRD|(1<<DDD3);//D3为输出引脚
  80:test.c        ****  set_bit(PORTD,3);
  81:test.c        **** 
  82:test.c        ****  SososInitOs();//初始化SOSOS系统
  83:test.c        ****  SososCreateTask(task0,TASK0_PRI,TASK0_ID,TASK0_STACK_SIZE,(void *)&counter0);//创建task0任务
  84:test.c        ****  SososCreateTask(task1,TASK1_PRI,TASK1_ID,TASK1_STACK_SIZE,(void *)&counter1);//创建task1任务
  85:test.c        ****  SososCreateTask(task1,TASK2_PRI,TASK2_ID,TASK2_STACK_SIZE,(void *)&counter2);//创建task1任务
  86:test.c        ****  SososSetTimer(TIMER0,TIMER0_VALUE);//定时器0
  87:test.c        ****  SososCreateLogicSem(&LOG_SEM,SOSOS_SIGNAL_ENGROSS);//创建逻辑型信号量
  88:test.c        ****  SososCreateMutex(&MUTEX_SEM,SOSOS_SIGNAL_FREE);//创建互斥型信号量
  89:test.c        ****  SososCreateFlag(&event_flag1,&flag_grp1,1,1);//创建事件标志
  90:test.c        ****  SososCreateFlag(&event_flag2,&flag_grp1,2,2);//创建事件标志
  91:test.c        ****  SososStartOs();//启动SOSOS系统
  92:test.c        **** 
  93:test.c        ****  }//主函数
  94:test.c        **** 
  95:test.c        **** void task0(unsigned int *ptr){//任务0
  96:test.c        ****  unsigned char i=0;
  97:test.c        ****  while(1){//任务循环
  98:test.c        **** 
  99:test.c        ****    test0=SososLogicSemPend(&LOG_SEM,2);//等待逻辑型信号量
 100:test.c        ****    if(test0==SOSOS_OK){
 101:test.c        ****      (*ptr)++;//counter0
 102:test.c        **** 
 103:test.c        ****      SososGetMutex(&MUTEX_SEM,0);//获得互斥型信号量
 104:test.c        ****      com_counter++;
 105:test.c        ****      SososFreeMutex(&MUTEX_SEM);//释放互斥型信号量
 106:test.c        ****      }
 107:test.c        **** 
 108:test.c        ****    if((i&1)==0)
 109:test.c        ****      SososChangeFlag(&event_flag1,1,SOSOS_FLAG_OPT_SET);//改变事件标志
 110:test.c        ****    else
 111:test.c        ****      SososChangeFlag(&event_flag2,2,SOSOS_FLAG_OPT_SET);//改变事件标志
 112:test.c        ****    i++;
 113:test.c        ****    }//任务循环
 114:test.c        ****  }//任务0
 115:test.c        **** 
 116:test.c        **** void task1(unsigned int *ptr){//任务1/2
  89               	ologue end (size=2) */
  90               		movw r28,r24
  91               	.L3:
  93 0002 DF93      	.LM1:
  94               		rcall SososGetTaskId
  95 0004 EC01      		cpi r24,lo8(16)
  96               		brne .L4
 117:test.c        ****  while(1){//任务循环
 118:test.c        **** 
 119:test.c        ****    if(SososGetTaskId()==0x10){//任务1
  97               	68,0,120,.LM2-task1
  98               	.LM2:
  99 0006 00D0      		ldi r18,lo8(0)
 100 0008 8031      		ldi r20,lo8(1)
 101 000a 01F4      		ldi r22,lo8(1)
 120:test.c        ****      SososWaitFlag(&event_flag1,1,1,0);//等待指定的事件
 102               	r24,lo8(event_flag1)
 103               		ldi r25,hi8(event_flag1)
 104 000c 20E0      		rcall SososWaitFlag
 106 0010 61E0      	.LM3:
 107 0012 80E0      		ldi r20,lo8(0)
 108 0014 90E0      		ldi r22,lo8(1)
 109 0016 00D0      		ldi r24,lo8(event_flag1)
 121:test.c        ****      SososChangeFlag(&event_flag1,1,SOSOS_FLAG_OPT_CLR);//改变事件标志
 110               	,hi8(event_flag1)
 111               		rcall SososChangeFlag
 113 001a 61E0      	.LM4:
 114 001c 80E0      		ld r24,Y
 115 001e 90E0      		ldd r25,Y+1
 116 0020 00D0      		adiw r24,1
 122:test.c        ****      (*ptr)++;//counter1
 117               	1,r25
 118               		st Y,r24
 119 0022 8881      	.L4:
 121 0026 0196      	.LM5:
 122 0028 9983      		rcall SososGetTaskId
 123 002a 8883      		cpi r24,lo8(17)
 124               		brne .L6
 123:test.c        ****      }//任务1
 124:test.c        **** 
 125:test.c        ****    if(SososGetTaskId()==0x11){//任务2
 125               	68,0,126,.LM6-task1
 126               	.LM6:
 127 002c 00D0      		ldi r18,lo8(0)
 128 002e 8131      		ldi r20,lo8(2)
 129 0030 01F4      		ldi r22,lo8(2)
 126:test.c        ****      SososWaitFlag(&event_flag2,2,2,0);//等待指定的事件
 130               	r24,lo8(event_flag2)
 131               		ldi r25,hi8(event_flag2)
 132 0032 20E0      		rcall SososWaitFlag
 134 0036 62E0      	.LM7:
 135 0038 80E0      		ldi r20,lo8(0)
 136 003a 90E0      		ldi r22,lo8(2)
 137 003c 00D0      		ldi r24,lo8(event_flag2)
 127:test.c        ****      SososChangeFlag(&event_flag2,2,SOSOS_FLAG_OPT_CLR);//改变事件标志
 138               	,hi8(event_flag2)
 139               		rcall SososChangeFlag
 141 0040 62E0      	.LM8:
 142 0042 80E0      		ld r24,Y
 143 0044 90E0      		ldd r25,Y+1
 144 0046 00D0      		adiw r24,1
 128:test.c        ****      (*ptr)++;//counter2
 145               	1,r25
 146               		st Y,r24
 147 0048 8881      	.L6:
 149 004c 0196      	.LM9:
 150 004e 9983      		ldi r22,lo8(0)
 151 0050 8883      		ldi r24,lo8(MUTEX_SEM)
 152               		ldi r25,hi8(MUTEX_SEM)
 129:test.c        ****      }//任务2
 130:test.c        **** 
 131:test.c        ****    SososGetMutex(&MUTEX_SEM,0);//获得互斥型信号量
 153               	ososGetMutex
 155 0052 60E0      	.LM10:
 156 0054 80E0      		ldi r24,lo8(1)
 157 0056 90E0      		ldi r25,hi8(1)
 158 0058 00D0      		rcall SososDelay
 132:test.c        ****    SososDelay(1);//任务延时
 159               	n	68,0,133,.LM11-task1
 160               	.LM11:
 161 005a 81E0      		lds r24,com_counter
 162 005c 90E0      		lds r25,(com_counter)+1
 163 005e 00D0      		adiw r24,1
 133:test.c        ****    com_counter++;
 164               	(com_counter)+1,r25
 165               		sts com_counter,r24
 167 0064 9091 0000 	.LM12:
 168 0068 0196      		ldi r24,lo8(MUTEX_SEM)
 169 006a 9093 0000 		ldi r25,hi8(MUTEX_SEM)
 170 006e 8093 0000 		rcall SososFreeMutex
 134:test.c        ****    SososFreeMutex(&MUTEX_SEM);//释放互斥型信号量
 171               	L3
 172               	/* epilogue: frame size=0 */
 173 0072 80E0      	/* epilogue: noreturn */
 174 0074 90E0      	/* epilogue end (size=0) */
 175 0076 00D0      	/* function task1 size 61 (59) */
 177               	.Lscope0:
 180               	.global	task0
 182               	task0:
 184               	.LM13:
 185               	/* prologue: frame size=4 */
 186               		push r16
 187               		push r28
 188               		push r29
 189               		in r28,__SP_L__
 190               		in r29,__SP_H__
 191 007a 0F93      		sbiw r28,4
 192 007c CF93      		in __tmp_reg__,__SREG__
 193 007e DF93      		cli
 194 0080 CDB7      		out __SP_H__,r29
 195 0082 DEB7      		out __SREG__,__tmp_reg__
 196 0084 2497      		out __SP_L__,r28
 197 0086 0FB6      	/* prologue end (size=11) */
 198 0088 F894      		std Y+2,r25
 199 008a DEBF      		std Y+1,r24
 200 008c 0FBE      		std Y+4,__zero_reg__
 201 008e CDBF      		std Y+3,__zero_reg__
 202               	.L10:
 204 0092 8983      	.LM14:
 205 0094 1C82      		ldd r16,Y+3
 207               	.LM15:
 208               		ldi r22,lo8(2)
 209               		ldi r24,lo8(LOG_SEM)
 210 0098 0B81      		ldi r25,hi8(LOG_SEM)
 211               		rcall SososLogicSemPend
 212               		sts test0,r24
 214 009c 80E0      	.LM16:
 215 009e 90E0      		tst r24
 216 00a0 00D0      		brne .L11
 218               	.LM17:
 219               		ldd r30,Y+1
 220 00a6 8823      		ldd r31,Y+2
 221 00a8 01F4      		ld r24,Z
 222               		ldd r25,Z+1
 223               		adiw r24,1
 224 00aa E981      		std Z+1,r25
 225 00ac FA81      		st Z,r24
 227 00b0 9181      	.LM18:
 228 00b2 0196      		ldi r22,lo8(0)
 229 00b4 9183      		ldi r24,lo8(MUTEX_SEM)
 230 00b6 8083      		ldi r25,hi8(MUTEX_SEM)
 231               		rcall SososGetMutex
 233 00b8 60E0      	.LM19:
 234 00ba 80E0      		lds r24,com_counter
 235 00bc 90E0      		lds r25,(com_counter)+1
 236 00be 00D0      		adiw r24,1
 237               		sts (com_counter)+1,r25
 238               		sts com_counter,r24
 240 00c4 9091 0000 	.LM20:
 241 00c8 0196      		ldi r24,lo8(MUTEX_SEM)
 242 00ca 9093 0000 		ldi r25,hi8(MUTEX_SEM)
 243 00ce 8093 0000 		rcall SososFreeMutex
 244               	.L11:
 246 00d2 80E0      	.LM21:
 247 00d4 90E0      		sbrc r16,0
 248 00d6 00D0      		rjmp .L13
 250               	.LM22:
 251               		ldi r20,lo8(1)
 252 00d8 00FD      		ldi r22,lo8(1)
 253 00da 00C0      		ldi r24,lo8(event_flag1)
 254               		ldi r25,hi8(event_flag1)
 255               		rjmp .L17
 256 00dc 41E0      	.L13:
 258 00e0 80E0      	.LM23:
 259 00e2 90E0      		ldi r20,lo8(1)
 260 00e4 00C0      		ldi r22,lo8(2)
 261               		ldi r24,lo8(event_flag2)
 262               		ldi r25,hi8(event_flag2)
 263               	.L17:
 264 00e6 41E0      		rcall SososChangeFlag
 265 00e8 62E0      		ldd r24,Y+3
 266 00ea 80E0      		ldd r25,Y+4
 267 00ec 90E0      		adiw r24,1
 268               		std Y+4,r25
 269 00ee 00D0      		std Y+3,r24
 270 00f0 8B81      		rjmp .L10
 271 00f2 9C81      	/* epilogue: frame size=4 */
 272 00f4 0196      	/* epilogue: noreturn */
 273 00f6 9C83      	/* epilogue end (size=0) */

⌨️ 快捷键说明

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