]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/Softune/MB96340/port.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Source / portable / Softune / MB96340 / port.c
1 /*\r
2  * FreeRTOS Kernel V10.3.0\r
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 #include "FreeRTOS.h"\r
29 #include "task.h"\r
30 \r
31 /*-----------------------------------------------------------\r
32  * Implementation of functions defined in portable.h for the 16FX port.\r
33  *----------------------------------------------------------*/\r
34 \r
35 /* \r
36  * Get current value of DPR and ADB registers \r
37  */\r
38 StackType_t xGet_DPR_ADB_bank( void ); \r
39 \r
40 /* \r
41  * Get current value of DTB and PCB registers \r
42  */\r
43 StackType_t xGet_DTB_PCB_bank( void );\r
44 \r
45 /*\r
46  * Sets up the periodic ISR used for the RTOS tick.  This uses RLT0, but\r
47  * can be done using any given RLT.\r
48  */\r
49 static void prvSetupRLT0Interrupt( void );\r
50 \r
51 /*-----------------------------------------------------------*/\r
52 \r
53 /* \r
54  * We require the address of the pxCurrentTCB variable, but don't want to know\r
55  * any details of its type. \r
56  */\r
57 typedef void TCB_t;\r
58 extern volatile TCB_t * volatile pxCurrentTCB;\r
59 \r
60 /*-----------------------------------------------------------*/\r
61 \r
62 /* \r
63  * Macro to save a task context to the task stack. This macro  copies the \r
64  * saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from  the   system \r
65  * stack to task stack pointed by user stack pointer ( USP  for SMALL and \r
66  * MEDIUM memory model amd USB:USP for COMPACT  and LARGE memory model ),\r
67  * then  it pushes the general purpose registers RW0-RW7  on  to the task \r
68  * stack. Finally the  resultant  stack  pointer  value is saved into the \r
69  * task  control  block  so  it  can  be retrieved the next time the task \r
70  * executes.\r
71  */ \r
72 #if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )\r
73 \r
74         #define portSAVE_CONTEXT()                                                                                      \\r
75                         {       __asm(" POPW  A ");                                                                             \\r
76                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
77                                 __asm(" PUSHW  A ");                                                                    \\r
78                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
79                         __asm(" POPW  A ");                                                                             \\r
80                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
81                                 __asm(" PUSHW  A ");                                                                    \\r
82                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
83                                 __asm(" POPW  A ");                                                                             \\r
84                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
85                                 __asm(" PUSHW  A ");                                                                    \\r
86                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
87                                 __asm(" POPW  A ");                                                                             \\r
88                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
89                                 __asm(" PUSHW  A ");                                                                    \\r
90                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
91                                 __asm(" POPW  A ");                                                                             \\r
92                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
93                                 __asm(" PUSHW  A ");                                                                    \\r
94                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
95                                 __asm(" POPW  A ");                                                                             \\r
96                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
97                                 __asm(" PUSHW  A ");                                                                    \\r
98                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
99                                 __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
100                                 __asm(" MOVW A, SP ");                                                                  \\r
101                                 __asm(" SWAPW ");                                                                               \\r
102                                 __asm(" MOVW @AL, AH ");                                                                \\r
103                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
104                         }\r
105 \r
106 /* \r
107  * Macro to restore a task context from the task stack.  This is effecti-\r
108  * vely the reverse of SAVE_CONTEXT(). First the stack pointer  value\r
109  * (USP for SMALL and MEDIUM memory model amd  USB:USP  for  COMPACT  and \r
110  * LARGE memory model ) is loaded from the task  control block.  Next the \r
111  * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
112  * lly it copies of the context ( AH:AL,  DPR:ADB, DTB:PCB, PC and PS) of \r
113  * the task to be executed upon RETI from user stack to system stack.  \r
114  */\r
115  \r
116         #define portRESTORE_CONTEXT()                                                                           \\r
117                         {       __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
118                                 __asm(" MOVW A, @A ");                                                                  \\r
119                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
120                                 __asm(" MOVW SP, A ");                                                                  \\r
121                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
122                                 __asm(" POPW  A ");                                                                             \\r
123                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
124                                 __asm(" PUSHW  A ");                                                                    \\r
125                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
126                                 __asm(" POPW  A ");                                                                             \\r
127                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
128                                 __asm(" PUSHW  A ");                                                                    \\r
129                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
130                                 __asm(" POPW  A ");                                                                             \\r
131                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
132                                 __asm(" PUSHW  A ");                                                                    \\r
133                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
134                                 __asm(" POPW  A ");                                                                             \\r
135                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
136                                 __asm(" PUSHW  A ");                                                                    \\r
137                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
138                                 __asm(" POPW  A ");                                                                             \\r
139                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
140                                 __asm(" PUSHW  A ");                                                                    \\r
141                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
142                                 __asm(" POPW  A ");                                                                             \\r
143                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
144                                 __asm(" PUSHW  A ");                                                                    \\r
145                         }\r
146                 \r
147 #elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
148 \r
149         #define portSAVE_CONTEXT()                                                                                      \\r
150                         {       __asm(" POPW  A ");                                                                             \\r
151                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
152                                 __asm(" PUSHW  A ");                                                                    \\r
153                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
154                         __asm(" POPW  A ");                                                                             \\r
155                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
156                                 __asm(" PUSHW  A ");                                                                    \\r
157                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
158                                 __asm(" POPW  A ");                                                                             \\r
159                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
160                                 __asm(" PUSHW  A ");                                                                    \\r
161                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
162                                 __asm(" POPW  A ");                                                                             \\r
163                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
164                                 __asm(" PUSHW  A ");                                                                    \\r
165                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
166                                 __asm(" POPW  A ");                                                                             \\r
167                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
168                                 __asm(" PUSHW  A ");                                                                    \\r
169                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
170                                 __asm(" POPW  A ");                                                                             \\r
171                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
172                                 __asm(" PUSHW  A ");                                                                    \\r
173                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
174                                 __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
175                                 __asm(" MOVL RL2, A ");                                                                 \\r
176                                 __asm(" MOVW A, SP ");                                                                  \\r
177                                 __asm(" MOVW @RL2+0, A ");                                                              \\r
178                                 __asm(" MOV A, USB ");                                                                  \\r
179                                 __asm(" MOV @RL2+2, A ");                                                               \\r
180                         }       \r
181             \r
182         #define portRESTORE_CONTEXT()                                                                           \\r
183                         {       __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
184                                 __asm(" MOVL RL2, A ");                                                                 \\r
185                                 __asm(" MOVW A, @RL2+0 ");                                                              \\r
186                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
187                                 __asm(" MOVW SP, A ");                                                                  \\r
188                                 __asm(" MOV A, @RL2+2 ");                                                               \\r
189                                 __asm(" MOV USB, A ");                                                                  \\r
190                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
191                                 __asm(" POPW  A ");                                                                             \\r
192                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
193                                 __asm(" PUSHW  A ");                                                                    \\r
194                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
195                                 __asm(" POPW  A ");                                                                             \\r
196                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
197                                 __asm(" PUSHW  A ");                                                                    \\r
198                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
199                                 __asm(" POPW  A ");                                                                             \\r
200                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
201                                 __asm(" PUSHW  A ");                                                                    \\r
202                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
203                                 __asm(" POPW  A ");                                                                             \\r
204                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
205                                 __asm(" PUSHW  A ");                                                                    \\r
206                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
207                                 __asm(" POPW  A ");                                                                             \\r
208                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
209                                 __asm(" PUSHW  A ");                                                                    \\r
210                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
211                                 __asm(" POPW  A ");                                                                             \\r
212                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
213                                 __asm(" PUSHW  A ");                                                                    \\r
214                         }\r
215 #endif\r
216 \r
217 /*-----------------------------------------------------------*/ \r
218 \r
219 /* \r
220  * Functions for obtaining the current value  of  DPR:ADB, DTB:PCB bank registers\r
221  */\r
222  \r
223 #pragma asm\r
224 \r
225         .GLOBAL    _xGet_DPR_ADB_bank\r
226         .GLOBAL    _xGet_DTB_PCB_bank\r
227         .SECTION   CODE, CODE, ALIGN=1\r
228 \r
229 _xGet_DPR_ADB_bank:\r
230 \r
231     MOV A, DPR\r
232     SWAP\r
233     MOV A, ADB\r
234     ORW A\r
235         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
236                 RETP\r
237         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
238                 RET\r
239         #endif \r
240 \r
241 \r
242 _xGet_DTB_PCB_bank:\r
243 \r
244     MOV A, DTB\r
245     SWAP\r
246     MOV A, PCB\r
247     ORW A\r
248         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
249                 RETP\r
250         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
251                 RET\r
252         #endif \r
253 \r
254 #pragma endasm\r
255 /*-----------------------------------------------------------*/\r
256 \r
257 /* \r
258  * Initialise the stack of a task to look exactly as if a call to \r
259  * portSAVE_CONTEXT had been called.\r
260  * \r
261  * See the header file portable.h.\r
262  */\r
263 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
264 {\r
265         /* Place a few bytes of known values on the bottom of the stack. \r
266         This is just useful for debugging. */\r
267         *pxTopOfStack = 0x1111;\r
268         pxTopOfStack--;\r
269         *pxTopOfStack = 0x2222;\r
270         pxTopOfStack--;\r
271         *pxTopOfStack = 0x3333;\r
272         pxTopOfStack--;\r
273 \r
274         /* Once the task is called the task  would  push  the  pointer to the\r
275         parameter onto the stack. Hence here the pointer would be copied to the stack\r
276         first.  When using the COMPACT or LARGE memory model the pointer would be 24 \r
277         bits, and when using the SMALL or MEDIUM memory model the pointer would be 16 \r
278         bits. */ \r
279         #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
280         {\r
281                 *pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );\r
282                 pxTopOfStack--;         \r
283         }\r
284         #endif\r
285 \r
286     *pxTopOfStack = ( StackType_t ) ( pvParameters );\r
287     pxTopOfStack--;                  \r
288     \r
289     /* This is redundant push to the stack. This is required in order to introduce \r
290     an offset so that the task accesses a parameter correctly that is passed on to \r
291     the task stack. */\r
292         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
293         {\r
294                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );      \r
295                 pxTopOfStack--;       \r
296         }\r
297         #endif\r
298 \r
299     /* This is redundant push to the stack. This is required in order to introduce \r
300     an offset so the task correctly accesses the parameter passed on the task stack. */\r
301     *pxTopOfStack = ( StackType_t ) ( pxCode );\r
302     pxTopOfStack--;       \r
303 \r
304     /* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */\r
305     *pxTopOfStack = 0xE0C0;                                                     \r
306         pxTopOfStack--; \r
307 \r
308         /* PC */\r
309         *pxTopOfStack = ( StackType_t ) ( pxCode );     \r
310     pxTopOfStack--;      \r
311     \r
312     /* DTB | PCB */\r
313         #if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT\r
314         {\r
315                 *pxTopOfStack = xGet_DTB_PCB_bank();            \r
316                 pxTopOfStack--;\r
317         }\r
318         #endif\r
319 \r
320         /* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used\r
321         along with PC to indicate the start address of the function. */\r
322         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
323         {\r
324                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );\r
325                 pxTopOfStack--;       \r
326         }\r
327         #endif\r
328 \r
329         /* DPR | ADB  */\r
330         *pxTopOfStack = xGet_DPR_ADB_bank();                            \r
331         pxTopOfStack--;\r
332     \r
333         /* AL */\r
334         *pxTopOfStack = ( StackType_t ) 0x9999;         \r
335         pxTopOfStack--;\r
336 \r
337         /* AH */\r
338         *pxTopOfStack = ( StackType_t ) 0xAAAA;         \r
339         pxTopOfStack--;\r
340         \r
341         /* Next the general purpose registers. */\r
342         *pxTopOfStack = ( StackType_t ) 0x7777; /* RW7 */\r
343         pxTopOfStack--;\r
344         *pxTopOfStack = ( StackType_t ) 0x6666; /* RW6 */\r
345         pxTopOfStack--;\r
346         *pxTopOfStack = ( StackType_t ) 0x5555; /* RW5 */\r
347         pxTopOfStack--;\r
348         *pxTopOfStack = ( StackType_t ) 0x4444; /* RW4 */\r
349         pxTopOfStack--;\r
350         *pxTopOfStack = ( StackType_t ) 0x3333; /* RW3 */\r
351         pxTopOfStack--;\r
352         *pxTopOfStack = ( StackType_t ) 0x2222; /* RW2 */\r
353         pxTopOfStack--;\r
354         *pxTopOfStack = ( StackType_t ) 0x1111; /* RW1 */\r
355         pxTopOfStack--;\r
356         *pxTopOfStack = ( StackType_t ) 0x8888; /* RW0 */\r
357                 \r
358         return pxTopOfStack;\r
359 }\r
360 /*-----------------------------------------------------------*/\r
361 \r
362 static void prvSetupRLT0Interrupt( void )\r
363 {\r
364 /* The peripheral clock divided by 16 is used by the timer. */\r
365 const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );\r
366 \r
367         /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
368         TMRLR0 = usReloadValue;    \r
369     \r
370     /* prescaler 1:16, reload, interrupt enable, count enable, trigger */\r
371     TMCSR0 = 0x041B;    \r
372 }\r
373 /*-----------------------------------------------------------*/\r
374 \r
375 BaseType_t xPortStartScheduler( void )\r
376 {\r
377         /* Setup the hardware to generate the tick. */\r
378         prvSetupRLT0Interrupt();\r
379         \r
380         /* Restore the context of the first task that is going to run. */\r
381         portRESTORE_CONTEXT();\r
382 \r
383         /* Simulate a function call end as generated by the compiler.  We will now\r
384         jump to the start of the task the context of which we have just restored. */    \r
385         __asm(" reti ");\r
386 \r
387 \r
388         /* Should not get here. */\r
389         return pdTRUE;\r
390 }\r
391 /*-----------------------------------------------------------*/\r
392 \r
393 void vPortEndScheduler( void )\r
394 {\r
395         /* Not implemented - unlikely to ever be required as there is nothing to\r
396         return to. */\r
397 }\r
398 \r
399 /*-----------------------------------------------------------*/\r
400 \r
401 /* \r
402  * The interrupt service routine used depends on whether the pre-emptive\r
403  * scheduler is being used or not.\r
404  */\r
405 \r
406 #if configUSE_PREEMPTION == 1\r
407 \r
408         /* \r
409          * Tick ISR for preemptive scheduler.  We can use a __nosavereg attribute\r
410          * as the context is to be saved by the portSAVE_CONTEXT() macro, not the\r
411          * compiler generated code.  The tick count is incremented after the context \r
412          * is saved. \r
413          */\r
414         __nosavereg __interrupt void prvRLT0_TICKISR( void )\r
415         {\r
416                 /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */\r
417                 __DI();\r
418                 \r
419                 /* Save the context of the interrupted task. */\r
420                 portSAVE_CONTEXT();\r
421                 \r
422                 /* Enable interrupts */\r
423                 __EI();\r
424                 \r
425                 /* Clear RLT0 interrupt flag */\r
426                 TMCSR0_UF = 0;      \r
427                 \r
428                 /* Increment the tick count then switch to the highest priority task\r
429                 that is ready to run. */\r
430                 if( xTaskIncrementTick() != pdFALSE )\r
431                 {\r
432                         vTaskSwitchContext();\r
433                 }\r
434 \r
435                 /* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */\r
436                 __DI();\r
437                 \r
438                 /* Restore the context of the new task. */\r
439                 portRESTORE_CONTEXT();\r
440                 \r
441                 /* Enable interrupts */\r
442                 __EI();\r
443         }\r
444 \r
445 #else\r
446 \r
447         /*\r
448          * Tick ISR for the cooperative scheduler.  All this does is increment the\r
449          * tick count.  We don't need to switch context, this can only be done by\r
450          * manual calls to taskYIELD();\r
451          */\r
452         __interrupt void prvRLT0_TICKISR( void )\r
453         {\r
454                 /* Clear RLT0 interrupt flag */\r
455                 TMCSR0_UF = 0;  \r
456                 \r
457                 xTaskIncrementTick();\r
458         }\r
459 \r
460 #endif\r
461 \r
462 /*-----------------------------------------------------------*/\r
463 \r
464 /*\r
465  * Manual context switch. We can use a __nosavereg attribute  as the context \r
466  * is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated \r
467  * code.\r
468  */\r
469 __nosavereg __interrupt void vPortYield( void )\r
470 {\r
471         /* Save the context of the interrupted task. */\r
472         portSAVE_CONTEXT();\r
473         \r
474         /* Switch to the highest priority task that is ready to run. */\r
475         vTaskSwitchContext();\r
476         \r
477         /* Restore the context of the new task. */\r
478         portRESTORE_CONTEXT();\r
479 }\r
480 /*-----------------------------------------------------------*/\r
481 \r
482 __nosavereg __interrupt void vPortYieldDelayed( void )\r
483 {    \r
484     /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */      \r
485         __DI();\r
486         \r
487         /* Save the context of the interrupted task. */\r
488         portSAVE_CONTEXT();\r
489         \r
490         /* Enable interrupts */\r
491         __EI();\r
492                                 \r
493         /* Clear delayed interrupt flag */\r
494     __asm (" CLRB  03A4H:0 ");\r
495         \r
496         /* Switch to the highest priority task that is ready to run. */\r
497         vTaskSwitchContext();\r
498         \r
499         /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */   \r
500         __DI();\r
501         \r
502         /* Restore the context of the new task. */\r
503         portRESTORE_CONTEXT();\r
504 \r
505         /* Enable interrupts */\r
506         __EI();\r
507 }       \r
508 /*-----------------------------------------------------------*/\r
509 \r