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