⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucos.lst

📁 Atmega128的proteus仿真例程
💻 LST
📖 第 1 页 / 共 5 页
字号:
    02AF 1FF9      ADC	R31,R25
    02B0 8020      LDD	R2,Z+0
    02B1 8031      LDD	R3,Z+1
    02B2 923002CF  STS	OSTCBHighRdy+1,R3
    02B4 922002CE  STS	OSTCBHighRdy,R2
(0153)             OSCtxSwCtr++;                        /* Keep track of the number of context switches       */
    02B6 E081      LDI	R24,1
    02B7 E090      LDI	R25,0
    02B8 E0A0      LDI	R26,0
    02B9 E0B0      LDI	R27,0
    02BA 904002F5  LDS	R4,OSCtxSwCtr+2
    02BC 905002F6  LDS	R5,OSCtxSwCtr+3
    02BE 902002F3  LDS	R2,OSCtxSwCtr
    02C0 903002F4  LDS	R3,OSCtxSwCtr+1
    02C2 0E28      ADD	R2,R24
    02C3 1E39      ADC	R3,R25
    02C4 1E4A      ADC	R4,R26
    02C5 1E5B      ADC	R5,R27
    02C6 923002F4  STS	OSCtxSwCtr+1,R3
    02C8 922002F3  STS	OSCtxSwCtr,R2
    02CA 925002F6  STS	OSCtxSwCtr+3,R5
    02CC 924002F5  STS	OSCtxSwCtr+2,R4
(0154)             OSIntCtxSw();                        /* Perform interrupt level context switch             */
    02CE 940E06E1  CALL	_OSIntCtxSw
(0155)         }
(0156)     }
(0157)     OS_EXIT_CRITICAL();
    02D0 930A      ST	R16,-Y
    02D1 910F      POP	R16
    02D2 BF0F      OUT	0x3F,R16
    02D3 9109      LD	R16,Y+
    02D4 9508      RET
_OSSched:
  y                    --> R10
    02D5 940E078F  CALL	push_gset3x
