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