📄 os_cpu_a.lst
字号:
77
78 /** \ingroup avr_version
79 Library major version number. */
80 #define __AVR_LIBC_MAJOR__ 1
81
82 /** \ingroup avr_version
83 Library minor version number. */
84 #define __AVR_LIBC_MINOR__ 4
85
86 /** \ingroup avr_version
87 Library revision number. */
88 #define __AVR_LIBC_REVISION__ 4
89
90 #endif /* _AVR_VERSION_H_ */
91 ...
339
16 #define OS_CPU_A
17 #include "../Config/OS_CFG.h"
1 /*
2 ***************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 *
6 * (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
7 * All Rights Reserved
8 *
9 * uC/OS-II Configuration File for V2.8x
10 *
11 * File : OS_CFG.H
12 * By : Jean J. Labrosse
13 * Version : V2.85
14 *Modified: Xiawei <xiawei0311@gmail.com>
15 *
16 * LICENSING TERMS:
17 * ---------------
18 * uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful re
18 #include "OS_CPU.h"
1 /*
2 ***************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 *
6 * ATmega128 Specific code for V2.8x
7 *
8 * File : OS_CPU.H
9 * By : Xiawei <xiawei0311@gmail.com>
10 * AVR-GCC version : 4.1.1 , WinAVR 20070122
11 * Date : September 9th,2007
12 ***************************************************************************************************
13 */
14 #ifndef _OS_CPU_H_
15 #define _OS_CPU_H_
16
17
18 #include <avr/io.h>
19
19
20 ;**************************************************************************************************
21 ; I/O PORT ADDRESSES
22 ;**************************************************************************************************
23
24
25
26
27 ;**************************************************************************************************
28 ; PUBLIC DECLARATIONS
29 ;**************************************************************************************************
30
31 .global OSStartHighRdy
32 .global OSCtxSw
33 .global OSIntCtxSw
34 .global TIMER0_COMP_vect
35 .global OSTickISR
36 .global OSTickISR2
37 .global OS_CPU_SR_Save
38 .global OS_CPU_SR_Restore
39
40 ;**************************************************************************************************
41 ; EXTERNAL DECLARATIONS
42 ;**************************************************************************************************
43
44 .extern OSIntExit
45 .extern OSIntNesting
46 .extern OSPrioCur
47 .extern OSPrioHighRdy
48 .extern OSRunning
49 .extern OSTaskSwHook
50 .extern OSTCBCur
51 .extern OSTCBHighRdy
52 .extern OSTimeTick
53
54 ;**************************************************************************************************
55 ; MACROS
56 ;**************************************************************************************************
57
58 ; Push all registers and the status register
59 .macro PUSHRS
60 push r0
61 push r1
62 push r2
63 push r3
64 push r4
65 push r5
66 push r6
67 push r7
68 push r8
69 push r9
70 push r10
71 push r11
72 push r12
73 push r13
74 push r14
75 push r15
76 push r16
77 push r17
78 push r18
79 push r19
80 push r20
81 push r21
82 push r22
83 push r23
84 push r24
85 push r25
86 push r26
87 push r27
88 push r28
89 push r29
90 push r30
91 push r31
92 in r16,_SFR_IO_ADDR(SREG)
93 push r16
94
95 .endm
96
97 ; Pop all registers and the status registers
98 .macro POPRS
99
100 pop r16
101 out _SFR_IO_ADDR(SREG),r16
102 pop r31
103 pop r30
104 pop r29
105 pop r28
106 pop r27
107 pop r26
108 pop r25
109 pop r24
110 pop r23
111 pop r22
112 pop r21
113 pop r20
114 pop r19
115 pop r18
116 pop r17
117 pop r16
118 pop r15
119 pop r14
120 pop r13
121 pop r12
122 pop r11
123 pop r10
124 pop r9
125 pop r8
126 pop r7
127 pop r6
128 pop r5
129 pop r4
130 pop r3
131 pop r2
132 pop r1
133 pop r0
134
135 .endm
136
137 .text
138 .section .text
139
140
141 ;**************************************************************************************************
142 ; START HIGHEST PRIORITY TASK READY-TO-RUN
143 ;
144 ; Description : This function is called by OSStart() to start the highest priority task that was cr
145 ; by your application before calling OSStart().
146 ;
147 ; Note(s) : 1) The (data)stack frame is assumed to look as follows:
148 ;
149 ; OSTCBHighRdy->OSTCBStkPtr --> LSB of (return) stack pointer (Low memor
150 ; SPH of (return) stack pointer
151 ; Flags to load in status register
152 ; R31
153 ; R30
154 ; R7
155 ; .
156 ; .
157 ; .
158 ; R0 (High memo
159 ;
160 ; where the stack pointer points to the task start address.
161 ;
162 ;
163 ; 2) OSStartHighRdy() MUST:
164 ; a) Call OSTaskSwHook() then,
165 ; b) Set OSRunning to TRUE,
166 ; c) Switch to the highest priority task.
167 ;**************************************************************************************************
168
169 OSStartHighRdy:
170 #if OS_CPU_HOOKS_EN > 0
171:../AVR/OS_CPU_A.S **** CALL OSTaskSwHook ; Invoke user defined context switch hook
172 #endif
173:../AVR/OS_CPU_A.S **** LDS R16,OSRunning ; Indicate that we are multitasking
174:../AVR/OS_CPU_A.S **** INC R16 ;
175:../AVR/OS_CPU_A.S **** STS OSRunning,R16 ;
176
177:../AVR/OS_CPU_A.S **** LDS R30,OSTCBHighRdy ; Let Z point to TCB of highest priority task
178:../AVR/OS_CPU_A.S **** LDS R31,OSTCBHighRdy+1 ; ready to run
179
180:../AVR/OS_CPU_A.S **** LD R28,Z+ ; Load stack L pointer
181:../AVR/OS_CPU_A.S **** OUT _SFR_IO_ADDR(SPL),R28
182:../AVR/OS_CPU_A.S **** LD R29,Z+ ;
183:../AVR/OS_CPU_A.S **** OUT _SFR_IO_ADDR(SPH),R29
184
185:../AVR/OS_CPU_A.S **** POPRS ; Pop all registers and status register
186:../AVR/OS_CPU_A.S **** RET ; Start task
187
188 ;**************************************************************************************************
189 ; TASK LEVEL CONTEXT SWITCH
190 ;
191 ; Description : This function is called when a task makes a higher priority task ready-to-run.
192 ;
193 ; Note(s) : 1) Upon entry,
194 ; OSTCBCur points to the OS_TCB of the task to suspend
195 ; OSTCBHighRdy points to the OS_TCB of the task to resume
196 ;
197 ; 2) The stack frame of the task to suspend looks as follows:
198 ;
199 ; SP+0 --> LSB of task code address
200 ; +1 MSB of task code address (High memo
201 ;
202 ; 3) The saved context of the task to resume looks as follows:
203 ;
204 ; OSTCBHighRdy->OSTCBStkPtr --> LSB of (return) stack pointer (Low memor
205 ; SPH of (return) stack pointer
206 ; Flags to load in status register
207 ; R31
208 ; R30
209 ; R7
210 ; .
211 ; .
212 ; .
213 ; R0 (High memo
214 ;**************************************************************************************************
215
216 OSCtxSw:
217:../AVR/OS_CPU_A.S **** PUSHRS ; Save current tasks context
218
219:../AVR/OS_CPU_A.S *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -