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

📄 ucos-port2.lst

📁 把UCOSII移植到AVR MEGA8上的程序 应用程序为驱动1602显示器,虽说有些简单,但可测试UCOS的运行
💻 LST
📖 第 1 页 / 共 5 页
字号:
(0260) */
(0261) 
(0262) void  OSIntEnter (void)
(0263) {
(0264) #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
(0265)     OS_CPU_SR  cpu_sr;
(0266) #endif    
(0267)     
(0268)     
(0269)     OS_ENTER_CRITICAL();
    01AC D9F7      RCALL	_OS_CPU_SR_Save
    01AD 2F40      MOV	R20,R16
(0270)     if (OSIntNesting < 255) {
    01AE 918001B2  LDS	R24,OSIntNesting
    01B0 3F8F      CPI	R24,0xFF
    01B1 F418      BCC	0x01B5
(0271)         OSIntNesting++;                          /* Increment ISR nesting level                        */
    01B2 5F8F      SUBI	R24,0xFF
    01B3 938001B2  STS	OSIntNesting,R24
(0272)     }
(0273)     OS_EXIT_CRITICAL();
    01B5 2F04      MOV	R16,R20
    01B6 D9F0      RCALL	_OS_CPU_SR_Restore
    01B7 DBE3      RCALL	pop_gset1
    01B8 9508      RET
_OSIntExit:
  cpu_sr               --> R10
    01B9 DBDA      RCALL	push_gset3
(0274) }
(0275) /*$PAGE*/
(0276) /*
(0277) *********************************************************************************************************
(0278) *                                               EXIT ISR
(0279) *
(0280) * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When
(0281) *              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
(0282) *              a new, high-priority task, is ready to run.
(0283) *
(0284) * Arguments  : none
(0285) *
(0286) * Returns    : none
(0287) *
(0288) * Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
(0289) *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
(0290) *                 end of the ISR.
(0291) *              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
(0292) *********************************************************************************************************
(0293) */
(0294) 
(0295) void  OSIntExit (void)
(0296) {
(0297) #if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
(0298)     OS_CPU_SR  cpu_sr;
(0299) #endif
(0300)     
(0301)     
(0302)     OS_ENTER_CRITICAL();
    01BA D9E9      RCALL	_OS_CPU_SR_Save
    01BB 2EA0      MOV	R10,R16
(0303)     if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping           */
    01BC 2422      CLR	R2
    01BD 903001B2  LDS	R3,OSIntNesting
    01BF 1423      CP	R2,R3
    01C0 F420      BCC	0x01C5
(0304)         OSIntNesting--;
    01C1 2D83      MOV	R24,R3
    01C2 5081      SUBI	R24,1
    01C3 938001B2  STS	OSIntNesting,R24
(0305)     }
(0306)     if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Reschedule only if all ISRs complete ...     */
    01C5 902001B2  LDS	R2,OSIntNesting
    01C7 2022      TST	R2
    01C8 F009      BEQ	0x01CA
    01C9 C054      RJMP	0x021E
    01CA 902001B0  LDS	R2,OSLockNesting
    01CC 2022      TST	R2
    01CD F009      BEQ	0x01CF
    01CE C04F      RJMP	0x021E
(0307)         OSIntExitY    = OSUnMapTbl[OSRdyGrp];          /* ... and not locked.                          */
    01CF E386      LDI	R24,0x36
    01D0 E090      LDI	R25,0
    01D1 91E001AD  LDS	R30,OSRdyGrp
    01D3 27FF      CLR	R31
    01D4 0FE8      ADD	R30,R24
    01D5 1FF9      ADC	R31,R25
    01D6 91E4      LPM	R30,0(Z)
    01D7 93E001B1  STS	OSIntExitY,R30
(0308)         OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
    01D9 EA8A      LDI	R24,0xAA
    01DA E091      LDI	R25,1
    01DB 27FF      CLR	R31
    01DC 0FE8      ADD	R30,R24
    01DD 1FF9      ADC	R31,R25
    01DE 81E0      LDD	R30,Z+0
    01DF 27FF      CLR	R31
    01E0 E386      LDI	R24,0x36
    01E1 E090      LDI	R25,0
    01E2 0FE8      ADD	R30,R24
    01E3 1FF9      ADC	R31,R25
    01E4 9024      LPM	R2,0(Z)
    01E5 2433      CLR	R3
    01E6 904001B1  LDS	R4,OSIntExitY
    01E8 2455      CLR	R5
    01E9 0C44      LSL	R4
    01EA 1C55      ROL	R5
    01EB 0C44      LSL	R4
    01EC 1C55      ROL	R5
    01ED 0C44      LSL	R4
    01EE 1C55      ROL	R5
    01EF 0C42      ADD	R4,R2
    01F0 1C53      ADC	R5,R3
    01F1 924001AE  STS	OSPrioHighRdy,R4
