📄 dynamic.lst
字号:
158 * Just loops around incrementing the shared variable until the limit has been
159 * reached. Once the limit has been reached it suspends itself.
160 */
\ In segment CODE, align 2
161 static portTASK_FUNCTION( vLimitedIncrementTask, pvParameters )
\ vLimitedIncrementTask:
162 {
\ 000000 0A12 PUSH.W R10
\ 000002 0B12 PUSH.W R11
\ 000004 0A4C MOV.W R12, R10
163 unsigned portLONG *pulCounter;
164
165 /* Take a pointer to the shared variable from the parameters passed into
166 the task. */
167 pulCounter = ( unsigned portLONG * ) pvParameters;
\ 000006 0B4A MOV.W R10, R11
168
169 /* This will run before the control task, so the first thing it does is
170 suspend - the control task will resume it when ready. */
171 vTaskSuspend( NULL );
\ 000008 0C43 MOV.W #0x0, R12
\ 00000A B012.... CALL #vTaskSuspend
172
173 for( ;; )
174 {
175 /* Just count up to a value then suspend. */
176 ( *pulCounter )++;
\ ??vLimitedIncrementTask_0:
\ 00000E 0F4B MOV.W R11, R15
\ 000010 9F530000 ADD.W #0x1, 0(R15)
\ 000014 8F630200 ADDC.W #0x0, 0x2(R15)
177
178 if( *pulCounter >= priMAX_COUNT )
\ 000018 8B930200 CMP.W #0x0, 0x2(R11)
\ 00001C F82B JNC ??vLimitedIncrementTask_0
\ 00001E 0420 JNE ??vLimitedIncrementTask_1
\ 000020 BB90FF000000 CMP.W #0xff, 0x0(R11)
\ 000026 F32B JNC ??vLimitedIncrementTask_0
179 {
180 vTaskSuspend( NULL );
\ ??vLimitedIncrementTask_1:
\ 000028 0C43 MOV.W #0x0, R12
\ 00002A B012.... CALL #vTaskSuspend
\ 00002E EF3F JMP ??vLimitedIncrementTask_0
181 }
182 }
183 }
184 /*-----------------------------------------------------------*/
185
186 /*
187 * Just keep counting the shared variable up. The control task will suspend
188 * this task when it wants.
189 */
\ In segment CODE, align 2
190 static portTASK_FUNCTION( vContinuousIncrementTask, pvParameters )
\ vContinuousIncrementTask:
191 {
\ 000000 0A12 PUSH.W R10
\ 000002 0B12 PUSH.W R11
\ 000004 0812 PUSH.W R8
\ 000006 0A4C MOV.W R12, R10
192 unsigned portLONG *pulCounter;
193 unsigned portBASE_TYPE uxOurPriority;
194
195 /* Take a pointer to the shared variable from the parameters passed into
196 the task. */
197 pulCounter = ( unsigned portLONG * ) pvParameters;
\ 000008 0B4A MOV.W R10, R11
198
199 /* Query our priority so we can raise it when exclusive access to the
200 shared variable is required. */
201 uxOurPriority = uxTaskPriorityGet( NULL );
\ 00000A 0C43 MOV.W #0x0, R12
\ 00000C B012.... CALL #uxTaskPriorityGet
\ 000010 084C MOV.W R12, R8
202
203 for( ;; )
204 {
205 /* Raise our priority above the controller task to ensure a context
206 switch does not occur while we are accessing this variable. */
207 vTaskPrioritySet( NULL, uxOurPriority + 1 );
\ ??vContinuousIncrementTask_0:
\ 000012 0E48 MOV.W R8, R14
\ 000014 1E53 ADD.W #0x1, R14
\ 000016 0C43 MOV.W #0x0, R12
\ 000018 B012.... CALL #vTaskPrioritySet
208 ( *pulCounter )++;
\ 00001C 0F4B MOV.W R11, R15
\ 00001E 9F530000 ADD.W #0x1, 0(R15)
\ 000022 8F630200 ADDC.W #0x0, 0x2(R15)
209 vTaskPrioritySet( NULL, uxOurPriority );
\ 000026 0E48 MOV.W R8, R14
\ 000028 0C43 MOV.W #0x0, R12
\ 00002A B012.... CALL #vTaskPrioritySet
\ 00002E F13F JMP ??vContinuousIncrementTask_0
210 }
211 }
212 /*-----------------------------------------------------------*/
213
214 /*
215 * Controller task as described above.
216 */
\ In segment CODE, align 2
217 static portTASK_FUNCTION( vCounterControlTask, pvParameters )
\ vCounterControlTask:
218 {
\ 000000 0A12 PUSH.W R10
\ 000002 0B12 PUSH.W R11
\ 000004 0812 PUSH.W R8
\ 000006 0912 PUSH.W R9
\ 000008 0612 PUSH.W R6
\ 00000A 084C MOV.W R12, R8
219 unsigned portLONG ulLastCounter;
220 portSHORT sLoops;
221 portSHORT sError = pdFALSE;
\ 00000C 0643 MOV.W #0x0, R6
222
223 /* Just to stop warning messages. */
224 ( void ) pvParameters;
225
226 for( ;; )
227 {
228 /* Start with the counter at zero. */
229 ulCounter = ( unsigned portLONG ) 0;
\ ??vCounterControlTask_1:
\ 00000E 8243.... MOV.W #0x0, &ulCounter
\ 000012 8243.... MOV.W #0x0, &ulCounter + 2
230
231 /* First section : */
232
233 /* Check the continuous count task is running. */
234 for( sLoops = 0; sLoops < priLOOPS; sLoops++ )
\ 000016 0943 MOV.W #0x0, R9
\ ??vCounterControlTask_0:
\ 000018 39900500 CMP.W #0x5, R9
\ 00001C 1D34 JGE ??vCounterControlTask_2
235 {
236 /* Suspend the continuous count task so we can take a mirror of the
237 shared variable without risk of corruption. */
238 vTaskSuspend( xContinousIncrementHandle );
\ 00001E 1C42.... MOV.W &xContinousIncrementHandle, R12
\ 000022 B012.... CALL #vTaskSuspend
239 ulLastCounter = ulCounter;
\ 000026 1A42.... MOV.W &ulCounter, R10
\ 00002A 1B42.... MOV.W &ulCounter + 2, R11
240 vTaskResume( xContinousIncrementHandle );
\ 00002E 1C42.... MOV.W &xContinousIncrementHandle, R12
\ 000032 B012.... CALL #vTaskResume
241
242 /* Now delay to ensure the other task has processor time. */
243 vTaskDelay( priSLEEP_TIME );
\ 000036 3C403200 MOV.W #0x32, R12
\ 00003A B012.... CALL #vTaskDelay
244
245 /* Check the shared variable again. This time to ensure mutual
246 exclusion the whole scheduler will be locked. This is just for
247 demo purposes! */
248 vTaskSuspendAll();
\ 00003E B012.... CALL #vTaskSuspendAll
249 {
250 if( ulLastCounter == ulCounter )
\ 000042 1A92.... CMP.W &ulCounter, R10
\ 000046 0420 JNE ??vCounterControlTask_3
\ 000048 1B92.... CMP.W &ulCounter + 2, R11
\ 00004C 0120 JNE ??vCounterControlTask_3
251 {
252 /* The shared variable has not changed. There is a problem
253 with the continuous count task so flag an error. */
254 sError = pdTRUE;
\ 00004E 1643 MOV.W #0x1, R6
255 }
256 }
257 xTaskResumeAll();
\ ??vCounterControlTask_3:
\ 000050 B012.... CALL #xTaskResumeAll
258 }
\ 000054 1953 ADD.W #0x1, R9
\ 000056 E03F JMP ??vCounterControlTask_0
259
260
261 /* Second section: */
262
263 /* Suspend the continuous counter task so it stops accessing the shared variable. */
264 vTaskSuspend( xContinousIncrementHandle );
\ ??vCounterControlTask_2:
\ 000058 1C42.... MOV.W &xContinousIncrementHandle, R12
\ 00005C B012.... CALL #vTaskSuspend
265
266 /* Reset the variable. */
267 ulCounter = ( unsigned portLONG ) 0;
\ 000060 8243.... MOV.W #0x0, &ulCounter
\ 000064 8243.... MOV.W #0x0, &ulCounter + 2
268
269 /* Resume the limited count task which has a higher priority than us.
270 We should therefore not return from this call until the limited count
271 task has suspended itself with a known value in the counter variable. */
272 vTaskResume( xLimitedIncrementHandle );
\ 000068 1C42.... MOV.W &xLimitedIncrementHandle, R12
\ 00006C B012.... CALL #vTaskResume
273
274 /* Does the counter variable have the expected value? */
275 if( ulCounter != priMAX_COUNT )
\ 000070 B290FF00.... CMP.W #0xff, &ulCounter
\ 000076 0320 JNE ??vCounterControlTask_4
\ 000078 8293.... CMP.W #0x0, &ulCounter + 2
\ 00007C 0124 JEQ ??vCounterControlTask_5
276 {
277 sError = pdTRUE;
\ ??vCounterControlTask_4:
\ 00007E 1643 MOV.W #0x1, R6
278 }
279
280 if( sError == pdFALSE )
\ ??vCounterControlTask_5:
\ 000080 0693 CMP.W #0x0, R6
\ 000082 0F20 JNE ??vCounterControlTask_6
281 {
282 /* If no errors have occurred then increment the check variable. */
283 portENTER_CRITICAL();
\ 000084 32C2 DINT
\ 000086 0343 NOP
\ 000088 9253.... ADD.W #0x1, &usCriticalNesting
284 usCheckVariable++;
\ 00008C 9253.... ADD.W #0x1, &usCheckVariable
285 portEXIT_CRITICAL();
\ 000090 8293.... CMP.W #0x0, &usCriticalNesting
\ 000094 0624 JEQ ??vCounterControlTask_6
\ 000096 B253.... ADD.W #0xffff, &usCriticalNesting
\ 00009A 8293.... CMP.W #0x0, &usCriticalNesting
\ 00009E 0120 JNE ??vCounterControlTask_6
\ 0000A0 32D2 EINT
286 }
287
288 /* Resume the continuous count task and do it all again. */
289 vTaskResume( xContinousIncrementHandle );
\ ??vCounterControlTask_6:
\ 0000A2 1C42.... MOV.W &xContinousIncrementHandle, R12
\ 0000A6 B012.... CALL #vTaskResume
\ 0000AA B13F JMP ??vCounterControlTask_1
290 }
291 }
292 /*-----------------------------------------------------------*/
293
\ In segment CODE, align 2
294 static portTASK_FUNCTION( vQueueSendWhenSuspendedTask, pvParameters )
\ vQueueSendWhenSuspendedTask:
295 {
\ 000000 0A12 PUSH.W R10
\ 000002 0A4C MOV.W R12, R10
296 static unsigned portLONG ulValueToSend = ( unsigned portLONG ) 0;
297
298 /* Just to stop warning messages. */
299 ( void ) pvParameters;
300
301 for( ;; )
302 {
303 vTaskSuspendAll();
\ ??vQueueSendWhenSuspendedTask_0:
\ 000004 B012.... CALL #vTaskSuspendAll
304 {
305 /* We must not block while the scheduler is suspended! */
306 if( xQueueSend( xSuspendedTestQueue, ( void * ) &ulValueToSend, priNO_BLOCK ) != pdTRUE )
\ 000008 0312 PUSH.W #0x0
\ 00000A 3E40.... MOV.W #??ulValueToSend, R14
\ 00000E 1C42.... MOV.W &xSuspendedTestQueue, R12
\ 000012 B012.... CALL #xQueueSend
\ 000016 2153 ADD.W #0x2, SP
\ 000018 1C93 CMP.W #0x1, R12
\ 00001A 0224 JEQ ??vQueueSendWhenSuspendedTask_1
307 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -