os_time.s

来自「将本站的UCOSFORAVR128V276版本升级到了280版」· S 代码 · 共 648 行 · 第 1/2 页

S
648
字号
	.module os_time.c
	.area text(rom, con, rel)
	.dbfile E:\ypt050912\XIAZAI\xinzai\UCOSAVR128\Source\os_time.c
	.dbfunc e OSTimeDly _OSTimeDly fV
;              y -> R10
;         cpu_sr -> R20
;          ticks -> R22,R23
	.even
_OSTimeDly::
	xcall push_gset3
	movw R22,R16
	.dbline -1
	.dbline 37
; /*
; *********************************************************************************************************
; *                                                uC/OS-II
; *                                          The Real-Time Kernel
; *                                             TIME MANAGEMENT
; *
; *                          (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
; *                                           All Rights Reserved
; *
; * File    : OS_TIME.C
; * By      : Jean J. Labrosse
; * Version : V2.80
; *********************************************************************************************************
; */
; 
; #ifndef  OS_MASTER_FILE
; #include <ucos_ii.h>
; #endif
; 
; /*
; *********************************************************************************************************
; *                                DELAY TASK 'n' TICKS   (n from 0 to 65535)
; *
; * Description: This function is called to delay execution of the currently running task until the
; *              specified number of system ticks expires.  This, of course, directly equates to delaying
; *              the current task for some time to expire.  No delay will result If the specified delay is
; *              0.  If the specified delay is greater than 0 then, a context switch will result.
; *
; * Arguments  : ticks     is the time delay that the task will be suspended in number of clock 'ticks'.
; *                        Note that by specifying 0, the task will not be delayed.
; *
; * Returns    : none
; *********************************************************************************************************
; */
; 
; void  OSTimeDly (INT16U ticks)
; {
	.dbline 40
;     INT8U      y;
; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;     OS_CPU_SR  cpu_sr = 0;
	clr R20
	.dbline 45
; #endif
; 
; 
; 
;     if (ticks > 0) {                             /* 0 means no delay!                                  */
	cpi R22,0
	cpc R22,R23
	brne X1
	xjmp L2
X1:
X0:
	.dbline 45
	.dbline 46
;         OS_ENTER_CRITICAL();
	xcall _OS_CPU_SR_Save
	mov R20,R16
	.dbline 47
;         y            =  OSTCBCur->OSTCBY;        /* Delay current task                                 */
	lds R30,_OSTCBCur
	lds R31,_OSTCBCur+1
	ldd R10,z+14
	.dbline 48
;         OSRdyTbl[y] &= ~OSTCBCur->OSTCBBitX;
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	mov R2,R10
	clr R3
	add R2,R24
	adc R3,R25
	lds R30,_OSTCBCur
	lds R31,_OSTCBCur+1
	ldd R4,z+15
	com R4
	movw R30,R2
	ldd R5,z+0
	and R5,R4
	std z+0,R5
	.dbline 49
;         if (OSRdyTbl[y] == 0) {
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	tst R2
	brne L4
	.dbline 49
	.dbline 50
;             OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
	lds R30,_OSTCBCur
	lds R31,_OSTCBCur+1
	ldd R2,z+16
	com R2
	lds R3,_OSRdyGrp
	and R3,R2
	sts _OSRdyGrp,R3
	.dbline 51
;         }
L4:
	.dbline 52
	lds R30,_OSTCBCur
	lds R31,_OSTCBCur+1
	std z+9,R23
	std z+8,R22
	.dbline 53
	mov R16,R20
	xcall _OS_CPU_SR_Restore
	.dbline 54
	xcall _OS_Sched
	.dbline 55
L2:
	.dbline -2
L1:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r y 10 c
	.dbsym r cpu_sr 20 c
	.dbsym r ticks 22 i
	.dbend
	.dbfunc e OSTimeDlyHMSM _OSTimeDlyHMSM fc
;          ticks -> y+0
;          loops -> R10,R11
;          milli -> y+14
;        seconds -> y+12
;        minutes -> R12
;          hours -> R10
	.even
_OSTimeDlyHMSM::
	xcall push_gset4
	mov R12,R18
	mov R10,R16
	sbiw R28,4
	.dbline -1
	.dbline 85
;         OSTCBCur->OSTCBDly = ticks;              /* Load ticks in TCB                                  */
;         OS_EXIT_CRITICAL();
;         OS_Sched();                              /* Find next task to run!                             */
;     }
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                     DELAY TASK FOR SPECIFIED TIME
; *
; * Description: This function is called to delay execution of the currently running task until some time
; *              expires.  This call allows you to specify the delay time in HOURS, MINUTES, SECONDS and
; *              MILLISECONDS instead of ticks.
; *
; * Arguments  : hours     specifies the number of hours that the task will be delayed (max. is 255)
; *              minutes   specifies the number of minutes (max. 59)
; *              seconds   specifies the number of seconds (max. 59)
; *              milli     specifies the number of milliseconds (max. 999)
; *
; * Returns    : OS_NO_ERR
; *              OS_TIME_INVALID_MINUTES
; *              OS_TIME_INVALID_SECONDS
; *              OS_TIME_INVALID_MS
; *              OS_TIME_ZERO_DLY
; *
; * Note(s)    : The resolution on the milliseconds depends on the tick rate.  For example, you can't do
; *              a 10 mS delay if the ticker interrupts every 100 mS.  In this case, the delay would be
; *              set to 0.  The actual delay is rounded to the nearest tick.
; *********************************************************************************************************
; */
; 
; #if OS_TIME_DLY_HMSM_EN > 0
; INT8U  OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U seconds, INT16U milli)
; {
	.dbline 112
;     INT32U ticks;
;     INT16U loops;
; 
; 
; #if OS_ARG_CHK_EN > 0
;     if (hours == 0) {
;         if (minutes == 0) {
;             if (seconds == 0) {
;                 if (milli == 0) {
;                     return (OS_TIME_ZERO_DLY);
;                 }
;             }
;         }
;     }
;     if (minutes > 59) {
;         return (OS_TIME_INVALID_MINUTES);        /* Validate arguments to be within range              */
;     }
;     if (seconds > 59) {
;         return (OS_TIME_INVALID_SECONDS);
;     }
;     if (milli > 999) {
;         return (OS_TIME_INVALID_MILLI);
;     }
; #endif
;                                                  /* Compute the total number of clock ticks required.. */
;                                                  /* .. (rounded to the nearest tick)                   */
;     ticks = ((INT32U)hours * 3600L + (INT32U)minutes * 60L + (INT32U)seconds) * OS_TICKS_PER_SEC
	mov R2,R12
	clr R3
	clr R4
	clr R5
	ldi R20,60
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R2,R16
	movw R4,R18
	mov R6,R10
	clr R7
	clr R8
	clr R9
	ldi R20,16
	ldi R21,14
	ldi R22,0
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R6,R16
	movw R8,R18
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	ldd R2,y+12
	clr R3
	clr R4
	clr R5
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	ldi R20,50
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R2,R16
	movw R4,R18
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R6,y+14
	ldd R7,y+15
	clr R8
	clr R9
	add R6,R20
	adc R7,R21
	adc R8,R22
	adc R9,R23
	ldi R20,50
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	ldi R20,232
	ldi R21,3
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall div32u
	add R2,R16
	adc R3,R17
	adc R4,R18
	adc R5,R19
	movw R30,R28
	std z+0,R2
	std z+1,R3
	std z+2,R4
	std z+3,R5
	.dbline 114
;           + OS_TICKS_PER_SEC * ((INT32U)milli + 500L / OS_TICKS_PER_SEC) / 1000L;
;     loops = (INT16U)(ticks / 65536L);            /* Compute the integral number of 65536 tick delays   */
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	movw R10,R4
	.dbline 115
;     ticks = ticks % 65536L;                      /* Obtain  the fractional number of ticks             */

⌨️ 快捷键说明

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