(0309)         if (OSPrioHighRdy != OSPrioCur) {              /* No Ctx Sw if current task is highest rdy     */
    01F3 902001AF  LDS	R2,OSPrioCur
    01F5 1442      CP	R4,R2
    01F6 F139      BEQ	0x021E
(0310)             OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy];
    01F7 2C24      MOV	R2,R4
    01F8 E082      LDI	R24,2
    01F9 9D82      MUL	R24,R2
    01FA 01F0      MOVW	R30,R0
    01FB EF82      LDI	R24,0xF2
    01FC E090      LDI	R25,0
    01FD 0FE8      ADD	R30,R24
    01FE 1FF9      ADC	R31,R25
    01FF 8020      LDD	R2,Z+0
    0200 8031      LDD	R3,Z+1
    0201 9230011F  STS	OSTCBHighRdy+1,R3
    0203 9220011E  STS	OSTCBHighRdy,R2
(0311)             OSCtxSwCtr++;                              /* Keep track of the number of context switches */
    0205 E041      LDI	R20,1
    0206 E050      LDI	R21,0
    0207 E060      LDI	R22,0
    0208 E070      LDI	R23,0
    0209 904001DB  LDS	R4,OSCtxSwCtr+2
    020B 905001DC  LDS	R5,OSCtxSwCtr+3
    020D 902001D9  LDS	R2,OSCtxSwCtr
    020F 903001DA  LDS	R3,OSCtxSwCtr+1
    0211 0E24      ADD	R2,R20
    0212 1E35      ADC	R3,R21
    0213 1E46      ADC	R4,R22
    0214 1E57      ADC	R5,R23
    0215 923001DA  STS	OSCtxSwCtr+1,R3
    0217 922001D9  STS	OSCtxSwCtr,R2
    0219 925001DC  STS	OSCtxSwCtr+3,R5
    021B 924001DB  STS	OSCtxSwCtr+2,R4
(0312)             OSIntCtxSw();                              /* Perform interrupt level context switch       */
    021D DA22      RCALL	_OSIntCtxSw
(0313)         }
(0314)     }
(0315)     OS_EXIT_CRITICAL();
    021E 2D0A      MOV	R16,R10
    021F D987      RCALL	_OS_CPU_SR_Restore
    0220 DB69      RCALL	pop_gset3
    0221 9508      RET
_OSStart:
  x                    --> R22
  y                    --> R20
    0222 DB73      RCALL	push_gset2
(0316) }
(0317) /*$PAGE*/
(0318) /*
(0319) *********************************************************************************************************
(0320) *                                          PREVENT SCHEDULING
(0321) *
(0322) * Description: This function is used to prevent rescheduling to take place.  This allows your application
(0323) *              to prevent context switches until you are ready to permit context switching.
(0324) *
(0325) * Arguments  : none
(0326) *
(0327) * Returns    : none
(0328) *
(0329) * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every
(0330) *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
(0331) *********************************************************************************************************
(0332) */
(0333) 
(0334) #if OS_SCHED_LOCK_EN > 0
(0335) void  OSSchedLock (void)
(0336) {
(0337) #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
(0338)     OS_CPU_SR  cpu_sr;
(0339) #endif    
(0340)     
(0341)     
(0342)     if (OSRunning == TRUE) {                     /* Make sure multitasking is running                  */
(0343)         OS_ENTER_CRITICAL();
(0344)         if (OSLockNesting < 255) {               /* Prevent OSLockNesting from wrapping back to 0      */
(0345)             OSLockNesting++;                     /* Increment lock nesting level                       */
(0346)         }
(0347)         OS_EXIT_CRITICAL();
(0348)     }
(0349) }
(0350) #endif    
(0351) 
(0352) /*$PAGE*/
(0353) /*
(0354) *********************************************************************************************************
(0355) *                                          ENABLE SCHEDULING
(0356) *
(0357) * Description: This function is used to re-allow rescheduling.
(0358) *
(0359) * Arguments  : none
(0360) *
(0361) * Returns    : none
(0362) *
(0363) * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every
(0364) *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
(0365) *********************************************************************************************************
(0366) */
(0367) 
(0368) #if OS_SCHED_LOCK_EN > 0
(0369) void  OSSchedUnlock (void)
(0370) {
(0371) #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
(0372)     OS_CPU_SR  cpu_sr;
(0373) #endif    
(0374)     
(0375)     
(0376)     if (OSRunning == TRUE) {                                   /* Make sure multitasking is running    */
(0377)         OS_ENTER_CRITICAL();
(0378)         if (OSLockNesting > 0) {                               /* Do not decrement if already 0        */
(0379)             OSLockNesting--;                                   /* Decrement lock nesting level         */
(0380)             if ((OSLockNesting == 0) && (OSIntNesting == 0)) { /* See if sched. enabled and not an ISR */
(0381)                 OS_EXIT_CRITICAL();
(0382)                 OS_Sched();                                    /* See if a HPT is ready                */
(0383)             } else {
(0384)                 OS_EXIT_CRITICAL();
(0385)             }
(0386)         } else {
(0387)             OS_EXIT_CRITICAL();
(0388)         }
(0389)     }
(0390) }
(0391) #endif    
(0392) 
(0393) /*$PAGE*/
(0394) /*
(0395) *********************************************************************************************************
(0396) *                                          START MULTITASKING
(0397) *
(0398) * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
(0399) *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
(0400) *              and you MUST have created at least one task.
(0401) *
(0402) * Arguments  : none
(0403) *
(0404) * Returns    : none
(0405) *
(0406) * Note       : OSStartHighRdy() MUST:
(0407) *                 a) Call OSTaskSwHook() then,
(0408) *                 b) Set OSRunning to TRUE.
(0409) *********************************************************************************************************
(0410) */
(0411) 
(0412) void  OSStart (void)
(0413) {
(0414)     INT8U y;
(0415)     INT8U x;
(0416) 
(0417) 
(0418)     if (OSRunning == FALSE) {
    0223 902001A9  LDS	R2,OSRunning
    0225 2022      TST	R2
    0226 F009      BEQ	0x0228
    0227 C038      RJMP	0x0260
(0419)         y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
    0228 E386      LDI	R24,0x36
    0229 E090      LDI	R25,0
    022A 91E001AD  LDS	R30,OSRdyGrp
    022C 27FF      CLR	R31
    022D 0FE8      ADD	R30,R24
    022E 1FF9      ADC	R31,R25
    022F 9144      LPM	R20,0(Z)
(0420)         x             = OSUnMapTbl[OSRdyTbl[y]];
    0230 EA8A      LDI	R24,0xAA
    0231 E091      LDI	R25,1
    0232 2FE4      MOV	R30,R20
    0233 27FF      CLR	R31
    0234 0FE8      ADD	R30,R24
    0235 1FF9      ADC	R31,R25
    0236 81E0      LDD	R30,Z+0
    0237 27FF      CLR	R31
    0238 E386      LDI	R24,0x36
    0239 E090      LDI	R25,0
    023A 0FE8      ADD	R30,R24
    023B 1FF9      ADC	R31,R25
    023C 9164      LPM	R22,0(Z)
(0421)         OSPrioHighRdy = (INT8U)((y << 3) + x);
    023D 2E26      MOV	R2,R22
    023E 2433      CLR	R3
    023F 2E44      MOV	R4,R20
    0240 2455      CLR	R5
    0241 0C44      LSL	R4
    0242 1C55      ROL	R5
    0243 0C44      LSL	R4
    0244 1C55      ROL	R5
    0245 0C44      LSL	R4
    0246 1C55      ROL	R5
    0247 0C42      ADD	R4,R2
    0248 1C53      ADC	R5,R3
    0249 924001AE  STS	OSPrioHighRdy,R4
(0422)         OSPrioCur     = OSPrioHighRdy;
    024B 2C24      MOV	R2,R4
    024C 922001AF  STS	OSPrioCur,R2
(0423)         OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
    024E E082      LDI	R24,2
    024F 9D82      MUL	R24,R2
    0250 01F0      MOVW	R30,R0
    0251 EF82      LDI	R24,0xF2
    0252 E090      LDI	R25,0
    0253 0FE8      ADD	R30,R24
    0254 1FF9      ADC	R31,R25
    0255 8020      LDD	R2,Z+0
    0256 8031      LDD	R3,Z+1
    0257 9230011F  STS	OSTCBHighRdy+1,R3
    0259 9220011E  STS	OSTCBHighRdy,R2
(0424)         OSTCBCur      = OSTCBHighRdy;
    025B 92300123  STS	OSTCBCur+1,R3
    025D 92200122  STS	OSTCBCur,R2
(0425)         OSStartHighRdy();                            /* Execute target specific code to start task     */
    025F D949      RCALL	_OSStartHighRdy
(0426)     }
    0260 DB27      RCALL	pop_gset2
    0261 9508      RET
_OSTimeTick:
  cpu_sr               --> R10

⌨️ 快捷键说明

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