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

📄 os_cpu.lst

📁 给出一个简单操作系统在AVR中应用实例
💻 LST
📖 第 1 页 / 共 2 页
字号:
   1               		.file	"os_cpu.c"
   2               		.arch at90s8515
   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:
  64               	.global	InitOSTimer
  66               	InitOSTimer:
   1:C:/WinAVR/minOS_WinAVR/os_cpu.c **** /*
   2:C:/WinAVR/minOS_WinAVR/os_cpu.c **** ***************************************************************************************************
   3:C:/WinAVR/minOS_WinAVR/os_cpu.c **** *                                      minOS 0.01v
   4:C:/WinAVR/minOS_WinAVR/os_cpu.c **** *                                The Real-Time OS Kernel
   5:C:/WinAVR/minOS_WinAVR/os_cpu.c **** *                                  All Rights Reserved
   6:C:/WinAVR/minOS_WinAVR/os_cpu.c **** * File : OS_CPU.C
   7:C:/WinAVR/minOS_WinAVR/os_cpu.c **** * 作者 : 21icbbs网友 LM7556 ,2004年7月   by : LM7556 , China , 2004-2004 
   8:C:/WinAVR/minOS_WinAVR/os_cpu.c **** *
   9:C:/WinAVR/minOS_WinAVR/os_cpu.c **** ***************************************************************************************************
  10:C:/WinAVR/minOS_WinAVR/os_cpu.c **** */
  11:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  12:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  13:C:/WinAVR/minOS_WinAVR/os_cpu.c **** #define OS_CPU_GLOBALS
  14:C:/WinAVR/minOS_WinAVR/os_cpu.c **** #include "OS_Includes.h"
  15:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  16:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //#pragma interrupt_handler OSTickISR:8  //uses Timer0 for time ticks.
  17:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  18:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //;CPU specific definitions 
  19:C:/WinAVR/minOS_WinAVR/os_cpu.c **** #define C51_CRYSTAL_FREQ   4000000ul
  20:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //;Determine the reload values for timer 0 this is automated by the next macro
  21:C:/WinAVR/minOS_WinAVR/os_cpu.c **** #define T0_RELOAD  C51_CRYSTAL_FREQ / OS_TICKS_PER_SEC / 1024
  22:C:/WinAVR/minOS_WinAVR/os_cpu.c **** #define T0_TCNT0 (256 - (T0_RELOAD & 0xff))
  23:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //Initial OS Timer for time ticks --- 初始化时间节拍定时器。
  24:C:/WinAVR/minOS_WinAVR/os_cpu.c **** void InitOSTimer(void)
  25:C:/WinAVR/minOS_WinAVR/os_cpu.c **** {
  68               	.LM1:
  69               	/* prologue: frame size=0 */
  70               	/* prologue end (size=0) */
  26:C:/WinAVR/minOS_WinAVR/os_cpu.c ****   TIMSK |= (1<<1);     // set T0IE0
  72               	.LM2:
  73 0000 89B7      		in r24,89-0x20
  74 0002 8260      		ori r24,lo8(2)
  75 0004 89BF      		out 89-0x20,r24
  27:C:/WinAVR/minOS_WinAVR/os_cpu.c ****   TCCR0  = 0x05;       // CTC0=CK/1024
  77               	.LM3:
  78 0006 85E0      		ldi r24,lo8(5)
  79 0008 83BF      		out 83-0x20,r24
  28:C:/WinAVR/minOS_WinAVR/os_cpu.c ****   TCNT0  = T0_TCNT0;   // (256 - (T0_RELOAD & 0xff))
  81               	.LM4:
  82 000a 8AE7      		ldi r24,lo8(122)
  83 000c 82BF      		out 82-0x20,r24
  29:C:/WinAVR/minOS_WinAVR/os_cpu.c ****   SREG  |= (1<<7);     // SEI
  85               	.LM5:
  86 000e 8FB7      		in r24,95-0x20
  87 0010 8068      		ori r24,lo8(-128)
  88 0012 8FBF      		out 95-0x20,r24
  89               	/* epilogue: frame size=0 */
  90 0014 0895      		ret
  91               	/* epilogue end (size=1) */
  92               	/* function InitOSTimer size 11 (10) */
  98               	.global	OSTaskCreate
 100               	OSTaskCreate:
  30:C:/WinAVR/minOS_WinAVR/os_cpu.c **** }
  31:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  32:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //建立一个任务(Create a Task)。
  33:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //Inport :  tFunc --- function address , tStk --- stack bottom , prio --- Priority .
  34:C:/WinAVR/minOS_WinAVR/os_cpu.c **** void OSTaskCreate (void (*tFunc)(void) , OS_STK *tStk, INT8U prio) 
  35:C:/WinAVR/minOS_WinAVR/os_cpu.c **** {
 102               	.LM6:
 103               	/* prologue: frame size=0 */
 104 0016 CF93      		push r28
 105 0018 DF93      		push r29
 106               	/* prologue end (size=2) */
 107 001a 282F      		mov r18,r24
 108 001c 392F      		mov r19,r25
 109 001e F72F      		mov r31,r23
 110 0020 E62F      		mov r30,r22
 111 0022 842F      		mov r24,r20
  36:C:/WinAVR/minOS_WinAVR/os_cpu.c ****  	OSTCB[prio].OSTaskStatus = OS_TASK_Rdy;
 113               	.LM7:
 114 0024 9927      		clr r25
 115 0026 B92F      		mov r27,r25
 116 0028 A82F      		mov r26,r24
 117 002a AA0F      		lsl r26
 118 002c BB1F      		rol r27
 119 002e AA0F      		lsl r26
 120 0030 BB1F      		rol r27
 121 0032 A80F      		add r26,r24
 122 0034 B91F      		adc r27,r25
 123 0036 A050      		subi r26,lo8(-(OSTCB))
 124 0038 B040      		sbci r27,hi8(-(OSTCB))
 125 003a 8CEF      		ldi r24,lo8(-4)
 126 003c DB2F      		mov r29,r27
 127 003e CA2F      		mov r28,r26
 128 0040 8A83      		std Y+2,r24
  37:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	OSTCB[prio].OSStkTop = (INT16U)tStk-1 /* Initial value when main was called             */
 130               	.LM8:
 131 0042 3F97      		sbiw r30,15
 132 0044 ED93      		st X+,r30
 133 0046 FC93      		st X,r31
 134 0048 3F96      		adiw r30,15
  38:C:/WinAVR/minOS_WinAVR/os_cpu.c ****                           -12             /* reserve for to save R0-R5 , R26-R31 registers  */
  39:C:/WinAVR/minOS_WinAVR/os_cpu.c ****                           -sizeof(INT16U) /* The PC value to be loaded                      */
  40:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 					   ;
  41:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	*--tStk	=  (INT16U const)tFunc & 0xff;   /* Save low byte of task function address   */
 136               	.LM9:
 137 004a 2293      		st -Z,r18
  42:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	*--tStk	=  (INT16U const)tFunc / 0x100;  /* Save high byte of task function address  */
 139               	.LM10:
 140 004c 3197      		sbiw r30,1
 141 004e 832F      		mov r24,r19
 142 0050 9927      		clr r25
 143 0052 8083      		st Z,r24
 144               	/* epilogue: frame size=0 */
 145 0054 DF91      		pop r29
 146 0056 CF91      		pop r28
 147 0058 0895      		ret
 148               	/* epilogue end (size=3) */
 149               	/* function OSTaskCreate size 34 (29) */
 152               	.global	OSCtxSw
 154               	OSCtxSw:
  43:C:/WinAVR/minOS_WinAVR/os_cpu.c **** }
  44:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  45:C:/WinAVR/minOS_WinAVR/os_cpu.c **** static unsigned int SaveSP; //用于保存需恢复的SP,在OSTickISR或用户中断结束做任务切换时,恢复SP.
  46:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  47:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //context switch interrupt --- 软中断任务切换
  48:C:/WinAVR/minOS_WinAVR/os_cpu.c **** void OSCtxSw(void) 
  49:C:/WinAVR/minOS_WinAVR/os_cpu.c **** {
 156               	.LM11:
 157               	/* prologue: frame size=0 */
 158               	/* prologue end (size=0) */
  50:C:/WinAVR/minOS_WinAVR/os_cpu.c **** //asm("in %0, %1" : "=r" (value) : "I" (PORTD) : );
  51:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  52:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R31");
 160               	.LM12:
 161               	/* #APP */
 162 005a FF93      		PUSH R31
  53:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R30");
 164               	.LM13:
 165 005c EF93      		PUSH R30
  54:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R29");	
 167               	.LM14:
 168 005e DF93      		PUSH R29
  55:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R28");
 170               	.LM15:
 171 0060 CF93      		PUSH R28
  56:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R27");
 173               	.LM16:
 174 0062 BF93      		PUSH R27
  57:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R26");
 176               	.LM17:
 177 0064 AF93      		PUSH R26
  58:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 
  59:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R0");
 179               	.LM18:
 180 0066 0F92      		PUSH R0
  60:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R1");
 182               	.LM19:
 183 0068 1F92      		PUSH R1
  61:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R2");	
 185               	.LM20:
 186 006a 2F92      		PUSH R2
  62:C:/WinAVR/minOS_WinAVR/os_cpu.c **** 	asm("PUSH R3");

⌨️ 快捷键说明

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