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