?? artx_config.lst
字號:
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 1
ARM COMPILER V2.42, COMPILATION OF MODULE ARTX_Config
OBJECT MODULE PLACED IN ARTX_Config.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe ARTX_Config.c THUMB BROWSE DEBUG TABS(4)
stmt level source
1 /*----------------------------------------------------------------------------
2 * A R T X - K e r n e l
3 *----------------------------------------------------------------------------
4 * Name: ARTX_CONFIG.C
5 * Purpose: Configuration of ARTX Kernel for Philips LPC21xx
6 * Rev.: V2.00 / 19-oct-2005
7 *----------------------------------------------------------------------------
8 * This code is part of the ARTX-ARM kernel package of Keil Software.
9 * Copyright (c) 2004-2005 Keil Software. All rights reserved.
10 *---------------------------------------------------------------------------*/
11
12 #pragma INTERWORK
13 #define NOFRAME __arm __task
14
15 #include <LPC213x.H> /* LPC21xx definitions */
16 #include <LPC213xdef.H> /* LPC21xx definitions */
17 #include <ARTX_Config.h> /* ARTX user configuration header */
18
19 /*----------------------------------------------------------------------------
20 * ARTX User configuration part BEGIN
21 *---------------------------------------------------------------------------*/
22
23 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
24 //
25 // <h>Task Definitions
26 // ===================
27 //
28 // <o>Number of concurrent running tasks <0-250>
29 // <i> Define max. number of tasks that will run at the same time.
30 // <i> Default: 6
31 #ifndef OS_TASKCNT
32 #define OS_TASKCNT 10
33 #endif
34
35 // <o>Number of tasks with user-provided stack <0-250>
36 // <i> Define the number of tasks that will use a bigger stack.
37 // <i> The memory space for the stack is provided by the user.
38 // <i> Default: 0
39 #ifndef OS_PRIVCNT
40 #define OS_PRIVCNT 0
41 #endif
42
43 // <o>Task stack size [bytes] <20-4096:4><#/4>
44 // <i> Set the stack size for tasks which is assigned by the system.
45 // <i> Default: 200
46 #ifndef OS_STKSIZE
47 #define OS_STKSIZE 50
48 #endif
49
50 // <q>Check for the stack overflow
51 // ===============================
52 // <i> Include the stack checking code for a stack overflow.
53 // <i> Note that additional code reduces the Kernel performance.
54 #ifndef OS_STKCHECK
55 #define OS_STKCHECK 1
56 #endif
57
58 // <o>Number of user timers <0-250>
59 // <i> Define max. number of user timers that will run at the same time.
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 2
60 // <i> Default: 0 (User timers disabled)
61 #ifndef OS_TIMERCNT
62 #define OS_TIMERCNT 0
63 #endif
64
65 // </h>
66 // <h>System Timer Configuration
67 // =============================
68 // <o>ARTX Kernel timer number <0=> Timer 0 <1=> Timer 1
69 // <i> Define the ARM timer used as a system tick timer.
70 // <i> Default: Timer 0
71 #ifndef OS_TIMER
72 #define OS_TIMER 1
73 #endif
74
75 // <o>Timer clock value [Hz] <1-1000000000>
76 // <i> Set the timer clock value for selected timer.
77 // <i> Default: 15000000 (15MHz at 60MHz CCLK and VPBDIV = 4)
78 #ifndef OS_CLOCK
79 #define OS_CLOCK 15000000
80 #endif
81
82 // <o>Timer tick value [us] <1-1000000>
83 // <i> Set the timer tick value for selected timer.
84 // <i> Default: 10000 (10ms)
85 #ifndef OS_TICK
86 #define OS_TICK 10000
87 #endif
88
89 // </h>
90 // <e>Round-Robin Task switching
91 // =============================
92 // <i> Enable Round-Robin Task switching.
93 #ifndef OS_ROBIN
94 #define OS_ROBIN 1
95 #endif
96
97 // <o>Round-Robin Timeout [ticks] <1-1000>
98 // <i> Define how long a task will execute before a task switch.
99 // <i> Default: 5
100 #ifndef OS_ROBINTOUT
101 #define OS_ROBINTOUT 5
102 #endif
103
104 // </e>
105
106 //------------- <<< end of configuration section >>> -----------------------
107
108 /*----------------------------------------------------------------------------
109 * ARTX User configuration part END
110 *---------------------------------------------------------------------------*/
111
112 #if (OS_TIMER == 0) /* Timer 0 */
#define OS_TID_ 4 /* Timer ID */
#define OS_TIM_ (1 << OS_TID_) /* Interrupt Mask */
#define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
#define OS_TVAL T0TC /* Timer Value */
#define OS_TOVF (T0IR & 1) /* Overflow Flag */
#define OS_TREL() ; /* Timer Reload */
#define OS_TFIRQ() VICSoftInt |= OS_TIM_; /* Force Interrupt */
#define OS_TIACK() T0IR = 1; /* Interrupt Ack */ \
VICSoftIntClr = OS_TIM_; \
VICVectAddr = 0;
#define OS_TINIT() T0MR0 = OS_TRV; /* Initialization */ \
T0MCR = 3; \
T0TCR = 1; \
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 3
VICDefVectAddr = (U32)os_def_interrupt; \
VICVectAddr15 = (U32)os_clock_interrupt; \
VICVectCntl15 = 0x20 | OS_TID_;
#elif (OS_TIMER == 1) /* Timer 1 */
130 #define OS_TID_ 5 /* Timer ID */
131 #define OS_TIM_ (1 << OS_TID_) /* Interrupt Mask */
132 #define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
133 #define OS_TVAL T1TC /* Timer Value */
134 #define OS_TOVF (T1IR & 1) /* Overflow Flag */
135 #define OS_TREL() ; /* Timer Reload */
136 #define OS_TFIRQ() VICSoftInt |= OS_TIM_; /* Force Interrupt */
137 #define OS_TIACK() T1IR = 1; /* Interrupt Ack */ \
138 VICSoftIntClr = OS_TIM_; \
139 VICVectAddr = 0;
140 #define OS_TINIT() T1MR0 = OS_TRV; /* Initialization */ \
141 T1MCR = 3; \
142 T1TCR = 1; \
143 VICDefVectAddr = (U32)os_def_interrupt; \
144 VICVectAddr15 = (U32)os_clock_interrupt; \
145 VICVectCntl15 = 0x20 | OS_TID_;
146 #else
#error OS_TIMER invalid
#endif
149
150 #define OS_IACK() VICVectAddr = 0; /* Interrupt Ack */
151
152 #define OS_LOCK() VICIntEnClr = OS_TIM_; /* Task Lock */
153 #define OS_UNLOCK() VICIntEnable |= OS_TIM_; /* Task Unlock */
154
155 /* WARNING ! Do not use IDLE mode if you are using a JTAG interface */
156 /* for debugging your application. */
157 #define _idle_() PCON = 1;
158 #define INITIAL_CPSR 0x40000010
159 #define MAGIC_WORD 0xE25A2EA5
160
161 /*----------------------------------------------------------------------------
162 * Global Variables
163 *---------------------------------------------------------------------------*/
164
165 extern P_TCB os_runtask;
166 extern struct OS_XCB os_rdy;
167 extern struct OS_TCB os_clock_TCB;
168 extern U16 os_time;
169 U16 const os_maxtaskrun = OS_TASKCNT;
170 /* Export following defines to uVision debugger. */
171 U32 const os_stackinfo = (OS_STKCHECK<<24) | (OS_PRIVCNT<<16) | (OS_STKSIZE*4);
172 U32 const os_clockrate = OS_TICK;
173 U32 const os_timernum = (OS_TIMER << 16) | OS_TIMERCNT;
174 U32 const os_rrobin = (OS_ROBIN << 16) | OS_ROBINTOUT;
175
176 /*----------------------------------------------------------------------------
177 * Local Variables
178 *---------------------------------------------------------------------------*/
179 /* Memory pool for TCB allocation */
180 static U32 m_tcb[(sizeof(struct OS_TCB) * OS_TASKCNT)/4 + 3];
181
182 /* Memory pool for System stack allocation. Need to allocate 2 additional */
183 /* entries for 'os_clock_demon()' and 'os_idle_demon()'. */
184 static U32 m_stk[OS_STKSIZE * (OS_TASKCNT-OS_PRIVCNT+2) + 3];
185
186 /* An array of Active task pointers. */
187 P_TCB os_active_TCB[OS_TASKCNT];
188
189 #if (OS_ROBIN == 1)
190 static U16 os_robin_time;
191 static P_TCB os_tsk_robin;
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 4
192 #endif
193
194 #if (OS_TIMERCNT != 0)
/* Memory pool for User Timer allocation */
static U32 m_tmr[(sizeof(struct OS_TMR) * OS_TIMERCNT)/4 + 3];
#endif
198
199 #if (OS_STKCHECK == 1)
200 static BIT os_del_flag;
201 #endif
202
203 /*----------------------------------------------------------------------------
204 * Global Functions
205 *---------------------------------------------------------------------------*/
206
207 /*--------------------------- os_idle_demon ---------------------------------*/
208
209 void os_idle_demon (void) __task {
210 1 /* The idle demon is a system task. It is running when no other task is */
211 1 /* ready to run (idle situation). It must not terminate. Therefore it */
212 1 /* should contain at least an endless loop. */
213 1
214 1 for (;;) {
215 2 /* HERE: include here optional user code to be executed when no task runs.*/
216 2 _idle_();//PWM
217 2 }
218 1 } /* end of os_idle_demon */
219
220
221 /*--------------------------- os_tmr_call -----------------------------------*/
222
223 void os_tmr_call (U16 info) {
224 1 /* This function is called when the user timer has expired. */
225 1 /* Parameter "info" is the parameter defined when the timer was created. */
226 1 /* HERE: include here optional user code to be executed on timeout. */
227 1 info = info;
228 1 } /* end of os_tmr_call */
229
230 /*--------------------------- os_stk_overflow -------------------------------*/
231
232 #if (OS_STKCHECK == 1)
233 static void os_stk_overflow (void) {
234 1 /* This function is called when a stack overflow is detected. */
235 1 /* 'os_runtask' points to a TCB of a task which has a stack overflow */
236 1 /* 'task_id' holds a task id for this task */
237 1 /* HERE: include here optional code to be executed on stack overflow. */
238 1 static OS_TID task_id;
239 1
240 1 /* Get a task identification for a task with stack problem to 'task_id'.*/
241 1 task_id = os_get_TID (os_runtask);
242 1 /* Use a uVision 'Advanced RTX' debug dialog page 'Active Tasks' to */
243 1 /* check which task has got a stack overflow and needs a bigger stack. */
244 1 for (;;);
245 1 }
246 #endif
247
248 /*--------------------------- os_clock_interrupt ----------------------------*/
249
250 void os_clock_interrupt (void) NOFRAME {
251 1 /* Do task switch to clock demon: entered upon a clock interrupt. */
252 1 __asm {
253 1 STMDB SP!,{R0-R1} ; Save Full Context
254 1 STMDB SP,{SP}^ ; User SP
255 1 LDMDB SP,{R0}
256 1 MRS R1,SPSR ; User CPSR
257 1 SUB LR,LR,#0x4
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 5
258 1 STMDB R0!,{R1,LR} ; Push PC, CPSR
259 1 STMDB R0,{LR}^ ; Push User LR
260 1 SUB R0,R0,#0x4 ; Write back problem !!
261 1 STMDB R0!,{R2-R12} ; Push R12-R2
262 1 LDMIA SP!,{R2-R3}
263 1 STMDB R0!,{R2-R3} ; Push R1-R0
264 1
265 1 LDR R1,=os_runtask ; os_runtask
266 1 LDR R1,[R1,#0x0] ; os_runtask
267 1 STR R0,[R1,#TCB_TSTACK] ; os_runtask->tsk_stack
268 1 }
269 1 OS_TIACK();
270 1 tsk_lock ();
271 1 os_runtask->full_ctx = __TRUE;
272 1 os_runtask->state = READY;
273 1 os_put_rdy_first (os_runtask);
274 1 os_runtask = &os_clock_TCB;
275 1 os_clock_TCB.state = RUNNING;
276 1 __asm {
277 1 LDR R0,=os_runtask ; os_runtask
278 1 LDR R0,[R0,#0x0] ; os_runtask
279 1 LDR R0,[R0,#TCB_TSTACK] ; os_runtask->tsk_stack
280 1
281 1 LDMIA R0!,{R4-R8,R12}
282 1 MSR SPSR_cxsf,R8
283 1 STMDB SP,{R0} ; Set User SP
284 1 LDMDB SP,{SP}^
285 1 MOVS PC,R12 ; RETI
286 1 }
287 1 } /* end of os_clock_interrupt */
288
289 /*--------------------------- os_def_interrupt ------------------------------*/
290
291 void os_def_interrupt (void) __irq {
292 1 /* Default Interrupt Function: may be called when timer ISR is disabled */
293 1 OS_IACK();
294 1 }
295
296 /*--------------------------- os_tmr_init -----------------------------------*/
297
298 void os_tmr_init (void) {
299 1 /* Initialize hardware timer as system tick timer. This function is */
300 1 /* called at the system startup. */
301 1 OS_TINIT();
302 1 #if (OS_ROBIN == 1)
303 1 os_robin_time = OS_ROBINTOUT;
304 1 #endif
305 1 } /* end of os_tmr_init */
306
307 /*--------------------------- os_tmr_reload ---------------------------------*/
308
309 void os_tmr_reload (void) {
310 1 /* Reload system timer for next period if a timer requires reload. */
311 1 OS_TREL();
312 1 } /* end of os_tmr_reload */
313
314 /*--------------------------- os_tmr_force_irq ------------------------------*/
315
316 void os_tmr_force_irq (void) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -