OS_CPU_C.SRC
资源名称:QFI4ddQe.rar [点击查看]
上传用户:tzjinxin1
上传日期:2022-08-08
资源大小:272k
文件大小:27k
源码类别:
嵌入式/单片机编程
开发平台:
Visual C++
- ; .objOS_CPU_C.SRC generated from: uCosiiOS_CPU_C.C
- ; COMPILER INVOKED BY:
- ; C:KeilC51BINC51.EXE uCosiiOS_CPU_C.C LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.lstOS_CPU_C.lst) SRC(.objOS_CPU_C.SRC)
- $NOMOD51
- NAME OS_CPU_C
- P0 DATA 080H
- P1 DATA 090H
- P2 DATA 0A0H
- P3 DATA 0B0H
- T0 BIT 0B0H.4
- AC BIT 0D0H.6
- T1 BIT 0B0H.5
- T2 BIT 090H.0
- EA BIT 0A8H.7
- IE DATA 0A8H
- EXF2 BIT 0C8H.6
- RD BIT 0B0H.7
- ES BIT 0A8H.4
- IP DATA 0B8H
- RI BIT 098H.0
- INT0 BIT 0B0H.2
- CY BIT 0D0H.7
- TI BIT 098H.1
- INT1 BIT 0B0H.3
- RCAP2H DATA 0CBH
- PS BIT 0B8H.4
- SP DATA 081H
- T2EX BIT 090H.1
- OV BIT 0D0H.2
- RCAP2L DATA 0CAH
- C_T2 BIT 0C8H.1
- WR BIT 0B0H.6
- RCLK BIT 0C8H.5
- TCLK BIT 0C8H.4
- SBUF DATA 099H
- PCON DATA 087H
- SCON DATA 098H
- TMOD DATA 089H
- TCON DATA 088H
- IE0 BIT 088H.1
- IE1 BIT 088H.3
- B DATA 0F0H
- CP_RL2 BIT 0C8H.0
- ACC DATA 0E0H
- ET0 BIT 0A8H.1
- ET1 BIT 0A8H.3
- TF0 BIT 088H.5
- ET2 BIT 0A8H.5
- TF1 BIT 088H.7
- TF2 BIT 0C8H.7
- RB8 BIT 098H.2
- TH0 DATA 08CH
- EX0 BIT 0A8H.0
- IT0 BIT 088H.0
- TH1 DATA 08DH
- TB8 BIT 098H.3
- EX1 BIT 0A8H.2
- IT1 BIT 088H.2
- TH2 DATA 0CDH
- P BIT 0D0H.0
- SM0 BIT 098H.7
- TL0 DATA 08AH
- SM1 BIT 098H.6
- TL1 DATA 08BH
- SM2 BIT 098H.5
- TL2 DATA 0CCH
- PT0 BIT 0B8H.1
- PT1 BIT 0B8H.3
- RS0 BIT 0D0H.3
- PT2 BIT 0B8H.5
- TR0 BIT 088H.4
- RS1 BIT 0D0H.4
- TR1 BIT 088H.6
- TR2 BIT 0C8H.2
- PX0 BIT 0B8H.0
- PX1 BIT 0B8H.2
- DPH DATA 083H
- DPL DATA 082H
- EXEN2 BIT 0C8H.3
- REN BIT 098H.4
- T2CON DATA 0C8H
- RXD BIT 0B0H.0
- TXD BIT 0B0H.1
- F0 BIT 0D0H.5
- PSW DATA 0D0H
- ?PR?_?OSTaskStkInit?OS_CPU_C SEGMENT CODE
- ?PR?_?OSInitHookBegin?OS_CPU_C SEGMENT CODE
- ?PR?_?OSInitHookEnd?OS_CPU_C SEGMENT CODE
- ?PR?_?OSTaskCreateHook?OS_CPU_C SEGMENT CODE
- ?PR?_?OSTaskSwHook?OS_CPU_C SEGMENT CODE
- ?PR?_?OSTCBInitHook?OS_CPU_C SEGMENT CODE
- ?PR?_?OSTimeTickHook?OS_CPU_C SEGMENT CODE
- ?PR?_?OSTaskIdleHook?OS_CPU_C SEGMENT CODE
- ?PR?UserTickTimer?OS_CPU_C SEGMENT CODE
- ?PR?OSTickISR?OS_CPU_C SEGMENT CODE
- ?PR?SerialISR?OS_CPU_C SEGMENT CODE
- ?PR?_?InitHardware?OS_CPU_C SEGMENT CODE
- ?XD?OS_CPU_C SEGMENT XDATA
- EXTRN CODE (_?OSIntExit)
- EXTRN CODE (_?OSTimeTick)
- EXTRN CODE (_?OSIntEnter)
- EXTRN CODE (?C?ADDXBP)
- EXTRN CODE (?C?XBPOFF)
- EXTRN DATA (?C_XBP)
- EXTRN CODE (?C?ILDIX)
- EXTRN CODE (?C?CSTPTR)
- EXTRN CODE (?C?CLDOPTR)
- PUBLIC pc_send
- PUBLIC _?InitHardware
- PUBLIC SerialISR
- PUBLIC OSTickISR
- PUBLIC UserTickTimer
- PUBLIC _?OSTaskIdleHook
- PUBLIC _?OSTimeTickHook
- PUBLIC _?OSTCBInitHook
- PUBLIC _?OSTaskSwHook
- PUBLIC _?OSTaskCreateHook
- PUBLIC _?OSInitHookEnd
- PUBLIC _?OSInitHookBegin
- PUBLIC _?OSTaskStkInit
- RSEG ?XD?OS_CPU_C
- pc_send: DS 7
- ; /*
- ; *********************************************************************************************************
- ; * uC/OS-II
- ; * 实时内核
- ; *
- ; * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
- ; * 版权所有
- ; *
- ; * MCU-51 专用代码
- ; * KEIL C51大模式编译
- ; *
- ; * 文件名 : OS_CPU_C.C
- ; * 作者 : Jean J. Labrosse
- ; * 改编 : 杨屹 gdtyy@ri.gdt.com.cn 巨龙公司系统集成开发部 2002.09.27
- ; * 改编 : 钟文青,升级到与ucOS-II 2.51的代码,2003.5
- ; *********************************************************************************************************
- ; */
- ;
- ; #define OS_CPU_GLOBALS
- ; #include "sourceincludes.h"
- ;
- ; /*
- ; *********************************************************************************************************
- ; * 初始化任务堆栈
- ; *
- ; * 描述 : 这个函数被OSTaskCreate()或OSTaskCreateExt()调用,以便初始化新创建任务的堆栈结构。本函数
- ; * 与处理器高度相关。
- ; *
- ; * 参数 : task 指向任务代码的指针
- ; *
- ; * pdata 当任务第一次执行时将要传入任务的用户数据结构指针
- ; *
- ; * ptos 栈顶指针。ptos指针被默认为用户堆栈入口指针。如果OS_STK_GROWTH被置1,那么,
- ; * ptos指向用户堆栈的最高有效地址。同样地,如果OS_STK_GROWTH清0,ptos将指向
- ; * 用户堆栈的最低有效地址。
- ; *
- ; * opt 指定可以改变OSTaskStkInit()行为的选项。(见uCOS_II.H for OS_TASK_OPT_???)。
- ; *
- ; * 返回值 : 我修改了原来的程序,使函数总是返回用户堆栈空间的最低有效地址。这样修改提高了TCB换入换出
- ; * 的效率。
- ; *
- ; * 注意 : 任务堆栈结构:
- ; *
- ; * ---------- -
- ; * 用户栈最高地址---->| | |
- ; * ---------- |
- ; * | ... | 仿真堆栈空间
- ; *---------- ---------- | 每任务一个
- ; *|OSTCBCur| ?C_XBP---->| | | KEIL自动处理
- ; *---------- ---------- -
- ; * | |空闲间隔|
- ; * | ----------------------- ---------- ----------
- ; * ---->|OSTCBCur->OSTCBStkPtr| |?C_XBP低| SP---->| |
- ; * ----------------------- ---------- ----------
- ; * | |?C_XBP高| | |
- ; * | ---------- - ----------
- ; * | | | | | . |
- ; * | ---------- | | . |
- ; * | | | | | . |
- ; * | ---------- | ----------
- ; * | | . |长度 | | +1
- ; * | | . | | ----------
- ; * | | . | | OSStack---->| | 0
- ; * | ---------- | ----------
- ; * | | | | OSStkStart---->| 不关心 | -1 低地址
- ; * | ---------- - ----------
- ; * ------------->| 长度 | 低地址 系统硬件堆栈
- ; * ----------
- ; * 用户堆栈 长度=SP-OSStkStart
- ; *********************************************************************************************************
- ; */
- ;
- ; OS_STK *OSTaskStkInit (void (*task)(void *pd) reentrant, void *ppdata, OS_STK *ptos, INT16U opt) reentrant
- RSEG ?PR?_?OSTaskStkInit?OS_CPU_C
- _?OSTaskStkInit:
- USING 0
- ; SOURCE LINE # 73
- MOV DPTR,#0FFFDH
- LCALL ?C?ADDXBP
- MOV A,R3
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- MOV DPTR,#0FFFDH
- LCALL ?C?ADDXBP
- ; {
- ; OS_STK *stk;
- ;
- ; ppdata = ppdata;
- ; SOURCE LINE # 77
- MOV DPTR,#06H
- LCALL ?C?XBPOFF
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- MOV R1,A
- MOV DPTR,#06H
- LCALL ?C?XBPOFF
- MOV A,R3
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- ; opt = opt; //opt没被用到,保留此语句防止告警产生
- ; SOURCE LINE # 78
- MOV DPTR,#0CH
- LCALL ?C?XBPOFF
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV DPTR,#0CH
- LCALL ?C?XBPOFF
- MOV A,R6
- MOVX @DPTR,A
- INC DPTR
- MOV A,R7
- MOVX @DPTR,A
- ; stk = ptos; //用户堆栈最低有效地址
- ; SOURCE LINE # 79
- MOV DPTR,#09H
- LCALL ?C?XBPOFF
- MOVX A,@DPTR
- MOV R1,A
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- XCH A,R1
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- ; *stk++ = 15; //用户堆栈长度
- ; SOURCE LINE # 80
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#0FH
- LCALL ?C?CSTPTR
- ; *stk++ = (INT16U)task & 0xFF; //任务地址低8位
- ; SOURCE LINE # 81
- MOV DPTR,#03H
- LCALL ?C?XBPOFF
- INC DPTR
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,R7
- LCALL ?C?CSTPTR
- ; *stk++ = (INT16U)task >> 8; //任务地址高8位
- ; SOURCE LINE # 82
- MOV DPTR,#03H
- LCALL ?C?XBPOFF
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- MOV A,R2
- MOV R7,A
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,R7
- LCALL ?C?CSTPTR
- ; *stk++ = 0x0A; //ACC
- ; SOURCE LINE # 83
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#0AH
- LCALL ?C?CSTPTR
- ; *stk++ = 0x0B; //B
- ; SOURCE LINE # 84
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#0BH
- LCALL ?C?CSTPTR
- ; *stk++ = 0x00; //DPH
- ; SOURCE LINE # 85
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- CLR A
- LCALL ?C?CSTPTR
- ; *stk++ = 0x00; //DPL
- ; SOURCE LINE # 86
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- CLR A
- LCALL ?C?CSTPTR
- ; *stk++ = 0x00; //PSW
- ; SOURCE LINE # 87
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- CLR A
- LCALL ?C?CSTPTR
- ; *stk++ = 0x00; //R0
- ; SOURCE LINE # 88
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- CLR A
- LCALL ?C?CSTPTR
- ;
- ; //R3、R2、R1用于传递任务参数ppdata,其中R3代表存储器类型,R2为高字节偏移,R1为低字节位移。
- ; //通过分析KEIL汇编,了解到任务的void *ppdata参数恰好是用R3、R2、R1传递,不是通过虚拟堆栈。
- ; *stk++ = (INT16U)ppdata & 0xFF; //R1
- ; SOURCE LINE # 92
- MOV DPTR,#06H
- LCALL ?C?XBPOFF
- INC DPTR
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,R7
- LCALL ?C?CSTPTR
- ; *stk++ = (INT16U)ppdata >> 8; //R2
- ; SOURCE LINE # 93
- MOV DPTR,#06H
- LCALL ?C?XBPOFF
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- MOV A,R2
- MOV R7,A
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,R7
- LCALL ?C?CSTPTR
- ; *stk++ = 0x01; //R3 因为我用的全是XDATA,所以存储器类型固定为1,见C51.PDF第178页说明。
- ; SOURCE LINE # 94
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#01H
- LCALL ?C?CSTPTR
- ;
- ; *stk++ = 0x04; //R4
- ; SOURCE LINE # 96
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#04H
- LCALL ?C?CSTPTR
- ; *stk++ = 0x05; //R5
- ; SOURCE LINE # 97
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#05H
- LCALL ?C?CSTPTR
- ; *stk++ = 0x06; //R6
- ; SOURCE LINE # 98
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#06H
- LCALL ?C?CSTPTR
- ; *stk++ = 0x07; //R7
- ; SOURCE LINE # 99
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,#07H
- LCALL ?C?CSTPTR
- ; //不用保存SP,任务切换时根据用户堆栈长度计算得出。
- ; *stk++ = (INT16U) (ptos+MaxStkSize) >> 8; //?C_XBP 仿真堆栈指针高8位
- ; SOURCE LINE # 101
- MOV DPTR,#09H
- LCALL ?C?XBPOFF
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- ADD A,#064H
- CLR A
- ADDC A,R2
- MOV R7,A
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,R7
- LCALL ?C?CSTPTR
- ; *stk++ = (INT16U) (ptos+MaxStkSize) & 0xFF; //?C_XBP 仿真堆栈指针低8位
- ; SOURCE LINE # 102
- MOV DPTR,#09H
- LCALL ?C?XBPOFF
- INC DPTR
- INC DPTR
- MOVX A,@DPTR
- ADD A,#064H
- MOV R1,A
- MOV R7,AR1
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- CLR A
- MOV B,#01H
- LCALL ?C?ILDIX
- MOV R1,B
- MOV R2,A
- MOV A,R7
- LCALL ?C?CSTPTR
- ;
- ; return ((void *)ptos);
- ; SOURCE LINE # 104
- MOV DPTR,#09H
- LCALL ?C?XBPOFF
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- MOV R1,A
- ; }
- ; SOURCE LINE # 105
- ?C0001:
- MOV DPTR,#0EH
- LJMP ?C?ADDXBP
- ; END OF _?OSTaskStkInit
- ;
- ; #if OS_CPU_HOOKS_EN
- ;
- ; /*
- ; *********************************************************************************************************
- ; * OS INITIALIZATION HOOK
- ; * (BEGINNING)
- ; *
- ; * Description: This function is called by OSInit() at the beginning of OSInit().
- ; *
- ; * Arguments : none
- ; *
- ; * Note(s) : 1) Interrupts should be disabled during this call.
- ; *********************************************************************************************************
- ; */
- ; #if OS_VERSION > 203
- ; void OSInitHookBegin (void) reentrant
- RSEG ?PR?_?OSInitHookBegin?OS_CPU_C
- _?OSInitHookBegin:
- ; SOURCE LINE # 122
- ; {
- ;
- ; }
- ; SOURCE LINE # 125
- RET
- ; END OF _?OSInitHookBegin
- ; #endif
- ;
- ; /*
- ; *********************************************************************************************************
- ; * OS INITIALIZATION HOOK
- ; * (END)
- ; *
- ; * Description: This function is called by OSInit() at the end of OSInit().
- ; *
- ; * Arguments : none
- ; *
- ; * Note(s) : 1) Interrupts should be disabled during this call.
- ; *********************************************************************************************************
- ; */
- ; #if OS_VERSION > 203
- ; void OSInitHookEnd (void) reentrant
- RSEG ?PR?_?OSInitHookEnd?OS_CPU_C
- _?OSInitHookEnd:
- ; SOURCE LINE # 141
- ; {
- ; }
- ; SOURCE LINE # 143
- RET
- ; END OF _?OSInitHookEnd
- ; #endif
- ;
- ; /*
- ; *********************************************************************************************************
- ; * 任务创建钩挂函数
- ; *
- ; * 描述 : 任务创建时调用
- ; *
- ; * 参数 : ptcb是指向将被创建任务的任务控制块的指针。
- ; *
- ; * 注意 : 1) 调用期间中断被禁止
- ; *********************************************************************************************************
- ; */
- ; void OSTaskCreateHook (OS_TCB *ptcb) reentrant
- RSEG ?PR?_?OSTaskCreateHook?OS_CPU_C
- _?OSTaskCreateHook:
- USING 0
- ; SOURCE LINE # 157
- MOV DPTR,#0FFFDH
- LCALL ?C?ADDXBP
- MOV A,R3
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- ; {
- ; ptcb = ptcb; /* Prevent compiler warning */
- ; SOURCE LINE # 159
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R1,A
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- XCH A,R1
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- ; }
- ; SOURCE LINE # 160
- MOV DPTR,#03H
- LJMP ?C?ADDXBP
- ; END OF _?OSTaskCreateHook
- ;
- ;
- ; /*
- ; *********************************************************************************************************
- ; * 任务删除钩挂函数
- ; *
- ; * 描述 : 任务删除时调用
- ; *
- ; * 参数 : ptcb是指向将被删除任务的任务控制块的指针。
- ; *
- ; * 注意 : 1) 调用期间中断被禁止
- ; *********************************************************************************************************
- ; */
- ; #if OS_TASK_DEL_EN > 0
- ; void OSTaskDelHook (OS_TCB *ptcb) reentrant
- ; {
- ; ptcb = ptcb; /* Prevent compiler warning */
- ; }
- ; #endif
- ;
- ; /*
- ; *********************************************************************************************************
- ; * 任务切换钩挂函数
- ; *
- ; * 描述 : 执行任务切换时调用。这允许你在上下文切换期间执行其它操作。
- ; *
- ; * 参数 : 无
- ; *
- ; * 注意 : 1) 调用期间中断被禁止
- ; * 2) 假定全局指针'OSTCBHighRdy'已经指向了将要被换入的任务控制块(即:最高优先级任务),并且
- ; * 'OSTCBCur'指向了将被换出的任务(即:当前任务)。
- ; *********************************************************************************************************
- ; */
- ; void OSTaskSwHook (void) reentrant
- RSEG ?PR?_?OSTaskSwHook?OS_CPU_C
- _?OSTaskSwHook:
- ; SOURCE LINE # 194
- ; {
- ; }
- ; SOURCE LINE # 196
- RET
- ; END OF _?OSTaskSwHook
- ;
- ; /*
- ; *********************************************************************************************************
- ; * 统计任务钩挂函数
- ; *
- ; * 描述 : 这个函数每秒钟被uC/OS-II统计任务调用。这么做使你的应用程序可以增加统计任务的功能。
- ; *
- ; * 注意 : 无
- ; *********************************************************************************************************
- ; */
- ; #if OS_TASK_STAT_EN > 0
- ; void OSTaskStatHook (void) reentrant
- ; {
- ; }
- ; #endif
- ;
- ; /*
- ; *********************************************************************************************************
- ; * OSTCBInit() HOOK
- ; *
- ; * Description: This function is called by OSTCBInit() after setting up most of the TCB.
- ; *
- ; * Arguments : ptcb is a pointer to the TCB of the task being created.
- ; *
- ; * Note(s) : 1) Interrupts may or may not be ENABLED during this call.
- ; *********************************************************************************************************
- ; */
- ; #if OS_VERSION > 203
- ; void OSTCBInitHook (OS_TCB *ptcb) reentrant
- RSEG ?PR?_?OSTCBInitHook?OS_CPU_C
- _?OSTCBInitHook:
- USING 0
- ; SOURCE LINE # 225
- MOV DPTR,#0FFFDH
- LCALL ?C?ADDXBP
- MOV A,R3
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- ; {
- ; ptcb = ptcb; /* Prevent Compiler warning */
- ; SOURCE LINE # 227
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- MOVX A,@DPTR
- MOV R1,A
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- MOV DPH,?C_XBP
- MOV DPL,?C_XBP+01H
- XCH A,R1
- MOVX @DPTR,A
- INC DPTR
- MOV A,R2
- MOVX @DPTR,A
- INC DPTR
- MOV A,R1
- MOVX @DPTR,A
- ; }
- ; SOURCE LINE # 228
- MOV DPTR,#03H
- LJMP ?C?ADDXBP
- ; END OF _?OSTCBInitHook
- ; #endif
- ;
- ; /*
- ; *********************************************************************************************************
- ; * 定时钩挂函数
- ; *
- ; * 描述 : 本函数每一滴答被调用一次。
- ; *
- ; * 参数 : 无
- ; *
- ; * 注意 : 1) 在本调用期间中断可以或不可以使能。
- ; *********************************************************************************************************
- ; */
- ; void OSTimeTickHook (void) reentrant
- RSEG ?PR?_?OSTimeTickHook?OS_CPU_C
- _?OSTimeTickHook:
- ; SOURCE LINE # 242
- ; {
- ; }
- ; SOURCE LINE # 244
- RET
- ; END OF _?OSTimeTickHook
- ;
- ; /*
- ; *********************************************************************************************************
- ; * IDLE TASK HOOK
- ; *
- ; * Description: This function is called by the idle task. This hook has been added to allow you to do
- ; * such things as STOP the CPU to conserve power.
- ; *
- ; * Arguments : none
- ; *
- ; * Note(s) : 1) Interrupts are enabled during this call.
- ; *********************************************************************************************************
- ; */
- ; #if OS_VERSION >= 251
- ; void OSTaskIdleHook (void) reentrant
- RSEG ?PR?_?OSTaskIdleHook?OS_CPU_C
- _?OSTaskIdleHook:
- ; SOURCE LINE # 259
- ; {
- ; }
- ; SOURCE LINE # 261
- RET
- ; END OF _?OSTaskIdleHook
- ; #endif
- ;
- ; #endif
- ;
- ; /*
- ; 使用C语言的中断处理函数有助与提高程序的移植性。建议中断程序不要太长,如果长则使用信号量来与任务同步,
- ; 在外部任务中实现大量的处理。
- ; 中断处理例程都放在下面。
- ; */
- ;
- ; void UserTickTimer(void)
- RSEG ?PR?UserTickTimer?OS_CPU_C
- UserTickTimer:
- ; SOURCE LINE # 272
- ; {
- ; SOURCE LINE # 273
- ; TH0=0x70; //普通51定时器方式1,必须在发生中断时,重新赋值并再次启动计时
- ; SOURCE LINE # 274
- MOV TH0,#070H
- ; TL0=0; //Tick=50次/秒(即0.02秒/次),晶振22.1184M
- ; SOURCE LINE # 275
- CLR A
- MOV TL0,A
- ; TR0=1;
- ; SOURCE LINE # 276
- SETB TR0
- ; }
- ; SOURCE LINE # 277
- RET
- ; END OF UserTickTimer
- CSEG AT 0000BH
- LJMP OSTickISR
- ;
- ; /*
- ; ucOS-II系统时钟中断处理程序
- ; */
- ; void OSTickISR(void) interrupt 1
- RSEG ?PR?OSTickISR?OS_CPU_C
- USING 0
- OSTickISR:
- PUSH ACC
- PUSH B
- PUSH DPH
- PUSH DPL
- PUSH PSW
- MOV PSW,#00H
- PUSH AR0
- PUSH AR1
- PUSH AR2
- PUSH AR3
- PUSH AR4
- PUSH AR5
- PUSH AR6
- PUSH AR7
- USING 0
- ; SOURCE LINE # 282
- ; {
- ; OSIntEnter(); // Must be called first at every hardware interrupt entry point
- ; SOURCE LINE # 284
- LCALL _?OSIntEnter
- ; UserTickTimer(); // User functions can be called here.
- ; SOURCE LINE # 285
- LCALL UserTickTimer
- ; OSTimeTick(); // Must be called during tick isr
- ; SOURCE LINE # 286
- LCALL _?OSTimeTick
- ; OSIntExit(); // Must be called finally at every hardware interupt exit point
- ; SOURCE LINE # 287
- LCALL _?OSIntExit
- ; }
- ; SOURCE LINE # 288
- POP AR7
- POP AR6
- POP AR5
- POP AR4
- POP AR3
- POP AR2
- POP AR1
- POP AR0
- POP PSW
- POP DPL
- POP DPH
- POP B
- POP ACC
- RETI
- ; END OF OSTickISR
- CSEG AT 00023H
- LJMP SerialISR
- ;
- ; /*--------------------------------------------------------------*/
- ; /* ucOS-II的中断服务程序示例 */
- ; /*--------------------------------------------------------------*/
- ; #include "sourceserial.h"
- ;
- ; void SerialISR(void) interrupt 4
- RSEG ?PR?SerialISR?OS_CPU_C
- USING 0
- SerialISR:
- PUSH ACC
- PUSH B
- PUSH DPH
- PUSH DPL
- PUSH PSW
- MOV PSW,#00H
- PUSH AR0
- PUSH AR1
- PUSH AR2
- PUSH AR3
- PUSH AR4
- PUSH AR5
- PUSH AR6
- PUSH AR7
- USING 0
- ; SOURCE LINE # 295
- ; {
- ; #if OS_CRITICAL_METHOD == 3 // Allocate storage for CPU status register
- ; OS_CPU_SR cpu_sr;
- ; #endif
- ;
- ; OSIntEnter(); // Must be called first at every hardware interrupt entry point
- ; SOURCE LINE # 301
- LCALL _?OSIntEnter
- ; OS_ENTER_CRITICAL();
- ; SOURCE LINE # 302
- CLR EA
- ; if(TI)
- ; SOURCE LINE # 303
- JNB TI,?C0011
- ; {
- ; SOURCE LINE # 304
- ; TI=0;
- ; SOURCE LINE # 305
- CLR TI
- ; pc_send.ptr++;
- ; SOURCE LINE # 306
- MOV DPTR,#pc_send+04H
- MOVX A,@DPTR
- INC A
- MOVX @DPTR,A
- JNZ ?C0017
- MOV DPTR,#pc_send+03H
- MOVX A,@DPTR
- INC A
- MOVX @DPTR,A
- ?C0017:
- ; if (pc_send.ptr < pc_send.count)
- ; SOURCE LINE # 307
- MOV DPTR,#pc_send+05H
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV DPTR,#pc_send+03H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- CLR C
- SUBB A,R7
- MOV A,R6
- XRL A,#080H
- MOV R0,A
- MOV A,R4
- XRL A,#080H
- SUBB A,R0
- JNC ?C0013
- ; SBUF=pc_send.buffer[pc_send.ptr];
- ; SOURCE LINE # 308
- MOV DPTR,#pc_send
- MOVX A,@DPTR
- MOV R3,A
- INC DPTR
- MOVX A,@DPTR
- MOV R2,A
- INC DPTR
- MOVX A,@DPTR
- MOV R1,A
- MOV DPL,R5
- MOV DPH,R4
- LCALL ?C?CLDOPTR
- MOV SBUF,A
- ; }
- ; SOURCE LINE # 309
- SJMP ?C0013
- ?C0011:
- ; else if(RI)
- ; SOURCE LINE # 310
- JNB RI,?C0013
- ; {
- ; SOURCE LINE # 311
- ; RI=0;
- ; SOURCE LINE # 312
- CLR RI
- ; //处理输入字符
- ; }
- ; SOURCE LINE # 314
- ?C0013:
- ; OS_EXIT_CRITICAL();
- ; SOURCE LINE # 315
- SETB EA
- ;
- ; OSIntExit(); // Must be called finally at every hardware interupt exit point
- ; SOURCE LINE # 317
- LCALL _?OSIntExit
- ; }
- ; SOURCE LINE # 318
- POP AR7
- POP AR6
- POP AR5
- POP AR4
- POP AR3
- POP AR2
- POP AR1
- POP AR0
- POP PSW
- POP DPL
- POP DPH
- POP B
- POP ACC
- RETI
- ; END OF SerialISR
- ;
- ;
- ; /*
- ; 设置硬件寄存器的初始值。
- ; 初始化定时器0,作为ucOS-II的系统时钟。
- ; 还有其他的与硬件相关的初始化也可以放在这里。
- ; */
- ;
- ; //串口初始化 0xfd=19200,0xfa=9600,0xf4=4800,0xe8=2400,0xd0=1200
- ; void InitHardware(void) reentrant
- RSEG ?PR?_?InitHardware?OS_CPU_C
- _?InitHardware:
- ; SOURCE LINE # 328
- ; {
- ; TMOD = 0x21; //定时器0:模式1(16位定时器),仅受TR0控制;定时器1:波特率发生器
- ; SOURCE LINE # 330
- MOV TMOD,#021H
- ; TH0 = 0x70; //定义Tick=50次/秒(即0.02秒/次),TH,TL值与CPU的频率有关(22.1184M)
- ; SOURCE LINE # 331
- MOV TH0,#070H
- ; TL0 = 0x00; //OS_CPU_C.C中定时器中断响应也要设置,OS_CFG.H中OS_TICKS_PER_SEC也有关系
- ; SOURCE LINE # 332
- CLR A
- MOV TL0,A
- ; //ET0 = 1; //允许T0中断(在第一个任务开始执行时才开时钟中断,否则万一中断系统进入不可知状态)
- ; TR0 = 1;
- ; SOURCE LINE # 334
- SETB TR0
- ;
- ; TH1 = 0xFA; //晶振22.1084, 波特率 9600
- ; SOURCE LINE # 336
- MOV TH1,#0FAH
- ; ET1 = 0;
- ; SOURCE LINE # 337
- CLR ET1
- ; TR1 = 1; //start timer1
- ; SOURCE LINE # 338
- SETB TR1
- ; SCON = 0x50;
- ; SOURCE LINE # 339
- MOV SCON,#050H
- ; ES = 1;
- ; SOURCE LINE # 340
- SETB ES
- ;
- ; //设置串口收发的初始值
- ; pc_send.ptr=0;
- ; SOURCE LINE # 343
- MOV DPTR,#pc_send+03H
- MOVX @DPTR,A
- INC DPTR
- MOVX @DPTR,A
- ; pc_send.count=0;
- ; SOURCE LINE # 344
- INC DPTR
- MOVX @DPTR,A
- INC DPTR
- MOVX @DPTR,A
- ; ET0=1; //开时钟节拍中断
- ; SOURCE LINE # 345
- SETB ET0
- ; } ; SOURCE LINE # 346
- RET
- ; END OF _?InitHardware
- END