📄 os_task.lis
字号:
.even
01E2 _OSTaskCreate::
01E2 3A93 st -y,r19
01E4 2A93 st -y,r18
01E6 00D0 rcall push_gset5
01E8 6801 movw R12,R16
01EA 2C97 sbiw R28,12
01EC EA8C ldd R14,y+26
01EE .dbline -1
01EE .dbline 159
01EE ; }
01EE ; }
01EE ; }
01EE ; #endif
01EE ; /*$PAGE*/
01EE ; /*
01EE ; *********************************************************************************************************
01EE ; * CREATE A TASK
01EE ; *
01EE ; * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
01EE ; * be created prior to the start of multitasking or by a running task. A task cannot be
01EE ; * created by an ISR.
01EE ; *
01EE ; * Arguments : task is a pointer to the task's code
01EE ; *
01EE ; * pdata is a pointer to an optional data area which can be used to pass parameters to
01EE ; * the task when the task first executes. Where the task is concerned it thinks
01EE ; * it was invoked and passed the argument 'pdata' as follows:
01EE ; *
01EE ; * void Task (void *pdata)
01EE ; * {
01EE ; * for (;;) {
01EE ; * Task code;
01EE ; * }
01EE ; * }
01EE ; *
01EE ; * ptos is a pointer to the task's top of stack. If the configuration constant
01EE ; * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
01EE ; * memory to low memory). 'pstk' will thus point to the highest (valid) memory
01EE ; * location of the stack. If OS_STK_GROWTH is set to 0, 'pstk' will point to the
01EE ; * lowest memory location of the stack and the stack will grow with increasing
01EE ; * memory locations.
01EE ; *
01EE ; * prio is the task's priority. A unique priority MUST be assigned to each task and the
01EE ; * lower the number, the higher the priority.
01EE ; *
01EE ; * Returns : OS_NO_ERR if the function was successful.
01EE ; * OS_PRIO_EXIT if the task priority already exist
01EE ; * (each task MUST have a unique priority).
01EE ; * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
01EE ; * (i.e. >= OS_LOWEST_PRIO)
01EE ; *********************************************************************************************************
01EE ; */
01EE ;
01EE ; #if OS_TASK_CREATE_EN > 0
01EE ; INT8U OSTaskCreate (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio)
01EE ; {
01EE .dbline 172
01EE ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
01EE ; OS_CPU_SR cpu_sr;
01EE ; #endif
01EE ; OS_STK *psp;
01EE ; INT8U err;
01EE ;
01EE ;
01EE ; #if OS_ARG_CHK_EN > 0
01EE ; if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
01EE ; return (OS_PRIO_INVALID);
01EE ; }
01EE ; #endif
01EE ; OS_ENTER_CRITICAL();
01EE 00D0 rcall _OS_CPU_SR_Save
01F0 A02E mov R10,R16
01F2 .dbline 173
01F2 ; if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
01F2 82E0 ldi R24,2
01F4 8E9D mul R24,R14
01F6 F001 movw R30,R0
01F8 80E0 ldi R24,<_OSTCBPrioTbl
01FA 90E0 ldi R25,>_OSTCBPrioTbl
01FC E80F add R30,R24
01FE F91F adc R31,R25
0200 2080 ldd R2,z+0
0202 3180 ldd R3,z+1
0204 2220 tst R2
0206 09F0 breq X7
0208 53C0 rjmp L19
020A X7:
020A 3320 tst R3
020C 09F0 breq X8
020E 50C0 rjmp L19
0210 X8:
0210 X6:
0210 .dbline 173
0210 .dbline 174
0210 ; OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
0210 82E0 ldi R24,2
0212 8E9D mul R24,R14
0214 F001 movw R30,R0
0216 80E0 ldi R24,<_OSTCBPrioTbl
0218 90E0 ldi R25,>_OSTCBPrioTbl
021A E80F add R30,R24
021C F91F adc R31,R25
021E 81E0 ldi R24,1
0220 90E0 ldi R25,0
0222 9183 std z+1,R25
0224 8083 std z+0,R24
0226 .dbline 176
0226 ; /* ... the same thing until task is created. */
0226 ; OS_EXIT_CRITICAL();
0226 0A2D mov R16,R10
0228 00D0 rcall _OS_CPU_SR_Restore
022A .dbline 177
022A ; psp = (OS_STK *)OSTaskStkInit(task, pdata, ptos, 0); /* Initialize the task's stack */
022A 2224 clr R2
022C 3324 clr R3
022E 3B82 std y+3,R3
0230 2A82 std y+2,R2
0232 088C ldd R0,y+24
0234 198C ldd R1,y+25
0236 1982 std y+1,R1
0238 0882 std y+0,R0
023A 2E89 ldd R18,y+22
023C 3F89 ldd R19,y+23
023E 8601 movw R16,R12
0240 00D0 rcall _OSTaskStkInit
0242 6801 movw R12,R16
0244 .dbline 178
0244 ; err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
0244 2224 clr R2
0246 3324 clr R3
0248 3B86 std y+11,R3
024A 2A86 std y+10,R2
024C 3986 std y+9,R3
024E 2886 std y+8,R2
0250 40E0 ldi R20,0
0252 50E0 ldi R21,0
0254 60E0 ldi R22,0
0256 70E0 ldi R23,0
0258 4C83 std y+4,R20
025A 5D83 std y+5,R21
025C 6E83 std y+6,R22
025E 7F83 std y+7,R23
0260 3B82 std y+3,R3
0262 2A82 std y+2,R2
0264 3982 std y+1,R3
0266 2882 std y+0,R2
0268 9601 movw R18,R12
026A 0E2D mov R16,R14
026C 00D0 rcall _OS_TCBInit
026E C02E mov R12,R16
0270 .dbline 179
0270 ; if (err == OS_NO_ERR) {
0270 0023 tst R16
0272 71F4 brne L21
0274 .dbline 179
0274 .dbline 180
0274 ; OS_ENTER_CRITICAL();
0274 00D0 rcall _OS_CPU_SR_Save
0276 A02E mov R10,R16
0278 .dbline 181
0278 ; OSTaskCtr++; /* Increment the #tasks counter */
0278 80910000 lds R24,_OSTaskCtr
027C 8F5F subi R24,255 ; addi 1
027E 80930000 sts _OSTaskCtr,R24
0282 .dbline 182
0282 ; OS_EXIT_CRITICAL();
0282 00D0 rcall _OS_CPU_SR_Restore
0284 .dbline 183
0284 ; if (OSRunning == TRUE) { /* Find highest priority task if multitasking has started */
0284 80910000 lds R24,_OSRunning
0288 8130 cpi R24,1
028A 81F4 brne L22
028C .dbline 183
028C .dbline 184
028C ; OS_Sched();
028C 00D0 rcall _OS_Sched
028E .dbline 185
028E ; }
028E .dbline 186
028E 0EC0 rjmp L22
0290 L21:
0290 .dbline 186
0290 ; } else {
0290 .dbline 187
0290 ; OS_ENTER_CRITICAL();
0290 00D0 rcall _OS_CPU_SR_Save
0292 A02E mov R10,R16
0294 .dbline 188
0294 ; OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */
0294 82E0 ldi R24,2
0296 8E9D mul R24,R14
0298 F001 movw R30,R0
029A 80E0 ldi R24,<_OSTCBPrioTbl
029C 90E0 ldi R25,>_OSTCBPrioTbl
029E E80F add R30,R24
02A0 F91F adc R31,R25
02A2 2224 clr R2
02A4 3324 clr R3
02A6 3182 std z+1,R3
02A8 2082 std z+0,R2
02AA .dbline 189
02AA ; OS_EXIT_CRITICAL();
02AA 00D0 rcall _OS_CPU_SR_Restore
02AC .dbline 190
02AC ; }
02AC L22:
02AC .dbline 191
02AC ; return (err);
02AC 0C2D mov R16,R12
02AE 03C0 rjmp L18
02B0 L19:
02B0 .dbline 193
02B0 ; }
02B0 ; OS_EXIT_CRITICAL();
02B0 0A2D mov R16,R10
02B2 00D0 rcall _OS_CPU_SR_Restore
02B4 .dbline 194
02B4 ; return (OS_PRIO_EXIST);
02B4 08E2 ldi R16,40
02B6 .dbline -2
02B6 L18:
02B6 2C96 adiw R28,12
02B8 00D0 rcall pop_gset5
02BA 2296 adiw R28,2
02BC .dbline 0 ; func end
02BC 0895 ret
02BE .dbsym r psp 12 pc
02BE .dbsym r err 12 c
02BE .dbsym r cpu_sr 10 c
02BE .dbsym r prio 14 c
02BE .dbsym l ptos 24 pc
02BE .dbsym l pdata 22 pV
02BE .dbsym r task 12 pfV
02BE .dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -