]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/Softune/MB96340/port.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / portable / Softune / MB96340 / port.c
1 /*\r
2     FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 #include "FreeRTOS.h"\r
71 #include "task.h"\r
72 \r
73 /*-----------------------------------------------------------\r
74  * Implementation of functions defined in portable.h for the 16FX port.\r
75  *----------------------------------------------------------*/\r
76 \r
77 /* \r
78  * Get current value of DPR and ADB registers \r
79  */\r
80 StackType_t xGet_DPR_ADB_bank( void ); \r
81 \r
82 /* \r
83  * Get current value of DTB and PCB registers \r
84  */\r
85 StackType_t xGet_DTB_PCB_bank( void );\r
86 \r
87 /*\r
88  * Sets up the periodic ISR used for the RTOS tick.  This uses RLT0, but\r
89  * can be done using any given RLT.\r
90  */\r
91 static void prvSetupRLT0Interrupt( void );\r
92 \r
93 /*-----------------------------------------------------------*/\r
94 \r
95 /* \r
96  * We require the address of the pxCurrentTCB variable, but don't want to know\r
97  * any details of its type. \r
98  */\r
99 typedef void TCB_t;\r
100 extern volatile TCB_t * volatile pxCurrentTCB;\r
101 \r
102 /*-----------------------------------------------------------*/\r
103 \r
104 /* \r
105  * Macro to save a task context to the task stack. This macro  copies the \r
106  * saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from  the   system \r
107  * stack to task stack pointed by user stack pointer ( USP  for SMALL and \r
108  * MEDIUM memory model amd USB:USP for COMPACT  and LARGE memory model ),\r
109  * then  it pushes the general purpose registers RW0-RW7  on  to the task \r
110  * stack. Finally the  resultant  stack  pointer  value is saved into the \r
111  * task  control  block  so  it  can  be retrieved the next time the task \r
112  * executes.\r
113  */ \r
114 #if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )\r
115 \r
116         #define portSAVE_CONTEXT()                                                                                      \\r
117                         {       __asm(" POPW  A ");                                                                             \\r
118                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
119                                 __asm(" PUSHW  A ");                                                                    \\r
120                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
121                         __asm(" POPW  A ");                                                                             \\r
122                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
123                                 __asm(" PUSHW  A ");                                                                    \\r
124                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
125                                 __asm(" POPW  A ");                                                                             \\r
126                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
127                                 __asm(" PUSHW  A ");                                                                    \\r
128                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
129                                 __asm(" POPW  A ");                                                                             \\r
130                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
131                                 __asm(" PUSHW  A ");                                                                    \\r
132                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
133                                 __asm(" POPW  A ");                                                                             \\r
134                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
135                                 __asm(" PUSHW  A ");                                                                    \\r
136                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
137                                 __asm(" POPW  A ");                                                                             \\r
138                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
139                                 __asm(" PUSHW  A ");                                                                    \\r
140                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
141                                 __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
142                                 __asm(" MOVW A, SP ");                                                                  \\r
143                                 __asm(" SWAPW ");                                                                               \\r
144                                 __asm(" MOVW @AL, AH ");                                                                \\r
145                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
146                         }\r
147 \r
148 /* \r
149  * Macro to restore a task context from the task stack.  This is effecti-\r
150  * vely the reverse of SAVE_CONTEXT(). First the stack pointer  value\r
151  * (USP for SMALL and MEDIUM memory model amd  USB:USP  for  COMPACT  and \r
152  * LARGE memory model ) is loaded from the task  control block.  Next the \r
153  * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
154  * lly it copies of the context ( AH:AL,  DPR:ADB, DTB:PCB, PC and PS) of \r
155  * the task to be executed upon RETI from user stack to system stack.  \r
156  */\r
157  \r
158         #define portRESTORE_CONTEXT()                                                                           \\r
159                         {       __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
160                                 __asm(" MOVW A, @A ");                                                                  \\r
161                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
162                                 __asm(" MOVW SP, A ");                                                                  \\r
163                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
164                                 __asm(" POPW  A ");                                                                             \\r
165                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
166                                 __asm(" PUSHW  A ");                                                                    \\r
167                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
168                                 __asm(" POPW  A ");                                                                             \\r
169                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
170                                 __asm(" PUSHW  A ");                                                                    \\r
171                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
172                                 __asm(" POPW  A ");                                                                             \\r
173                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
174                                 __asm(" PUSHW  A ");                                                                    \\r
175                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
176                                 __asm(" POPW  A ");                                                                             \\r
177                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
178                                 __asm(" PUSHW  A ");                                                                    \\r
179                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
180                                 __asm(" POPW  A ");                                                                             \\r
181                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
182                                 __asm(" PUSHW  A ");                                                                    \\r
183                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
184                                 __asm(" POPW  A ");                                                                             \\r
185                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
186                                 __asm(" PUSHW  A ");                                                                    \\r
187                         }\r
188                 \r
189 #elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
190 \r
191         #define portSAVE_CONTEXT()                                                                                      \\r
192                         {       __asm(" POPW  A ");                                                                             \\r
193                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
194                                 __asm(" PUSHW  A ");                                                                    \\r
195                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
196                         __asm(" POPW  A ");                                                                             \\r
197                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
198                                 __asm(" PUSHW  A ");                                                                    \\r
199                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
200                                 __asm(" POPW  A ");                                                                             \\r
201                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
202                                 __asm(" PUSHW  A ");                                                                    \\r
203                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
204                                 __asm(" POPW  A ");                                                                             \\r
205                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
206                                 __asm(" PUSHW  A ");                                                                    \\r
207                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
208                                 __asm(" POPW  A ");                                                                             \\r
209                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
210                                 __asm(" PUSHW  A ");                                                                    \\r
211                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
212                                 __asm(" POPW  A ");                                                                             \\r
213                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
214                                 __asm(" PUSHW  A ");                                                                    \\r
215                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
216                                 __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
217                                 __asm(" MOVL RL2, A ");                                                                 \\r
218                                 __asm(" MOVW A, SP ");                                                                  \\r
219                                 __asm(" MOVW @RL2+0, A ");                                                              \\r
220                                 __asm(" MOV A, USB ");                                                                  \\r
221                                 __asm(" MOV @RL2+2, A ");                                                               \\r
222                         }       \r
223             \r
224         #define portRESTORE_CONTEXT()                                                                           \\r
225                         {       __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
226                                 __asm(" MOVL RL2, A ");                                                                 \\r
227                                 __asm(" MOVW A, @RL2+0 ");                                                              \\r
228                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
229                                 __asm(" MOVW SP, A ");                                                                  \\r
230                                 __asm(" MOV A, @RL2+2 ");                                                               \\r
231                                 __asm(" MOV USB, A ");                                                                  \\r
232                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
233                                 __asm(" POPW  A ");                                                                             \\r
234                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
235                                 __asm(" PUSHW  A ");                                                                    \\r
236                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
237                                 __asm(" POPW  A ");                                                                             \\r
238                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
239                                 __asm(" PUSHW  A ");                                                                    \\r
240                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
241                                 __asm(" POPW  A ");                                                                             \\r
242                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
243                                 __asm(" PUSHW  A ");                                                                    \\r
244                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
245                                 __asm(" POPW  A ");                                                                             \\r
246                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
247                                 __asm(" PUSHW  A ");                                                                    \\r
248                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
249                                 __asm(" POPW  A ");                                                                             \\r
250                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
251                                 __asm(" PUSHW  A ");                                                                    \\r
252                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
253                                 __asm(" POPW  A ");                                                                             \\r
254                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
255                                 __asm(" PUSHW  A ");                                                                    \\r
256                         }\r
257 #endif\r
258 \r
259 /*-----------------------------------------------------------*/ \r
260 \r
261 /* \r
262  * Functions for obtaining the current value  of  DPR:ADB, DTB:PCB bank registers\r
263  */\r
264  \r
265 #pragma asm\r
266 \r
267         .GLOBAL    _xGet_DPR_ADB_bank\r
268         .GLOBAL    _xGet_DTB_PCB_bank\r
269         .SECTION   CODE, CODE, ALIGN=1\r
270 \r
271 _xGet_DPR_ADB_bank:\r
272 \r
273     MOV A, DPR\r
274     SWAP\r
275     MOV A, ADB\r
276     ORW A\r
277         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
278                 RETP\r
279         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
280                 RET\r
281         #endif \r
282 \r
283 \r
284 _xGet_DTB_PCB_bank:\r
285 \r
286     MOV A, DTB\r
287     SWAP\r
288     MOV A, PCB\r
289     ORW A\r
290         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
291                 RETP\r
292         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
293                 RET\r
294         #endif \r
295 \r
296 #pragma endasm\r
297 /*-----------------------------------------------------------*/\r
298 \r
299 /* \r
300  * Initialise the stack of a task to look exactly as if a call to \r
301  * portSAVE_CONTEXT had been called.\r
302  * \r
303  * See the header file portable.h.\r
304  */\r
305 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
306 {\r
307         /* Place a few bytes of known values on the bottom of the stack. \r
308         This is just useful for debugging. */\r
309         *pxTopOfStack = 0x1111;\r
310         pxTopOfStack--;\r
311         *pxTopOfStack = 0x2222;\r
312         pxTopOfStack--;\r
313         *pxTopOfStack = 0x3333;\r
314         pxTopOfStack--;\r
315 \r
316         /* Once the task is called the task  would  push  the  pointer to the\r
317         parameter onto the stack. Hence here the pointer would be copied to the stack\r
318         first.  When using the COMPACT or LARGE memory model the pointer would be 24 \r
319         bits, and when using the SMALL or MEDIUM memory model the pointer would be 16 \r
320         bits. */ \r
321         #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
322         {\r
323                 *pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );\r
324                 pxTopOfStack--;         \r
325         }\r
326         #endif\r
327 \r
328     *pxTopOfStack = ( StackType_t ) ( pvParameters );\r
329     pxTopOfStack--;                  \r
330     \r
331     /* This is redundant push to the stack. This is required in order to introduce \r
332     an offset so that the task accesses a parameter correctly that is passed on to \r
333     the task stack. */\r
334         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
335         {\r
336                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );      \r
337                 pxTopOfStack--;       \r
338         }\r
339         #endif\r
340 \r
341     /* This is redundant push to the stack. This is required in order to introduce \r
342     an offset so the task correctly accesses the parameter passed on the task stack. */\r
343     *pxTopOfStack = ( StackType_t ) ( pxCode );\r
344     pxTopOfStack--;       \r
345 \r
346     /* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */\r
347     *pxTopOfStack = 0xE0C0;                                                     \r
348         pxTopOfStack--; \r
349 \r
350         /* PC */\r
351         *pxTopOfStack = ( StackType_t ) ( pxCode );     \r
352     pxTopOfStack--;      \r
353     \r
354     /* DTB | PCB */\r
355         #if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT\r
356         {\r
357                 *pxTopOfStack = xGet_DTB_PCB_bank();            \r
358                 pxTopOfStack--;\r
359         }\r
360         #endif\r
361 \r
362         /* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used\r
363         along with PC to indicate the start address of the function. */\r
364         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
365         {\r
366                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );\r
367                 pxTopOfStack--;       \r
368         }\r
369         #endif\r
370 \r
371         /* DPR | ADB  */\r
372         *pxTopOfStack = xGet_DPR_ADB_bank();                            \r
373         pxTopOfStack--;\r
374     \r
375         /* AL */\r
376         *pxTopOfStack = ( StackType_t ) 0x9999;         \r
377         pxTopOfStack--;\r
378 \r
379         /* AH */\r
380         *pxTopOfStack = ( StackType_t ) 0xAAAA;         \r
381         pxTopOfStack--;\r
382         \r
383         /* Next the general purpose registers. */\r
384         *pxTopOfStack = ( StackType_t ) 0x7777; /* RW7 */\r
385         pxTopOfStack--;\r
386         *pxTopOfStack = ( StackType_t ) 0x6666; /* RW6 */\r
387         pxTopOfStack--;\r
388         *pxTopOfStack = ( StackType_t ) 0x5555; /* RW5 */\r
389         pxTopOfStack--;\r
390         *pxTopOfStack = ( StackType_t ) 0x4444; /* RW4 */\r
391         pxTopOfStack--;\r
392         *pxTopOfStack = ( StackType_t ) 0x3333; /* RW3 */\r
393         pxTopOfStack--;\r
394         *pxTopOfStack = ( StackType_t ) 0x2222; /* RW2 */\r
395         pxTopOfStack--;\r
396         *pxTopOfStack = ( StackType_t ) 0x1111; /* RW1 */\r
397         pxTopOfStack--;\r
398         *pxTopOfStack = ( StackType_t ) 0x8888; /* RW0 */\r
399                 \r
400         return pxTopOfStack;\r
401 }\r
402 /*-----------------------------------------------------------*/\r
403 \r
404 static void prvSetupRLT0Interrupt( void )\r
405 {\r
406 /* The peripheral clock divided by 16 is used by the timer. */\r
407 const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );\r
408 \r
409         /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
410         TMRLR0 = usReloadValue;    \r
411     \r
412     /* prescaler 1:16, reload, interrupt enable, count enable, trigger */\r
413     TMCSR0 = 0x041B;    \r
414 }\r
415 /*-----------------------------------------------------------*/\r
416 \r
417 BaseType_t xPortStartScheduler( void )\r
418 {\r
419         /* Setup the hardware to generate the tick. */\r
420         prvSetupRLT0Interrupt();\r
421         \r
422         /* Restore the context of the first task that is going to run. */\r
423         portRESTORE_CONTEXT();\r
424 \r
425         /* Simulate a function call end as generated by the compiler.  We will now\r
426         jump to the start of the task the context of which we have just restored. */    \r
427         __asm(" reti ");\r
428 \r
429 \r
430         /* Should not get here. */\r
431         return pdTRUE;\r
432 }\r
433 /*-----------------------------------------------------------*/\r
434 \r
435 void vPortEndScheduler( void )\r
436 {\r
437         /* Not implemented - unlikely to ever be required as there is nothing to\r
438         return to. */\r
439 }\r
440 \r
441 /*-----------------------------------------------------------*/\r
442 \r
443 /* \r
444  * The interrupt service routine used depends on whether the pre-emptive\r
445  * scheduler is being used or not.\r
446  */\r
447 \r
448 #if configUSE_PREEMPTION == 1\r
449 \r
450         /* \r
451          * Tick ISR for preemptive scheduler.  We can use a __nosavereg attribute\r
452          * as the context is to be saved by the portSAVE_CONTEXT() macro, not the\r
453          * compiler generated code.  The tick count is incremented after the context \r
454          * is saved. \r
455          */\r
456         __nosavereg __interrupt void prvRLT0_TICKISR( void )\r
457         {\r
458                 /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */\r
459                 __DI();\r
460                 \r
461                 /* Save the context of the interrupted task. */\r
462                 portSAVE_CONTEXT();\r
463                 \r
464                 /* Enable interrupts */\r
465                 __EI();\r
466                 \r
467                 /* Clear RLT0 interrupt flag */\r
468                 TMCSR0_UF = 0;      \r
469                 \r
470                 /* Increment the tick count then switch to the highest priority task\r
471                 that is ready to run. */\r
472                 if( xTaskIncrementTick() != pdFALSE )\r
473                 {\r
474                         vTaskSwitchContext();\r
475                 }\r
476 \r
477                 /* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */\r
478                 __DI();\r
479                 \r
480                 /* Restore the context of the new task. */\r
481                 portRESTORE_CONTEXT();\r
482                 \r
483                 /* Enable interrupts */\r
484                 __EI();\r
485         }\r
486 \r
487 #else\r
488 \r
489         /*\r
490          * Tick ISR for the cooperative scheduler.  All this does is increment the\r
491          * tick count.  We don't need to switch context, this can only be done by\r
492          * manual calls to taskYIELD();\r
493          */\r
494         __interrupt void prvRLT0_TICKISR( void )\r
495         {\r
496                 /* Clear RLT0 interrupt flag */\r
497                 TMCSR0_UF = 0;  \r
498                 \r
499                 xTaskIncrementTick();\r
500         }\r
501 \r
502 #endif\r
503 \r
504 /*-----------------------------------------------------------*/\r
505 \r
506 /*\r
507  * Manual context switch. We can use a __nosavereg attribute  as the context \r
508  * is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated \r
509  * code.\r
510  */\r
511 __nosavereg __interrupt void vPortYield( void )\r
512 {\r
513         /* Save the context of the interrupted task. */\r
514         portSAVE_CONTEXT();\r
515         \r
516         /* Switch to the highest priority task that is ready to run. */\r
517         vTaskSwitchContext();\r
518         \r
519         /* Restore the context of the new task. */\r
520         portRESTORE_CONTEXT();\r
521 }\r
522 /*-----------------------------------------------------------*/\r
523 \r
524 __nosavereg __interrupt void vPortYieldDelayed( void )\r
525 {    \r
526     /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */      \r
527         __DI();\r
528         \r
529         /* Save the context of the interrupted task. */\r
530         portSAVE_CONTEXT();\r
531         \r
532         /* Enable interrupts */\r
533         __EI();\r
534                                 \r
535         /* Clear delayed interrupt flag */\r
536     __asm (" CLRB  03A4H:0 ");\r
537         \r
538         /* Switch to the highest priority task that is ready to run. */\r
539         vTaskSwitchContext();\r
540         \r
541         /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */   \r
542         __DI();\r
543         \r
544         /* Restore the context of the new task. */\r
545         portRESTORE_CONTEXT();\r
546 \r
547         /* Enable interrupts */\r
548         __EI();\r
549 }       \r
550 /*-----------------------------------------------------------*/\r
551 \r