3 ; FreeRTOS V7.4.2 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
6 ; ***************************************************************************
\r
8 ; * FreeRTOS tutorial books are available in pdf and paperback. *
\r
9 ; * Complete, revised, and edited pdf reference manuals are also *
\r
12 ; * Purchasing FreeRTOS documentation will not only help you, by *
\r
13 ; * ensuring you get running as quickly as possible and with an *
\r
14 ; * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
15 ; * the FreeRTOS project to continue with its mission of providing *
\r
16 ; * professional grade, cross platform, de facto standard solutions *
\r
17 ; * for microcontrollers - completely free of charge! *
\r
19 ; * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
21 ; * Thank you for using FreeRTOS, and thank you for your support! *
\r
23 ; ***************************************************************************
\r
26 ; This file is part of the FreeRTOS distribution.
\r
28 ; FreeRTOS is free software; you can redistribute it and/or modify it under
\r
29 ; the terms of the GNU General Public License (version 2) as published by the
\r
30 ; Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
31 ; >>>NOTE<<< The modification to the GPL is included to allow you to
\r
32 ; distribute a combined work that includes FreeRTOS without being obliged to
\r
33 ; provide the source code for proprietary components outside of the FreeRTOS
\r
34 ; kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
35 ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
36 ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
37 ; more details. You should have received a copy of the GNU General Public
\r
38 ; License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
39 ; can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
40 ; by writing to Richard Barry, contact details for whom are available on the
\r
41 ; FreeRTOS WEB site.
\r
43 ; 1 tab == 4 spaces!
\r
45 ; http://www.FreeRTOS.org - Documentation, latest information, license and
\r
48 ; http://www.SafeRTOS.com - A version that is certified for use in safety
\r
51 ; http://www.OpenRTOS.com - Commercial support, development, porting,
\r
52 ; licensing and training services.
\r
55 ; * The definition of the "register test" tasks, as described at the top of
\r
58 .include data_model.h
\r
60 .global vTaskIncrementTick
\r
61 .global vTaskSwitchContext
\r
62 .global vPortSetupTimerInterrupt
\r
63 .global pxCurrentTCB
\r
64 .global usCriticalNesting
\r
66 .def vPortPreemptiveTickISR
\r
67 .def vPortCooperativeTickISR
\r
69 .def xPortStartScheduler
\r
71 ;-----------------------------------------------------------
\r
73 portSAVE_CONTEXT .macro
\r
75 ;Save the remaining registers.
\r
77 mov.w &usCriticalNesting, r14
\r
79 mov_x &pxCurrentTCB, r12
\r
82 ;-----------------------------------------------------------
\r
84 portRESTORE_CONTEXT .macro
\r
86 mov_x &pxCurrentTCB, r12
\r
89 mov.w r15, &usCriticalNesting
\r
94 ;-----------------------------------------------------------
\r
97 ;* The RTOS tick ISR.
\r
99 ;* If the cooperative scheduler is in use this simply increments the tick
\r
102 ;* If the preemptive scheduler is in use a context switch can also occur.
\r
108 vPortPreemptiveTickISR: .asmfunc
\r
110 ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs
\r
111 ;to save it manually before it gets modified (interrupts get disabled).
\r
115 call_x #vTaskIncrementTick
\r
116 call_x #vTaskSwitchContext
\r
118 portRESTORE_CONTEXT
\r
120 ;-----------------------------------------------------------
\r
124 vPortCooperativeTickISR: .asmfunc
\r
126 ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs
\r
127 ;to save it manually before it gets modified (interrupts get disabled).
\r
131 call_x #vTaskIncrementTick
\r
133 portRESTORE_CONTEXT
\r
136 ;-----------------------------------------------------------
\r
139 ; Manual context switch called by the portYIELD() macro.
\r
144 vPortYield: .asmfunc
\r
146 ; The sr needs saving before it is modified.
\r
149 ; Now the SR is stacked we can disable interrupts.
\r
153 ; Save the context of the current task.
\r
156 ; Select the next task to run.
\r
157 call_x #vTaskSwitchContext
\r
159 ; Restore the context of the new task.
\r
160 portRESTORE_CONTEXT
\r
162 ;-----------------------------------------------------------
\r
166 ; Start off the scheduler by initialising the RTOS tick timer, then restoring
\r
167 ; the context of the first task.
\r
172 xPortStartScheduler: .asmfunc
\r
174 ; Setup the hardware to generate the tick. Interrupts are disabled
\r
175 ; when this function is called.
\r
176 call_x #vPortSetupTimerInterrupt
\r
178 ; Restore the context of the first task that is going to run.
\r
179 portRESTORE_CONTEXT
\r
181 ;-----------------------------------------------------------
\r