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