📄 ucosii.lst
字号:
(0055) *********************************************************************************************************
(0056) * TASK CREATION HOOK
(0057) *
(0058) * Description: This function is called when a task is created.
(0059) *
(0060) * Arguments : ptcb is a pointer to the task control block of the task being created.
(0061) *
(0062) * Note(s) : 1) Interrupts are disabled during this call.
(0063) *********************************************************************************************************
(0064) */
(0065) #if OS_CPU_HOOKS_EN > 0
(0066) void OSTaskCreateHook (OS_TCB *ptcb)
(0067) {
(0068) #ifdef OS_VIEW_MODULE
(0069) OSView_TaskCreateHook(ptcb);
(0070) #else
(0071) ptcb = ptcb; /* Prevent compiler warning */
(0072) #endif
(0073) }
_OSTaskCreateHook:
ptcb --> R16
0121 9508 RET
(0074) #endif
(0075)
(0076)
(0077) /*
(0078) *********************************************************************************************************
(0079) * TASK DELETION HOOK
(0080) *
(0081) * Description: This function is called when a task is deleted.
(0082) *
(0083) * Arguments : ptcb is a pointer to the task control block of the task being deleted.
(0084) *
(0085) * Note(s) : 1) Interrupts are disabled during this call.
(0086) *********************************************************************************************************
(0087) */
(0088) #if OS_CPU_HOOKS_EN > 0
(0089) void OSTaskDelHook (OS_TCB *ptcb)
(0090) {
(0091) ptcb = ptcb; /* Prevent compiler warning */
(0092) }
_OSTaskDelHook:
ptcb --> R16
0122 9508 RET
(0093) #endif
(0094)
(0095) /*
(0096) *********************************************************************************************************
(0097) * IDLE TASK HOOK
(0098) *
(0099) * Description: This function is called by the idle task. This hook has been added to allow you to do
(0100) * such things as STOP the CPU to conserve power.
(0101) *
(0102) * Arguments : none
(0103) *
(0104) * Note(s) : 1) Interrupts are enabled during this call.
(0105) *********************************************************************************************************
(0106) */
(0107) #if OS_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
(0108) void OSTaskIdleHook (void)
(0109) {
(0110) }
_OSTaskIdleHook:
0123 9508 RET
(0111) #endif
(0112)
(0113) /*
(0114) *********************************************************************************************************
(0115) * STATISTIC TASK HOOK
(0116) *
(0117) * Description: This function is called every second by uC/OS-II's statistics task. This allows your
(0118) * application to add functionality to the statistics task.
(0119) *
(0120) * Arguments : none
(0121) *********************************************************************************************************
(0122) */
(0123)
(0124) #if OS_CPU_HOOKS_EN > 0
(0125) void OSTaskStatHook (void)
(0126) {
(0127) }
_OSTaskStatHook:
0124 9508 RET
_OSTaskStkInit:
phard_stk --> R10
tmp --> R22
psoft_stk --> R20
opt --> Y+8
ptos --> Y+6
p_arg --> R18
task --> R16
0125 940E0E5B CALL push_gset3
(0128) #endif
(0129)
(0130) /*$PAGE*/
(0131) /*
(0132) **********************************************************************************************************
(0133) * INITIALIZE A TASK'S STACK
(0134) *
(0135) * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
(0136) * stack frame of the task being created. This function is highly processor specific.
(0137) *
(0138) * Arguments : task is a pointer to the task code
(0139) *
(0140) * p_arg is a pointer to a user supplied data area that will be passed to the task
(0141) * when the task first executes.
(0142) *
(0143) * ptos is a pointer to the top of stack. It is assumed that 'ptos' points to the
(0144) * highest valid address on the stack.
(0145) *
(0146) * opt specifies options that can be used to alter the behavior of OSTaskStkInit().
(0147) * (see uCOS_II.H for OS_TASK_OPT_???).
(0148) *
(0149) * Returns : Always returns the location of the new top-of-stack' once the processor registers have
(0150) * been placed on the stack in the proper order.
(0151) *
(0152) * Note(s) : Interrupts are enabled when your task starts executing. You can change this by setting the
(0153) * SREG to 0x00 instead. In this case, interrupts would be disabled upon task startup. The
(0154) * application code would be responsible for enabling interrupts at the beginning of the task
(0155) * code. You will need to modify OSTaskIdle() and OSTaskStat() so that they enable interrupts.
(0156) * Failure to do this will make your system crash!
(0157) *
(0158) * The AVR return stack is placed OS_TASK_HARD_STK_SIZE bytes before the bottom of the task's
(0159) * stack.
(0160) *
(0161) * (1) IMPORTANT: The ICC compiler handles function pointers by actually passing the pointer
(0162) * to a location in Flash that actually contains the pointer to the function.
(0163) **********************************************************************************************************
(0164) */
(0165)
(0166) OS_STK *OSTaskStkInit (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT16U opt)
(0167) {
(0168) INT8U *psoft_stk;
(0169) INT8U *phard_stk; /* Temp. variable used for setting up AVR hardware stack */
(0170) INT16U tmp;
(0171)
(0172)
(0173) opt = opt; /* 'opt' is not used, prevent warning */
(0174) psoft_stk = (INT8U *)ptos;
0127 814E LDD R20,Y+6
0128 815F LDD R21,Y+7
(0175) phard_stk = (INT8U *)ptos
0129 90200102 LDS R2,_OSTaskStkSize
012B 90300103 LDS R3,_OSTaskStkSize+1
012D 012A MOVW R4,R20
012E 1842 SUB R4,R2
012F 0853 SBC R5,R3
0130 90A00100 LDS R10,_OSTaskHardStkSize
0132 90B00101 LDS R11,_OSTaskHardStkSize+1
0134 0CA4 ADD R10,R4
0135 1CB5 ADC R11,R5
(0176) - OSTaskStkSize /* Task stack size */
(0177) + OSTaskHardStkSize; /* AVR return stack ("hardware stack") */
(0178)
(0179) tmp = *(INT16U const *)task; /* (1) ICC compiler handles function pointers indirectly! */
0136 01F8 MOVW R30,R16
0137 9165 LPM R22,Z+
0138 9174 LPM R23,0(Z)
(0180)
(0181) *phard_stk-- = (INT8U)tmp; /* Put task start address on top of "hardware stack" */
0139 0115 MOVW R2,R10
013A 01C1 MOVW R24,R2
013B 9701 SBIW R24,1
013C 01F1 MOVW R30,R2
013D 8360 STD Z+0,R22
(0182) *phard_stk-- = (INT8U)(tmp >> 8);
013E 011C MOVW R2,R24
013F 9701 SBIW R24,1
0140 015C MOVW R10,R24
0141 012B MOVW R4,R22
0142 2C45 MOV R4,R5
0143 2455 CLR R5
0144 01F1 MOVW R30,R2
0145 8240 STD Z+0,R4
(0183)
(0184) *psoft_stk-- = (INT8U)0x00; /* R0 = 0x00 */
0146 011A MOVW R2,R20
0147 5041 SUBI R20,1
0148 4050 SBCI R21,0
0149 2444 CLR R4
014A 01F1 MOVW R30,R2
014B 8240 STD Z+0,R4
(0185) *psoft_stk-- = (INT8U)0x01; /* R1 = 0x01 */
014C 011A MOVW R2,R20
014D 5041 SUBI R20,1
014E 4050 SBCI R21,0
014F E081 LDI R24,1
0150 01F1 MOVW R30,R2
0151 8380 STD Z+0,R24
(0186) *psoft_stk-- = (INT8U)0x02; /* R2 = 0x02 */
0152 011A MOVW R2,R20
0153 5041 SUBI R20,1
0154 4050 SBCI R21,0
0155 E082 LDI R24,2
0156 01F1 MOVW R30,R2
0157 8380 STD Z+0,R24
(0187) *psoft_stk-- = (INT8U)0x03; /* R3 = 0x03 */
0158 011A MOVW R2,R20
0159 5041 SUBI R20,1
015A 4050 SBCI R21,0
015B E083 LDI R24,3
015C 01F1 MOVW R30,R2
015D 8380 STD Z+0,R24
(0188) *psoft_stk-- = (INT8U)0x04; /* R4 = 0x04 */
015E 011A MOVW R2,R20
015F 5041 SUBI R20,1
0160 4050 SBCI R21,0
0161 E084 LDI R24,4
0162 01F1 MOVW R30,R2
0163 8380 STD Z+0,R24
(0189) *psoft_stk-- = (INT8U)0x05; /* R5 = 0x05 */
0164 011A MOVW R2,R20
0165 5041 SUBI R20,1
0166 4050 SBCI R21,0
0167 E085 LDI R24,5
0168 01F1 MOVW R30,R2
0169 8380 STD Z+0,R24
(0190) *psoft_stk-- = (INT8U)0x06; /* R6 = 0x06 */
016A 011A MOVW R2,R20
016B 5041 SUBI R20,1
016C 4050 SBCI R21,0
016D E086 LDI R24,6
016E 01F1 MOVW R30,R2
016F 8380 STD Z+0,R24
(0191) *psoft_stk-- = (INT8U)0x07; /* R7 = 0x07 */
0170 011A MOVW R2,R20
0171 5041 SUBI R20,1
0172 4050 SBCI R21,0
0173 E087 LDI R24,7
0174 01F1 MOVW R30,R2
0175 8380 STD Z+0,R24
(0192) *psoft_stk-- = (INT8U)0x08; /* R8 = 0x08 */
0176 011A MOVW R2,R20
0177 5041 SUBI R20,1
0178 4050 SBCI R21,0
0179 E088 LDI R24,0x8
017A 01F1 MOVW R30,R2
017B 8380 STD Z+0,R24
(0193) *psoft_stk-- = (INT8U)0x09; /* R9 = 0x09 */
017C 011A MOVW R2,R20
017D 5041 SUBI R20,1
017E 4050 SBCI R21,0
017F E089 LDI R24,0x9
0180 01F1 MOVW R30,R2
0181 8380 STD Z+0,R24
(0194) *psoft_stk-- = (INT8U)0x10; /* R10 = 0x10 */
0182 011A MOVW R2,R20
0183 5041 SUBI R20,1
0184 4050 SBCI R21,0
0185 E180 LDI R24,0x10
0186 01F1 MOVW R30,R2
0187 8380 STD Z+0,R24
(0195) *psoft_stk-- = (INT8U)0x11; /* R11 = 0x11 */
0188 011A MOVW R2,R20
0189 5041 SUBI R20,1
018A 4050 SBCI R21,0
018B E181 LDI R24,0x11
018C 01F1 MOVW R30,R2
018D 8380 STD Z+0,R24
(0196) *psoft_stk-- = (INT8U)0x12; /* R12 = 0x12 */
018E 011A MOVW R2,R20
018F 5041 SUBI R20,1
0190 4050 SBCI R21,0
0191 E182 LDI R24,0x12
0192 01F1 MOVW R30,R2
0193 8380 STD Z+0,R24
(0197) *psoft_stk-- = (INT8U)0x13; /* R13 = 0x13 */
0194 011A MOVW R2,R20
0195 5041 SUBI R20,1
0196 4050 SBCI R21,0
0197 E183 LDI R24,0x13
0198 01F1 MOVW R30,R2
0199 8380 STD Z+0,R24
(0198) *psoft_stk-- = (INT8U)0x14; /* R14 = 0x14 */
019A 011A MOVW R2,R20
019B 5041 SUBI R20,1
019C 4050 SBCI R21,0
019D E184 LDI R24,0x14
019E 01F1 MOVW R30,R2
019F 8380 STD Z+0,R24
(0199) *psoft_stk-- = (INT8U)0x15; /* R15 = 0x15 */
01A0 011A MOVW R2,R20
01A1 5041 SUBI R20,1
01A2 4050 SBCI R21,0
01A3 E185 LDI R24,0x15
01A4 01F1 MOVW R30,R2
01A5 8380 STD Z+0,R24
(0200) tmp = (INT16U)p_arg;
01A6 01B9 MOVW R22,R18
(0201) *psoft_stk-- = (INT8U)tmp; /* 'p_arg' passed in R17:R16 */
01A7 011A MOVW R2,R20
01A8 5041 SUBI R20,1
01A9 4050 SBCI R21,0
01AA 01F1 MOVW R30,R2
01AB 8360 STD Z+0,R22
(0202) *psoft_stk-- = (INT8U)(tmp >> 8);
01AC 011A MOVW R2,R20
01AD 5041 SUBI R20,1
01AE 4050 SBCI R21,0
01AF 012B MOVW R4,R22
01B0 2C45 MOV R4,R5
01B1 2455 CLR R5
01B2 01F1 MOVW R30,R2
01B3 8240 STD Z+0,R4
(0203) *psoft_stk-- = (INT8U)0x18; /* R18 = 0x18 */
01B4 011A MOVW R2,R20
01B5 5041 SUBI R20,1
01B6 4050 SBCI R21,0
01B7 E188 LDI R24,0x18
01B8 01F1 MOVW R30,R2
01B9 8380 STD Z+0,R24
(0204) *psoft_stk-- = (INT8U)0x19; /* R19 = 0x19 */
01BA 011A MOVW R2,R20
01BB 5041 SUBI R20,1
01BC 4050 SBCI R21,0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -