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