📄 os_time.s
字号:
ldi R16,32768
ldi R17,128
rcall _OSTimeDly
.dbline 104
ldi R16,32768
ldi R17,128
rcall _OSTimeDly
.dbline 105
movw R24,R10
sbiw R24,1
movw R10,R24
.dbline 106
L21:
.dbline 102
; while (loops > 0) {
tst R10
brne L20
tst R11
brne L20
X3:
.dbline 107
; OSTimeDly(32768);
; OSTimeDly(32768);
; loops--;
; }
; return (OS_NO_ERR);
clr R16
rjmp L8
L9:
.dbline 109
; }
; return (OS_TIME_ZERO_DLY);
ldi R16,84
.dbline -2
L8:
adiw R28,4
rcall pop_gset4
.dbline 0 ; func end
ret
.dbsym l ticks 0 l
.dbsym r loops 10 i
.dbsym l milli 14 i
.dbsym l seconds 12 c
.dbsym r minutes 12 c
.dbsym r hours 10 c
.dbend
.dbfunc e OSTimeDlyResume _OSTimeDlyResume fc
.dbstruct 0 9 .1
.dbfield 0 OSEventType c
.dbfield 1 OSEventGrp c
.dbfield 2 OSEventCnt i
.dbfield 4 OSEventPtr pV
.dbfield 6 OSEventTbl A[3:3]c
.dbend
.dbstruct 0 16 os_tcb
.dbfield 0 OSTCBStkPtr pc
.dbfield 2 OSTCBNext pS[os_tcb]
.dbfield 4 OSTCBPrev pS[os_tcb]
.dbfield 6 OSTCBEventPtr pS[.1]
.dbfield 8 OSTCBDly i
.dbfield 10 OSTCBStat c
.dbfield 11 OSTCBPrio c
.dbfield 12 OSTCBX c
.dbfield 13 OSTCBY c
.dbfield 14 OSTCBBitX c
.dbfield 15 OSTCBBitY c
.dbend
; cpu_sr -> R20
; ptcb -> R22,R23
; prio -> R22
.even
_OSTimeDlyResume::
rcall push_gset2
mov R22,R16
.dbline -1
.dbline 139
; }
; #endif
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * RESUME A DELAYED TASK
; *
; * Description: This function is used resume a task that has been delayed through a call to either
; * OSTimeDly() or OSTimeDlyHMSM(). Note that you MUST NOT call this function to resume a
; * task that is waiting for an event with timeout. This situation would make the task look
; * like a timeout occurred (unless you desire this effect). Also, you cannot resume a task
; * that has called OSTimeDlyHMSM() with a combined time that exceeds 65535 clock ticks. In
; * other words, if the clock tick runs at 100 Hz then, you will not be able to resume a
; * delayed task that called OSTimeDlyHMSM(0, 10, 55, 350) or higher.
; *
; * (10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second.
; *
; * Arguments : prio specifies the priority of the task to resume
; *
; * Returns : OS_NO_ERR Task has been resumed
; * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
; * (i.e. >= OS_LOWEST_PRIO)
; * OS_TIME_NOT_DLY Task is not waiting for time to expire
; * OS_TASK_NOT_EXIST The desired task has not been created
; *********************************************************************************************************
; */
;
; #if OS_TIME_DLY_RESUME_EN > 0
; INT8U OSTimeDlyResume (INT8U prio)
; {
.dbline 146
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
; OS_TCB *ptcb;
;
;
; if (prio >= OS_LOWEST_PRIO) {
cpi R22,20
brlo L24
.dbline 146
.dbline 147
; return (OS_PRIO_INVALID);
ldi R16,42
rjmp L23
L24:
.dbline 149
; }
; OS_ENTER_CRITICAL();
rcall _OS_CPU_SR_Save
mov R20,R16
.dbline 150
; ptcb = (OS_TCB *)OSTCBPrioTbl[prio]; /* Make sure that task exist */
ldi R24,2
mul R24,R22
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
ldd R22,z+0
ldd R23,z+1
.dbline 151
; if (ptcb != (OS_TCB *)0) {
cpi R22,0
cpc R22,R23
brne X7
rjmp L26
X7:
X5:
.dbline 151
.dbline 152
; if (ptcb->OSTCBDly != 0) { /* See if task is delayed */
movw R30,R22
ldd R2,z+8
ldd R3,z+9
tst R2
brne X6
tst R3
brne X8
rjmp L28
X8:
X6:
.dbline 152
.dbline 153
; ptcb->OSTCBDly = 0; /* Clear the time delay */
clr R2
clr R3
movw R30,R22
std z+9,R3
std z+8,R2
.dbline 154
; if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == 0x00) { /* See if task is ready to run */
movw R30,R22
ldd R2,z+10
sbrc R2,3
rjmp L30
.dbline 154
.dbline 155
; OSRdyGrp |= ptcb->OSTCBBitY; /* Make task ready to run */
movw R30,R22
ldd R2,z+15
lds R3,_OSRdyGrp
or R3,R2
sts _OSRdyGrp,R3
.dbline 156
; OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
ldi R24,<_OSRdyTbl
ldi R25,>_OSRdyTbl
movw R30,R22
ldd R2,z+13
clr R3
add R2,R24
adc R3,R25
movw R30,R22
ldd R4,z+14
movw R30,R2
ldd R5,z+0
or R5,R4
std z+0,R5
.dbline 157
; OS_EXIT_CRITICAL();
mov R16,R20
rcall _OS_CPU_SR_Restore
.dbline 158
; OS_Sched(); /* See if this is new highest priority */
rcall _OS_Sched
.dbline 159
rjmp L31
L30:
.dbline 159
; } else {
.dbline 160
; OS_EXIT_CRITICAL(); /* Task may be suspended */
mov R16,R20
rcall _OS_CPU_SR_Restore
.dbline 161
; }
L31:
.dbline 162
; return (OS_NO_ERR);
clr R16
rjmp L23
L28:
.dbline 163
; } else {
.dbline 164
; OS_EXIT_CRITICAL();
mov R16,R20
rcall _OS_CPU_SR_Restore
.dbline 165
; return (OS_TIME_NOT_DLY); /* Indicate that task was not delayed */
ldi R16,80
rjmp L23
L26:
.dbline 168
; }
; }
; OS_EXIT_CRITICAL();
mov R16,R20
rcall _OS_CPU_SR_Restore
.dbline 169
; return (OS_TASK_NOT_EXIST); /* The task does not exist */
ldi R16,11
.dbline -2
L23:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r cpu_sr 20 c
.dbsym r ptcb 22 pS[os_tcb]
.dbsym r prio 22 c
.dbend
.dbfunc e OSTimeGet _OSTimeGet fl
; ticks -> y+0
; cpu_sr -> R20
.even
_OSTimeGet::
rcall push_gset1
sbiw R28,4
.dbline -1
.dbline 188
; }
; #endif
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * GET CURRENT SYSTEM TIME
; *
; * Description: This function is used by your application to obtain the current value of the 32-bit
; * counter which keeps track of the number of clock ticks.
; *
; * Arguments : none
; *
; * Returns : The current value of OSTime
; *********************************************************************************************************
; */
;
; #if OS_TIME_GET_SET_EN > 0
; INT32U OSTimeGet (void)
; {
.dbline 195
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
; INT32U ticks;
;
;
; OS_ENTER_CRITICAL();
rcall _OS_CPU_SR_Save
mov R20,R16
.dbline 196
; ticks = OSTime;
lds R4,_OSTime+2
lds R5,_OSTime+2+1
lds R2,_OSTime
lds R3,_OSTime+1
movw R30,R28
std z+0,R2
std z+1,R3
std z+2,R4
std z+3,R5
.dbline 197
; OS_EXIT_CRITICAL();
rcall _OS_CPU_SR_Restore
.dbline 198
; return (ticks);
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
.dbline -2
L32:
adiw R28,4
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym l ticks 0 l
.dbsym r cpu_sr 20 c
.dbend
.dbfunc e OSTimeSet _OSTimeSet fV
; cpu_sr -> R20
; ticks -> y+2
.even
_OSTimeSet::
rcall push_arg4
rcall push_gset1
.dbline -1
.dbline 216
; }
; #endif
;
; /*
; *********************************************************************************************************
; * SET SYSTEM CLOCK
; *
; * Description: This function sets the 32-bit counter which keeps track of the number of clock ticks.
; *
; * Arguments : ticks specifies the new value that OSTime needs to take.
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; #if OS_TIME_GET_SET_EN > 0
; void OSTimeSet (INT32U ticks)
; {
.dbline 222
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
;
; OS_ENTER_CRITICAL();
rcall _OS_CPU_SR_Save
mov R20,R16
.dbline 223
; OSTime = ticks;
movw R30,R28
ldd R2,z+2
ldd R3,z+3
ldd R4,z+4
ldd R5,z+5
sts _OSTime+1,R3
sts _OSTime,R2
sts _OSTime+2+1,R5
sts _OSTime+2,R4
.dbline 224
; OS_EXIT_CRITICAL();
rcall _OS_CPU_SR_Restore
.dbline -2
L33:
rcall pop_gset1
adiw R28,4
.dbline 0 ; func end
ret
.dbsym r cpu_sr 20 c
.dbsym l ticks 2 l
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -