2 FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\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
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\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
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 #include "FreeRTOSConfig.h"
\r
55 #include "data_model.h"
\r
57 IMPORT vTaskIncrementTick
\r
58 IMPORT vTaskSwitchContext
\r
59 IMPORT vPortSetupTimerInterrupt
\r
61 IMPORT usCriticalNesting
\r
65 EXPORT xPortStartScheduler
\r
67 portSAVE_CONTEXT macro
\r
69 /* Save the remaining registers. */
\r
71 mov.w &usCriticalNesting, r14
\r
73 mov_x &pxCurrentTCB, r12
\r
76 /*-----------------------------------------------------------*/
\r
78 portRESTORE_CONTEXT macro
\r
80 mov_x &pxCurrentTCB, r12
\r
83 mov.w r15, &usCriticalNesting
\r
86 /* The last thing on the stack will be the status register.
\r
87 Ensure the power down bits are clear ready for the next
\r
88 time this power down register is popped from the stack. */
\r
89 bic.w #0xf0, 0( sp )
\r
94 /*-----------------------------------------------------------*/
\r
98 * The RTOS tick ISR.
\r
100 * If the cooperative scheduler is in use this simply increments the tick
\r
103 * If the preemptive scheduler is in use a context switch can also occur.
\r
111 /* The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs
\r
112 to save it manually before it gets modified (interrupts get disabled). */
\r
116 calla #vTaskIncrementTick
\r
118 #if configUSE_PREEMPTION == 1
\r
119 calla #vTaskSwitchContext
\r
122 portRESTORE_CONTEXT
\r
123 /*-----------------------------------------------------------*/
\r
126 * Manual context switch called by the portYIELD() macro.
\r
132 /* The sr needs saving before it is modified. */
\r
135 /* Now the SR is stacked we can disable interrupts. */
\r
139 /* Save the context of the current task. */
\r
142 /* Select the next task to run. */
\r
143 calla #vTaskSwitchContext
\r
145 /* Restore the context of the new task. */
\r
146 portRESTORE_CONTEXT
\r
147 /*-----------------------------------------------------------*/
\r
151 * Start off the scheduler by initialising the RTOS tick timer, then restoring
\r
152 * the context of the first task.
\r
156 xPortStartScheduler:
\r
158 /* Setup the hardware to generate the tick. Interrupts are disabled
\r
159 when this function is called. */
\r
160 calla #vPortSetupTimerInterrupt
\r
162 /* Restore the context of the first task that is going to run. */
\r
163 portRESTORE_CONTEXT
\r
164 /*-----------------------------------------------------------*/
\r