(0158) }
(0159) /*$PAGE*/
(0160) /*
(0161) *********************************************************************************************************
(0162) *                                              SCHEDULER
(0163) *
(0164) * Description: This function is called by other uC/OS-II services to determine whether a new, high
(0165) *              priority task has been made ready to run.  This function is invoked by TASK level code
(0166) *              and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
(0167) *
(0168) * Arguments  : none
(0169) *
(0170) * Returns    : none
(0171) *
(0172) * Notes      : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
(0173) *              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
(0174) *********************************************************************************************************
(0175) */
(0176) 
(0177) void OSSched (void)
(0178) {
(0179)     INT8U y;
(0180) 
(0181) 
(0182)     OS_ENTER_CRITICAL();
    02D7 930A      ST	R16,-Y
    02D8 B70F      IN	R16,0x3F
    02D9 94F8      BCLR	7
    02DA 930F      PUSH	R16
    02DB 9109      LD	R16,Y+
(0183)     if ((OSLockNesting | OSIntNesting) == 0) {   /* Task scheduling must be enabled and not ISR level  */
    02DC 902002DC  LDS	R2,OSIntNesting
    02DE 903002DB  LDS	R3,OSLockNesting
    02E0 2832      OR	R3,R2
    02E1 F009      BEQ	0x02E3
    02E2 C04E      RJMP	0x0331
(0184)         y             = OSUnMapTbl[OSRdyGrp];    /* Get pointer to highest priority task ready to run  */
    02E3 E98A      LDI	R24,0x9A
    02E4 E090      LDI	R25,0
    02E5 91E002D8  LDS	R30,OSRdyGrp
    02E7 27FF      CLR	R31
    02E8 0FE8      ADD	R30,R24
    02E9 1FF9      ADC	R31,R25
    02EA 90A4      LPM	R10,0(Z)
(0185)         OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
    02EB ED86      LDI	R24,0xD6
    02EC E092      LDI	R25,2
    02ED 2DEA      MOV	R30,R10
    02EE 27FF      CLR	R31
    02EF 0FE8      ADD	R30,R24
    02F0 1FF9      ADC	R31,R25
    02F1 81E0      LDD	R30,Z+0
    02F2 27FF      CLR	R31
    02F3 E98A      LDI	R24,0x9A
    02F4 E090      LDI	R25,0
    02F5 0FE8      ADD	R30,R24
    02F6 1FF9      ADC	R31,R25
    02F7 9024      LPM	R2,0(Z)
    02F8 2433      CLR	R3
    02F9 2C4A      MOV	R4,R10
    02FA 2455      CLR	R5
    02FB 0C44      LSL	R4
    02FC 1C55      ROL	R5
    02FD 0C44      LSL	R4
    02FE 1C55      ROL	R5
    02FF 0C44      LSL	R4
    0300 1C55      ROL	R5
    0301 0C42      ADD	R4,R2
    0302 1C53      ADC	R5,R3
    0303 924002D9  STS	OSPrioHighRdy,R4
(0186)         if (OSPrioHighRdy != OSPrioCur) {         /* No context switch if current task is highest ready */
    0305 902002DA  LDS	R2,OSPrioCur
    0307 1442      CP	R4,R2
    0308 F141      BEQ	0x0331
(0187)             OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
    0309 2C24      MOV	R2,R4
    030A E082      LDI	R24,2
    030B 9D82      MUL	R24,R2
    030C 01F0      MOVW	R30,R0
    030D EA8C      LDI	R24,0xAC
    030E E092      LDI	R25,2
    030F 0FE8      ADD	R30,R24
    0310 1FF9      ADC	R31,R25
    0311 8020      LDD	R2,Z+0
    0312 8031      LDD	R3,Z+1
    0313 923002CF  STS	OSTCBHighRdy+1,R3
    0315 922002CE  STS	OSTCBHighRdy,R2
(0188)             OSCtxSwCtr++;                        /* Increment context switch counter                   */
    0317 E081      LDI	R24,1
    0318 E090      LDI	R25,0
    0319 E0A0      LDI	R26,0
    031A E0B0      LDI	R27,0
    031B 904002F5  LDS	R4,OSCtxSwCtr+2
    031D 905002F6  LDS	R5,OSCtxSwCtr+3
    031F 902002F3  LDS	R2,OSCtxSwCtr
    0321 903002F4  LDS	R3,OSCtxSwCtr+1
    0323 0E28      ADD	R2,R24
    0324 1E39      ADC	R3,R25
    0325 1E4A      ADC	R4,R26
    0326 1E5B      ADC	R5,R27
    0327 923002F4  STS	OSCtxSwCtr+1,R3
    0329 922002F3  STS	OSCtxSwCtr,R2
    032B 925002F6  STS	OSCtxSwCtr+3,R5
    032D 924002F5  STS	OSCtxSwCtr+2,R4
(0189)             OS_TASK_SW();                        /* Perform a context switch                           */
    032F 940E0684  CALL	_OSCtxSw
(0190)         }
(0191)     }
(0192)     OS_EXIT_CRITICAL();
    0331 930A      ST	R16,-Y
    0332 910F      POP	R16
    0333 BF0F      OUT	0x3F,R16
    0334 9109      LD	R16,Y+
    0335 940E077D  CALL	pop_gset3x
    0337 9508      RET
_OSStart:
  x                    --> R12
  y                    --> R10
    0338 940E0792  CALL	push_gset4x
(0193) }
(0194) /*$PAGE*/
(0195) /*
(0196) *********************************************************************************************************
(0197) *                                          START MULTITASKING
(0198) *
(0199) * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
(0200) *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
(0201) *              and you MUST have created at least one task.
(0202) *
(0203) * Arguments  : none
(0204) *
(0205) * Returns    : none
(0206) *
(0207) * Note       : OSStartHighRdy() MUST:
(0208) *                 a) Call OSTaskSwHook() then,
(0209) *                 b) Set OSRunning to TRUE.
(0210) *********************************************************************************************************
(0211) */
(0212) 
(0213) void OSStart (void)
(0214) {
(0215)     INT8U y;
(0216)     INT8U x;
(0217) 
(0218) 
(0219)     if (OSRunning == FALSE) {
    033A 902002D5  LDS	R2,OSRunning
    033C 2022      TST	R2
    033D F009      BEQ	0x033F
    033E C039      RJMP	0x0378
(0220)         y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
    033F E98A      LDI	R24,0x9A
    0340 E090      LDI	R25,0
    0341 91E002D8  LDS	R30,OSRdyGrp
    0343 27FF      CLR	R31
    0344 0FE8      ADD	R30,R24
    0345 1FF9      ADC	R31,R25
    0346 90A4      LPM	R10,0(Z)
(0221)         x             = OSUnMapTbl[OSRdyTbl[y]];
    0347 ED86      LDI	R24,0xD6
    0348 E092      LDI	R25,2
    0349 2DEA      MOV	R30,R10
    034A 27FF      CLR	R31
    034B 0FE8      ADD	R30,R24
    034C 1FF9      ADC	R31,R25
    034D 81E0      LDD	R30,Z+0
    034E 27FF      CLR	R31
    034F E98A      LDI	R24,0x9A
    0350 E090      LDI	R25,0
    0351 0FE8      ADD	R30,R24
    0352 1FF9      ADC	R31,R25
    0353 90C4      LPM	R12,0(Z)
(0222)         OSPrioHighRdy = (INT8U)((y << 3) + x);
    0354 2C2C      MOV	R2,R12
    0355 2433      CLR	R3
    0356 2C4A      MOV	R4,R10
    0357 2455      CLR	R5
    0358 0C44      LSL	R4
    0359 1C55      ROL	R5
    035A 0C44      LSL	R4
    035B 1C55      ROL	R5
    035C 0C44      LSL	R4
    035D 1C55      ROL	R5
    035E 0C42      ADD	R4,R2
    035F 1C53      ADC	R5,R3
    0360 924002D9  STS	OSPrioHighRdy,R4
(0223)         OSPrioCur     = OSPrioHighRdy;
    0362 2C24      MOV	R2,R4
    0363 922002DA  STS	OSPrioCur,R2
(0224)         OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
    0365 E082      LDI	R24,2
    0366 9D82      MUL	R24,R2
    0367 01F0      MOVW	R30,R0
    0368 EA8C      LDI	R24,0xAC
    0369 E092      LDI	R25,2
    036A 0FE8      ADD	R30,R24
    036B 1FF9      ADC	R31,R25
    036C 8020      LDD	R2,Z+0
    036D 8031      LDD	R3,Z+1
    036E 923002CF  STS	OSTCBHighRdy+1,R3
    0370 922002CE  STS	OSTCBHighRdy,R2
(0225)         OSTCBCur      = OSTCBHighRdy;
    0372 923002D3  STS	OSTCBCur+1,R3
    0374 922002D2  STS	OSTCBCur,R2
(0226)         OSStartHighRdy();                            /* Execute target specific code to start task     */
    0376 940E0654  CALL	_OSStartHighRdy
(0227)     }
    0378 940E0789  CALL	pop_gset4x
    037A 9508      RET
(0228) }
(0229) /*$PAGE*/
(0230) /*
(0231) *********************************************************************************************************
(0232) *                                              IDLE TASK
(0233) *
(0234) * Description: This task is internal to uC/OS-II and executes whenever no other higher priority tasks
(0235) *              executes because they are waiting for event(s) to occur.
(0236) *
(0237) * Arguments  : none
(0238) *
(0239) * Returns    : none
(0240) *********************************************************************************************************
(0241) */
(0242) 
(0243) void OSTaskIdle (void *pdata)
(0244) {
(0245)     pdata = pdata;                               /* Prevent compiler warning for not using 'pdata'     */
(0246)     for (;;) {
(0247)         OS_ENTER_CRITICAL();
_OSTaskIdle:
  pdata                --> R16
    037B 930A      ST	R16,-Y
    037C B70F      IN	R16,0x3F
    037D 94F8      BCLR	7
    037E 930F      PUSH	R16
    037F 9109      LD	R16,Y+
(0248)         OSIdleCtr++;
    0380 E081      LDI	R24,1
    0381 E090      LDI	R25,0
    0382 E0A0      LDI	R26,0
    0383 E0B0      LDI	R27,0
    0384 904002DF  LDS	R4,OSIdleCtr+2
    0386 905002E0  LDS	R5,OSIdleCtr+3
    0388 902002DD  LDS	R2,OSIdleCtr
    038A 903002DE  LDS	R3,OSIdleCtr+1
    038C 0E28      ADD	R2,R24
    038D 1E39      ADC	R3,R25
    038E 1E4A      ADC	R4,R26
    038F 1E5B      ADC	R5,R27
    0390 923002DE  STS	OSIdleCtr+1,R3
    0392 922002DD  STS	OSIdleCtr,R2
    0394 925002E0  STS	OSIdleCtr+3,R5
    0396 924002DF  STS	OSIdleCtr+2,R4
(0249)         OS_EXIT_CRITICAL();
    0398 930A      ST	R16,-Y
    0399 910F      POP	R16
    039A BF0F      OUT	0x3F,R16
    039B 9109      LD	R16,Y+
    039C CFDE      RJMP	_OSTaskIdle
    039D 9508      RET
_OSTCBInit:
  ptcb                 --> R10
  opt                  --> Y+10
  pext                 --> Y+8
  stk_size             --> Y+6
  id                   --> Y+4
  pbos                 --> Y+2
  ptos                 --> R18
  prio                 --> R16
    039E 940E078F  CALL	push_gset3x
(0250)     }
(0251) }
(0252) /*$PAGE*/
(0253) /*
(0254) *********************************************************************************************************
(0255) *                                            INITIALIZE TCB
(0256) *
(0257) * Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
(0258) *              a task is created (see OSTaskCreate() and OSTaskCreateExt()).
(0259) *
(0260) * Arguments  : prio          is the priority of the task being created
(0261) *
(0262) *              ptos          is a pointer to the task's top-of-stack assuming that the CPU registers
(0263) *                            have been placed on the stack.  Note that the top-of-stack corresponds to a 
(0264) *                            'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
(0265) *                            location if OS_STK_GROWTH is set to 0.  Note that stack growth is CPU
(0266) *                            specific.
(0267) *
(0268) *              pbos          is a pointer to the bottom of stack.  A NULL pointer is passed if called by
(0269) *                            'OSTaskCreate()'.
(0270) *
(0271) *              id            is the task's ID (0..65535)
(0272) *
(0273) *              stk_size      is the size of the stack (in 'stack units').  If the stack units are INT8Us
(0274) *                            then, 'stk_size' contains the number of bytes for the stack.  If the stack
(0275) *                            units are INT32Us then, the stack contains '4 * stk_size' bytes.  The stack
(0276) *                            units are established by the #define constant OS_STK which is CPU
(0277) *                            specific.  'stk_size' is 0 if called by 'OSTaskCreate()'.
(0278) *
(0279) *              pext          is a pointer to a user supplied memory area that is used to extend the task
(0280) *                            control block.  This allows you to store the contents of floating-point
(0281) *                            registers, MMU registers or anything else you could find useful during a 
(0282) *                            context switch.  You can even assign a name to each task and store this name
(0283) *                            in this TCB extension.  A NULL pointer is passed if called by OSTaskCreate().
(0284) *
(0285) *              opt           options as passed to 'OSTaskCreateExt()' or, 
(0286) *                            0 if called from 'OSTaskCreate()'.
(0287) *
(0288) * Returns    : OS_NO_ERR         if the call was successful
(0289) *              OS_NO_MORE_TCB    if there are no more free TCBs to be allocated and thus, the task cannot
(0290) *                                be created.
(0291) *
(0292) * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
(0293) *********************************************************************************************************
(0294) */

⌨️ 快捷键说明

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