📄 os_time.lst
字号:
88 *
89 * Note(s) : The resolution on the milliseconds depends on the tick rate. For example, you can't do
90 * a 10 mS delay if the ticker interrupts every 100 mS. In this case, the delay would be
91 * set to 0. The actual delay is rounded to the nearest tick.
92 *********************************************************************************************************
93 */
94
95 #if OS_TIME_DLY_HMSM_EN > 0
\ In segment CODE, align 4, keep-with-next
96 INT8U OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U seconds, INT16U ms)
97 {
\ OSTimeDlyHMSM:
\ 00000000 30B5 PUSH {R4,R5,LR}
98 INT32U ticks;
99 INT16U loops;
100
101
102 if (OSIntNesting > 0) { /* See if trying to call from an ISR */
\ 00000002 .... LDR.N R4,??DataTable3 ;; OSIntNesting
\ 00000004 2478 LDRB R4,[R4, #+0]
\ 00000006 002C CMP R4,#+0
\ 00000008 01D0 BEQ.N ??OSTimeDlyHMSM_0
103 return (OS_ERR_TIME_DLY_ISR);
\ 0000000A 5520 MOVS R0,#+85
\ 0000000C 30BD POP {R4,R5,PC}
104 }
105 #if OS_ARG_CHK_EN > 0
106 if (hours == 0) {
107 if (minutes == 0) {
108 if (seconds == 0) {
109 if (ms == 0) {
110 return (OS_ERR_TIME_ZERO_DLY);
111 }
112 }
113 }
114 }
115 if (minutes > 59) {
116 return (OS_ERR_TIME_INVALID_MINUTES); /* Validate arguments to be within range */
117 }
118 if (seconds > 59) {
119 return (OS_ERR_TIME_INVALID_SECONDS);
120 }
121 if (ms > 999) {
122 return (OS_ERR_TIME_INVALID_MS);
123 }
124 #endif
125 /* Compute the total number of clock ticks required.. */
126 /* .. (rounded to the nearest tick) */
127 ticks = ((INT32U)hours * 3600L + (INT32U)minutes * 60L + (INT32U)seconds) * OS_TICKS_PER_SEC
128 + OS_TICKS_PER_SEC * ((INT32U)ms + 500L / OS_TICKS_PER_SEC) / 1000L;
\ ??OSTimeDlyHMSM_0:
\ 0000000E 5FF46164 MOVS R4,#+3600
\ 00000012 3C25 MOVS R5,#+60
\ 00000014 6943 MULS R1,R5,R1
\ 00000016 00FB0410 MLA R0,R0,R4,R1
\ 0000001A 8018 ADDS R0,R0,R2
\ 0000001C 5FF47A71 MOVS R1,#+1000
\ 00000020 0A46 MOV R2,R1
\ 00000022 5343 MULS R3,R2,R3
\ 00000024 B3FBF2F2 UDIV R2,R3,R2
\ 00000028 00FB0120 MLA R0,R0,R1,R2
129 loops = (INT16U)(ticks >> 16); /* Compute the integral number of 65536 tick delays */
\ 0000002C 0400 MOVS R4,R0
\ 0000002E 240C LSRS R4,R4,#+16
130 ticks = ticks & 0xFFFFL; /* Obtain the fractional number of ticks */
131 OSTimeDly((INT16U)ticks);
\ 00000030 80B2 UXTH R0,R0
\ 00000032 ........ BL OSTimeDly
\ 00000036 09E0 B.N ??OSTimeDlyHMSM_1
132 while (loops > 0) {
133 OSTimeDly((INT16U)32768u);
\ ??OSTimeDlyHMSM_2:
\ 00000038 5FF40040 MOVS R0,#+32768
\ 0000003C ........ BL OSTimeDly
134 OSTimeDly((INT16U)32768u);
\ 00000040 5FF40040 MOVS R0,#+32768
\ 00000044 ........ BL OSTimeDly
135 loops--;
\ 00000048 641E SUBS R4,R4,#+1
\ 0000004A A4B2 UXTH R4,R4
136 }
\ ??OSTimeDlyHMSM_1:
\ 0000004C 2000 MOVS R0,R4
\ 0000004E F3D1 BNE.N ??OSTimeDlyHMSM_2
137 return (OS_ERR_NONE);
\ 00000050 0020 MOVS R0,#+0
\ 00000052 30BD POP {R4,R5,PC} ;; return
138 }
139 #endif
140 /*$PAGE*/
141 /*
142 *********************************************************************************************************
143 * RESUME A DELAYED TASK
144 *
145 * Description: This function is used resume a task that has been delayed through a call to either
146 * OSTimeDly() or OSTimeDlyHMSM(). Note that you can call this function to resume a
147 * task that is waiting for an event with timeout. This would make the task look
148 * like a timeout occurred.
149 *
150 * Also, you cannot resume a task that has called OSTimeDlyHMSM() with a combined time that
151 * exceeds 65535 clock ticks. In other words, if the clock tick runs at 100 Hz then, you will
152 * not be able to resume a delayed task that called OSTimeDlyHMSM(0, 10, 55, 350) or higher:
153 *
154 * (10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second.
155 *
156 * Arguments : prio specifies the priority of the task to resume
157 *
158 * Returns : OS_ERR_NONE Task has been resumed
159 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the maximum allowed
160 * (i.e. >= OS_LOWEST_PRIO)
161 * OS_ERR_TIME_NOT_DLY Task is not waiting for time to expire
162 * OS_ERR_TASK_NOT_EXIST The desired task has not been created or has been assigned to a Mutex.
163 *********************************************************************************************************
164 */
165
166 #if OS_TIME_DLY_RESUME_EN > 0
\ In segment CODE, align 4, keep-with-next
167 INT8U OSTimeDlyResume (INT8U prio)
168 {
\ OSTimeDlyResume:
\ 00000000 10B5 PUSH {R4,LR}
\ 00000002 0400 MOVS R4,R0
169 OS_TCB *ptcb;
170 #if OS_CRITICAL_METHOD == 3 /* Storage for CPU status register */
171 OS_CPU_SR cpu_sr = 0;
172 #endif
173
174
175
176 if (prio >= OS_LOWEST_PRIO) {
\ 00000004 1F2C CMP R4,#+31
\ 00000006 01D3 BCC.N ??OSTimeDlyResume_0
177 return (OS_ERR_PRIO_INVALID);
\ 00000008 2A20 MOVS R0,#+42
\ 0000000A 10BD POP {R4,PC}
178 }
179 OS_ENTER_CRITICAL();
\ ??OSTimeDlyResume_0:
\ 0000000C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
180 ptcb = OSTCBPrioTbl[prio]; /* Make sure that task exist */
\ 00000010 1C49 LDR.N R1,??OSTimeDlyResume_1 ;; OSTCBPrioTbl
\ 00000012 51F82410 LDR R1,[R1, R4, LSL #+2]
181 if (ptcb == (OS_TCB *)0) {
\ 00000016 0029 CMP R1,#+0
\ 00000018 03D1 BNE.N ??OSTimeDlyResume_2
182 OS_EXIT_CRITICAL();
\ ??OSTimeDlyResume_3:
\ 0000001A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
183 return (OS_ERR_TASK_NOT_EXIST); /* The task does not exist */
\ 0000001E 4320 MOVS R0,#+67
\ 00000020 10BD POP {R4,PC}
184 }
185 if (ptcb == OS_TCB_RESERVED) {
\ ??OSTimeDlyResume_2:
\ 00000022 0129 CMP R1,#+1
\ 00000024 F9D0 BEQ.N ??OSTimeDlyResume_3
186 OS_EXIT_CRITICAL();
187 return (OS_ERR_TASK_NOT_EXIST); /* The task does not exist */
188 }
189 if (ptcb->OSTCBDly == 0) { /* See if task is delayed */
\ 00000026 2E31 ADDS R1,R1,#+46
\ 00000028 0A88 LDRH R2,[R1, #+0]
\ 0000002A 002A CMP R2,#+0
\ 0000002C 03D1 BNE.N ??OSTimeDlyResume_4
190 OS_EXIT_CRITICAL();
\ 0000002E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
191 return (OS_ERR_TIME_NOT_DLY); /* Indicate that task was not delayed */
\ 00000032 5020 MOVS R0,#+80
\ 00000034 10BD POP {R4,PC}
192 }
193
194 ptcb->OSTCBDly = 0; /* Clear the time delay */
\ ??OSTimeDlyResume_4:
\ 00000036 0022 MOVS R2,#+0
\ 00000038 1300 MOVS R3,R2
\ 0000003A 0B80 STRH R3,[R1, #+0]
195 if ((ptcb->OSTCBStat & OS_STAT_PEND_ANY) != OS_STAT_RDY) {
\ 0000003C 8B78 LDRB R3,[R1, #+2]
\ 0000003E 13F0370F TST R3,#0x37
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -