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

📄 os_time.lis

📁 把UCOSII移植到AVR MEGA8上的程序 应用程序为驱动1602显示器,虽说有些简单,但可测试UCOS的运行
💻 LIS
📖 第 1 页 / 共 3 页
字号:
                        .module OS_TIME.c
                        .area text(rom, con, rel)
 0000                   .dbfile F:\AVRPRA~1\ucosii-port2-mega8\OS_TIME.c
 0000                   .dbfunc e OSTimeDly _OSTimeDly fV
 0000           ;         cpu_sr -> R20
 0000           ;          ticks -> R22,R23
                        .even
 0000           _OSTimeDly::
 0000 00D0              rcall push_gset2
 0002 B801              movw R22,R16
 0004                   .dbline -1
 0004                   .dbline 36
 0004           ; /*
 0004           ; *********************************************************************************************************
 0004           ; *                                                uC/OS-II
 0004           ; *                                          The Real-Time Kernel
 0004           ; *                                             TIME MANAGEMENT
 0004           ; *
 0004           ; *                          (c) Copyright 1992-2001, Jean J. Labrosse, Weston, FL
 0004           ; *                                           All Rights Reserved
 0004           ; *
 0004           ; * File : OS_TIME.C
 0004           ; * By   : Jean J. Labrosse
 0004           ; *********************************************************************************************************
 0004           ; */
 0004           ; 
 0004           ; #ifndef  OS_MASTER_FILE
 0004           ; #include "includes.h"
 0004           ; #endif
 0004           ; 
 0004           ; /*
 0004           ; *********************************************************************************************************
 0004           ; *                                DELAY TASK 'n' TICKS   (n from 0 to 65535)
 0004           ; *
 0004           ; * Description: This function is called to delay execution of the currently running task until the
 0004           ; *              specified number of system ticks expires.  This, of course, directly equates to delaying
 0004           ; *              the current task for some time to expire.  No delay will result If the specified delay is
 0004           ; *              0.  If the specified delay is greater than 0 then, a context switch will result.
 0004           ; *
 0004           ; * Arguments  : ticks     is the time delay that the task will be suspended in number of clock 'ticks'.
 0004           ; *                        Note that by specifying 0, the task will not be delayed.
 0004           ; *
 0004           ; * Returns    : none
 0004           ; *********************************************************************************************************
 0004           ; */
 0004           ; 
 0004           ; void  OSTimeDly (INT16U ticks)
 0004           ; {
 0004                   .dbline 42
 0004           ; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 0004           ;     OS_CPU_SR  cpu_sr;
 0004           ; #endif    
 0004           ; 
 0004           ; 
 0004           ;     if (ticks > 0) {                                                      /* 0 means no delay!         */
 0004 6030              cpi R22,0
 0006 6707              cpc R22,R23
 0008 09F4              brne X1
 000A 2DC0              rjmp L4
 000C           X1:
 000C           X0:
 000C                   .dbline 42
 000C                   .dbline 43
 000C           ;         OS_ENTER_CRITICAL();
 000C 00D0              rcall _OS_CPU_SR_Save
 000E 402F              mov R20,R16
 0010                   .dbline 44
 0010           ;         if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {  /* Delay current task        */
 0010 80E0              ldi R24,<_OSRdyTbl
 0012 90E0              ldi R25,>_OSRdyTbl
 0014 E0910000          lds R30,_OSTCBCur
 0018 F0910100          lds R31,_OSTCBCur+1
 001C 2584              ldd R2,z+13
 001E 3324              clr R3
 0020 280E              add R2,R24
 0022 391E              adc R3,R25
 0024 E0910000          lds R30,_OSTCBCur
 0028 F0910100          lds R31,_OSTCBCur+1
 002C 4684              ldd R4,z+14
 002E 4094              com R4
 0030 F101              movw R30,R2
 0032 5080              ldd R5,z+0
 0034 5420              and R5,R4
 0036 452C              mov R4,R5
 0038 4082              std z+0,R4
 003A 5520              tst R5
 003C 59F4              brne L6
 003E                   .dbline 44
 003E                   .dbline 45
 003E           ;             OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
 003E E0910000          lds R30,_OSTCBCur
 0042 F0910100          lds R31,_OSTCBCur+1
 0046 2784              ldd R2,z+15
 0048 2094              com R2
 004A 30900000          lds R3,_OSRdyGrp
 004E 3220              and R3,R2
 0050 30920000          sts _OSRdyGrp,R3
 0054                   .dbline 46
 0054           ;         }
 0054           L6:
 0054                   .dbline 47
 0054 E0910000          lds R30,_OSTCBCur
 0058 F0910100          lds R31,_OSTCBCur+1
 005C 7187              std z+9,R23
 005E 6087              std z+8,R22
 0060                   .dbline 48
 0060 042F              mov R16,R20
 0062 00D0              rcall _OS_CPU_SR_Restore
 0064                   .dbline 49
 0064 00D0              rcall _OS_Sched
 0066                   .dbline 50
 0066           L4:
 0066                   .dbline -2
 0066           L3:
 0066 00D0              rcall pop_gset2
 0068                   .dbline 0 ; func end
 0068 0895              ret
 006A                   .dbsym r cpu_sr 20 c
 006A                   .dbsym r ticks 22 i
 006A                   .dbend
 006A                   .dbfunc e OSTimeDlyHMSM _OSTimeDlyHMSM fc
 006A           ;          ticks -> y+0
 006A           ;          loops -> R10,R11
 006A           ;          milli -> y+14
 006A           ;        seconds -> y+12
 006A           ;        minutes -> R12
 006A           ;          hours -> R10
                        .even
 006A           _OSTimeDlyHMSM::
 006A 00D0              rcall push_gset4
 006C C22E              mov R12,R18
 006E A02E              mov R10,R16
 0070 2497              sbiw R28,4
 0072                   .dbline -1
 0072                   .dbline 80
 0072           ;         OSTCBCur->OSTCBDly = ticks;                                       /* Load ticks in TCB         */
 0072           ;         OS_EXIT_CRITICAL();
 0072           ;         OS_Sched();                                                       /* Find next task to run!    */
 0072           ;     }
 0072           ; }
 0072           ; /*$PAGE*/
 0072           ; /*
 0072           ; *********************************************************************************************************
 0072           ; *                                     DELAY TASK FOR SPECIFIED TIME
 0072           ; *
 0072           ; * Description: This function is called to delay execution of the currently running task until some time
 0072           ; *              expires.  This call allows you to specify the delay time in HOURS, MINUTES, SECONDS and
 0072           ; *              MILLISECONDS instead of ticks.
 0072           ; *
 0072           ; * Arguments  : hours     specifies the number of hours that the task will be delayed (max. is 255)
 0072           ; *              minutes   specifies the number of minutes (max. 59)
 0072           ; *              seconds   specifies the number of seconds (max. 59)
 0072           ; *              milli     specifies the number of milliseconds (max. 999)
 0072           ; *
 0072           ; * Returns    : OS_NO_ERR
 0072           ; *              OS_TIME_INVALID_MINUTES
 0072           ; *              OS_TIME_INVALID_SECONDS
 0072           ; *              OS_TIME_INVALID_MS
 0072           ; *              OS_TIME_ZERO_DLY
 0072           ; *
 0072           ; * Note(s)    : The resolution on the milliseconds depends on the tick rate.  For example, you can't do
 0072           ; *              a 10 mS delay if the ticker interrupts every 100 mS.  In this case, the delay would be
 0072           ; *              set to 0.  The actual delay is rounded to the nearest tick.
 0072           ; *********************************************************************************************************
 0072           ; */
 0072           ; 
 0072           ; #if OS_TIME_DLY_HMSM_EN > 0
 0072           ; INT8U  OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U seconds, INT16U milli)
 0072           ; {
 0072                   .dbline 85
 0072 2224              clr R2
 0074 2A14              cp R2,R10
 0076 60F0              brlo L13
 0078 2C14              cp R2,R12
 007A 50F0              brlo L13
 007C 0C84              ldd R0,y+12
 007E 2014              cp R2,R0
 0080 38F0              brlo L13
 0082 0E84              ldd R0,y+14
 0084 1F84              ldd R1,y+15
 0086 0020              tst R0
 0088 19F4              brne X2
 008A 1120              tst R1
 008C 09F4              brne X4
 008E A4C0              rjmp L9
 0090           X4:
 0090           X2:
 0090           L13:
 0090                   .dbline 85
 0090           ;     INT32U ticks;
 0090           ;     INT16U loops;
 0090           ; 
 0090           ; 
 0090           ;     if (hours > 0 || minutes > 0 || seconds > 0 || milli > 0) {
 0090                   .dbline 86
 0090           ;         if (minutes > 59) {
 0090 8BE3              ldi R24,59
 0092 8C15              cp R24,R12
 0094 10F4              brsh L14
 0096                   .dbline 86
 0096                   .dbline 87
 0096           ;             return (OS_TIME_INVALID_MINUTES);    /* Validate arguments to be within range              */
 0096 01E5              ldi R16,81
 0098 A0C0              rjmp L8
 009A           L14:
 009A                   .dbline 89
 009A           ;         }
 009A           ;         if (seconds > 59) {
 009A 8BE3              ldi R24,59
 009C 0C84              ldd R0,y+12
 009E 8015              cp R24,R0
 00A0 10F4              brsh L16
 00A2                   .dbline 89
 00A2                   .dbline 90
 00A2           ;             return (OS_TIME_INVALID_SECONDS);
 00A2 02E5              ldi R16,82
 00A4 9AC0              rjmp L8
 00A6           L16:
 00A6                   .dbline 92
 00A6           ;         }
 00A6           ;         if (milli > 999) {
 00A6 87EE              ldi R24,999
 00A8 93E0              ldi R25,3
 00AA 0E84              ldd R0,y+14
 00AC 1F84              ldd R1,y+15
 00AE 8015              cp R24,R0
 00B0 9105              cpc R25,R1
 00B2 10F4              brsh L18
 00B4                   .dbline 92
 00B4                   .dbline 93
 00B4           ;             return (OS_TIME_INVALID_MILLI);
 00B4 03E5              ldi R16,83
 00B6 91C0              rjmp L8
 00B8           L18:
 00B8                   .dbline 97
 00B8           ;         }
 00B8           ;                                                  /* Compute the total number of clock ticks required.. */
 00B8           ;                                                  /* .. (rounded to the nearest tick)                   */
 00B8           ;         ticks = ((INT32U)hours * 3600L + (INT32U)minutes * 60L + (INT32U)seconds) * OS_TICKS_PER_SEC
 00B8 2C2C              mov R2,R12
 00BA 3324              clr R3
 00BC 4424              clr R4
 00BE 5524              clr R5
 00C0 4CE3              ldi R20,60
 00C2 50E0              ldi R21,0
 00C4 60E0              ldi R22,0
 00C6 70E0              ldi R23,0
 00C8 5A92              st -y,R5
 00CA 4A92              st -y,R4
 00CC 3A92              st -y,R3
 00CE 2A92              st -y,R2
 00D0 8A01              movw R16,R20

⌨️ 快捷键说明

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