os_time.lis
来自「将本站的UCOSFORAVR128V276版本升级到了280版」· LIS 代码 · 共 648 行 · 第 1/2 页
LIS
648 行
.module os_time.c
.area text(rom, con, rel)
0000 .dbfile E:\ypt050912\XIAZAI\xinzai\UCOSAVR128\Source\os_time.c
0000 .dbfunc e OSTimeDly _OSTimeDly fV
0000 ; y -> R10
0000 ; cpu_sr -> R20
0000 ; ticks -> R22,R23
.even
0000 _OSTimeDly::
0000 0E940000 xcall push_gset3
0004 B801 movw R22,R16
0006 .dbline -1
0006 .dbline 37
0006 ; /*
0006 ; *********************************************************************************************************
0006 ; * uC/OS-II
0006 ; * The Real-Time Kernel
0006 ; * TIME MANAGEMENT
0006 ; *
0006 ; * (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
0006 ; * All Rights Reserved
0006 ; *
0006 ; * File : OS_TIME.C
0006 ; * By : Jean J. Labrosse
0006 ; * Version : V2.80
0006 ; *********************************************************************************************************
0006 ; */
0006 ;
0006 ; #ifndef OS_MASTER_FILE
0006 ; #include <ucos_ii.h>
0006 ; #endif
0006 ;
0006 ; /*
0006 ; *********************************************************************************************************
0006 ; * DELAY TASK 'n' TICKS (n from 0 to 65535)
0006 ; *
0006 ; * Description: This function is called to delay execution of the currently running task until the
0006 ; * specified number of system ticks expires. This, of course, directly equates to delaying
0006 ; * the current task for some time to expire. No delay will result If the specified delay is
0006 ; * 0. If the specified delay is greater than 0 then, a context switch will result.
0006 ; *
0006 ; * Arguments : ticks is the time delay that the task will be suspended in number of clock 'ticks'.
0006 ; * Note that by specifying 0, the task will not be delayed.
0006 ; *
0006 ; * Returns : none
0006 ; *********************************************************************************************************
0006 ; */
0006 ;
0006 ; void OSTimeDly (INT16U ticks)
0006 ; {
0006 .dbline 40
0006 ; INT8U y;
0006 ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
0006 ; OS_CPU_SR cpu_sr = 0;
0006 4427 clr R20
0008 .dbline 45
0008 ; #endif
0008 ;
0008 ;
0008 ;
0008 ; if (ticks > 0) { /* 0 means no delay! */
0008 6030 cpi R22,0
000A 6707 cpc R22,R23
000C 09F4 brne X1
000E 35C0 xjmp L2
0010 X1:
0010 X0:
0010 .dbline 45
0010 .dbline 46
0010 ; OS_ENTER_CRITICAL();
0010 0E940000 xcall _OS_CPU_SR_Save
0014 402F mov R20,R16
0016 .dbline 47
0016 ; y = OSTCBCur->OSTCBY; /* Delay current task */
0016 E0910000 lds R30,_OSTCBCur
001A F0910100 lds R31,_OSTCBCur+1
001E A684 ldd R10,z+14
0020 .dbline 48
0020 ; OSRdyTbl[y] &= ~OSTCBCur->OSTCBBitX;
0020 80E0 ldi R24,<_OSRdyTbl
0022 90E0 ldi R25,>_OSRdyTbl
0024 2A2C mov R2,R10
0026 3324 clr R3
0028 280E add R2,R24
002A 391E adc R3,R25
002C E0910000 lds R30,_OSTCBCur
0030 F0910100 lds R31,_OSTCBCur+1
0034 4784 ldd R4,z+15
0036 4094 com R4
0038 F101 movw R30,R2
003A 5080 ldd R5,z+0
003C 5420 and R5,R4
003E 5082 std z+0,R5
0040 .dbline 49
0040 ; if (OSRdyTbl[y] == 0) {
0040 EA2D mov R30,R10
0042 FF27 clr R31
0044 E80F add R30,R24
0046 F91F adc R31,R25
0048 2080 ldd R2,z+0
004A 2220 tst R2
004C 59F4 brne L4
004E .dbline 49
004E .dbline 50
004E ; OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
004E E0910000 lds R30,_OSTCBCur
0052 F0910100 lds R31,_OSTCBCur+1
0056 2088 ldd R2,z+16
0058 2094 com R2
005A 30900000 lds R3,_OSRdyGrp
005E 3220 and R3,R2
0060 30920000 sts _OSRdyGrp,R3
0064 .dbline 51
0064 ; }
0064 L4:
0064 .dbline 52
0064 E0910000 lds R30,_OSTCBCur
0068 F0910100 lds R31,_OSTCBCur+1
006C 7187 std z+9,R23
006E 6087 std z+8,R22
0070 .dbline 53
0070 042F mov R16,R20
0072 0E940000 xcall _OS_CPU_SR_Restore
0076 .dbline 54
0076 0E940000 xcall _OS_Sched
007A .dbline 55
007A L2:
007A .dbline -2
007A L1:
007A 0E940000 xcall pop_gset3
007E .dbline 0 ; func end
007E 0895 ret
0080 .dbsym r y 10 c
0080 .dbsym r cpu_sr 20 c
0080 .dbsym r ticks 22 i
0080 .dbend
0080 .dbfunc e OSTimeDlyHMSM _OSTimeDlyHMSM fc
0080 ; ticks -> y+0
0080 ; loops -> R10,R11
0080 ; milli -> y+14
0080 ; seconds -> y+12
0080 ; minutes -> R12
0080 ; hours -> R10
.even
0080 _OSTimeDlyHMSM::
0080 0E940000 xcall push_gset4
0084 C22E mov R12,R18
0086 A02E mov R10,R16
0088 2497 sbiw R28,4
008A .dbline -1
008A .dbline 85
008A ; OSTCBCur->OSTCBDly = ticks; /* Load ticks in TCB */
008A ; OS_EXIT_CRITICAL();
008A ; OS_Sched(); /* Find next task to run! */
008A ; }
008A ; }
008A ; /*$PAGE*/
008A ; /*
008A ; *********************************************************************************************************
008A ; * DELAY TASK FOR SPECIFIED TIME
008A ; *
008A ; * Description: This function is called to delay execution of the currently running task until some time
008A ; * expires. This call allows you to specify the delay time in HOURS, MINUTES, SECONDS and
008A ; * MILLISECONDS instead of ticks.
008A ; *
008A ; * Arguments : hours specifies the number of hours that the task will be delayed (max. is 255)
008A ; * minutes specifies the number of minutes (max. 59)
008A ; * seconds specifies the number of seconds (max. 59)
008A ; * milli specifies the number of milliseconds (max. 999)
008A ; *
008A ; * Returns : OS_NO_ERR
008A ; * OS_TIME_INVALID_MINUTES
008A ; * OS_TIME_INVALID_SECONDS
008A ; * OS_TIME_INVALID_MS
008A ; * OS_TIME_ZERO_DLY
008A ; *
008A ; * Note(s) : The resolution on the milliseconds depends on the tick rate. For example, you can't do
008A ; * a 10 mS delay if the ticker interrupts every 100 mS. In this case, the delay would be
008A ; * set to 0. The actual delay is rounded to the nearest tick.
008A ; *********************************************************************************************************
008A ; */
008A ;
008A ; #if OS_TIME_DLY_HMSM_EN > 0
008A ; INT8U OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U seconds, INT16U milli)
008A ; {
008A .dbline 112
008A ; INT32U ticks;
008A ; INT16U loops;
008A ;
008A ;
008A ; #if OS_ARG_CHK_EN > 0
008A ; if (hours == 0) {
008A ; if (minutes == 0) {
008A ; if (seconds == 0) {
008A ; if (milli == 0) {
008A ; return (OS_TIME_ZERO_DLY);
008A ; }
008A ; }
008A ; }
008A ; }
008A ; if (minutes > 59) {
008A ; return (OS_TIME_INVALID_MINUTES); /* Validate arguments to be within range */
008A ; }
008A ; if (seconds > 59) {
008A ; return (OS_TIME_INVALID_SECONDS);
008A ; }
008A ; if (milli > 999) {
008A ; return (OS_TIME_INVALID_MILLI);
008A ; }
008A ; #endif
008A ; /* Compute the total number of clock ticks required.. */
008A ; /* .. (rounded to the nearest tick) */
008A ; ticks = ((INT32U)hours * 3600L + (INT32U)minutes * 60L + (INT32U)seconds) * OS_TICKS_PER_SEC
008A 2C2C mov R2,R12
008C 3324 clr R3
008E 4424 clr R4
0090 5524 clr R5
0092 4CE3 ldi R20,60
0094 50E0 ldi R21,0
0096 60E0 ldi R22,0
0098 70E0 ldi R23,0
009A 5A92 st -y,R5
009C 4A92 st -y,R4
009E 3A92 st -y,R3
00A0 2A92 st -y,R2
00A2 8A01 movw R16,R20
00A4 9B01 movw R18,R22
00A6 0E940000 xcall empy32u
00AA 1801 movw R2,R16
00AC 2901 movw R4,R18
00AE 6A2C mov R6,R10
00B0 7724 clr R7
00B2 8824 clr R8
00B4 9924 clr R9
00B6 40E1 ldi R20,16
00B8 5EE0 ldi R21,14
00BA 60E0 ldi R22,0
00BC 70E0 ldi R23,0
00BE 9A92 st -y,R9
00C0 8A92 st -y,R8
00C2 7A92 st -y,R7
00C4 6A92 st -y,R6
00C6 8A01 movw R16,R20
00C8 9B01 movw R18,R22
00CA 0E940000 xcall empy32u
00CE 3801 movw R6,R16
00D0 4901 movw R8,R18
00D2 620C add R6,R2
00D4 731C adc R7,R3
00D6 841C adc R8,R4
00D8 951C adc R9,R5
00DA 2C84 ldd R2,y+12
00DC 3324 clr R3
00DE 4424 clr R4
00E0 5524 clr R5
00E2 620C add R6,R2
00E4 731C adc R7,R3
00E6 841C adc R8,R4
00E8 951C adc R9,R5
00EA 42E3 ldi R20,50
00EC 50E0 ldi R21,0
00EE 60E0 ldi R22,0
00F0 70E0 ldi R23,0
00F2 9A92 st -y,R9
00F4 8A92 st -y,R8
00F6 7A92 st -y,R7
00F8 6A92 st -y,R6
00FA 8A01 movw R16,R20
00FC 9B01 movw R18,R22
00FE 0E940000 xcall empy32u
0102 1801 movw R2,R16
0104 2901 movw R4,R18
0106 4AE0 ldi R20,10
0108 50E0 ldi R21,0
010A 60E0 ldi R22,0
010C 70E0 ldi R23,0
010E 6E84 ldd R6,y+14
0110 7F84 ldd R7,y+15
0112 8824 clr R8
0114 9924 clr R9
0116 640E add R6,R20
0118 751E adc R7,R21
011A 861E adc R8,R22
011C 971E adc R9,R23
011E 42E3 ldi R20,50
0120 50E0 ldi R21,0
0122 60E0 ldi R22,0
0124 70E0 ldi R23,0
0126 9A92 st -y,R9
0128 8A92 st -y,R8
012A 7A92 st -y,R7
012C 6A92 st -y,R6
012E 8A01 movw R16,R20
0130 9B01 movw R18,R22
0132 0E940000 xcall empy32u
0136 48EE ldi R20,232
0138 53E0 ldi R21,3
013A 60E0 ldi R22,0
013C 70E0 ldi R23,0
013E 7A93 st -y,R23
0140 6A93 st -y,R22
0142 5A93 st -y,R21
0144 4A93 st -y,R20
0146 0E940000 xcall div32u
014A 200E add R2,R16
014C 311E adc R3,R17
014E 421E adc R4,R18
0150 531E adc R5,R19
0152 FE01 movw R30,R28
0154 2082 std z+0,R2
0156 3182 std z+1,R3
0158 4282 std z+2,R4
015A 5382 std z+3,R5
015C .dbline 114
015C ; + OS_TICKS_PER_SEC * ((INT32U)milli + 500L / OS_TICKS_PER_SEC) / 1000L;
015C ; loops = (INT16U)(ticks / 65536L); /* Compute the integral number of 65536 tick delays */
015C FE01 movw R30,R28
015E 2080 ldd R2,z+0
0160 3180 ldd R3,z+1
0162 4280 ldd R4,z+2
0164 5380 ldd R5,z+3
0166 5201 movw R10,R4
0168 .dbline 115
0168 ; ticks = ticks % 65536L; /* Obtain the fractional number of ticks */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?