2 FreeRTOS V7.2.0 - Copyright (C) 2012 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 ***************************************************************************
\r
46 * Having a problem? Start by reading the FAQ "My application does *
\r
47 * not run, what could be wrong? *
\r
49 * http://www.FreeRTOS.org/FAQHelp.html *
\r
51 ***************************************************************************
\r
54 http://www.FreeRTOS.org - Documentation, training, latest information,
\r
55 license and contact details.
\r
57 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
58 including FreeRTOS+Trace - an indispensable productivity tool.
\r
60 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
61 the code with commercial support, indemnification, and middleware, under
\r
62 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
63 provide a safety engineered and independently SIL3 certified version under
\r
64 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
67 #include "FreeRTOS.h"
\r
70 __declspec(interrupt:0) void vPIT0InterruptHandler( void );
\r
72 /* Constants used to configure the interrupts. */
\r
73 #define portPRESCALE_VALUE 64
\r
74 #define portPRESCALE_REG_SETTING ( 5 << 8 )
\r
75 #define portPIT_INTERRUPT_ENABLED ( 0x08 )
\r
76 #define configPIT0_INTERRUPT_VECTOR ( 55 )
\r
79 * FreeRTOS.org requires two interrupts - a tick interrupt generated from a
\r
80 * timer source, and a spare interrupt vector used for context switching.
\r
81 * The configuration below uses PIT0 for the former, and vector 16 for the
\r
82 * latter. **IF YOUR APPLICATION HAS BOTH OF THESE INTERRUPTS FREE THEN YOU DO
\r
83 * NOT NEED TO CHANGE ANY OF THIS CODE** - otherwise instructions are provided
\r
84 * here for using alternative interrupt sources.
\r
86 * To change the tick interrupt source:
\r
88 * 1) Modify vApplicationSetupInterrupts() below to be correct for whichever
\r
89 * peripheral is to be used to generate the tick interrupt. The name of the
\r
90 * handler function (currently vPIT0InterruptHandler()) should also be updated
\r
91 * to indicate which peripheral is generating the interrupt.
\r
93 * 2) Make sure the interrupt source is cleared within the interrupt handler function.
\r
94 * Currently vPIT0InterruptHandler() clears the PIT0 interrupt.
\r
96 * 3) Update the vector table within mcf5225x_vectors.s to install the tick
\r
97 * interrupt handler in the correct vector position.
\r
99 * To change the spare interrupt source:
\r
101 * 1) Modify vApplicationSetupInterrupts() below to be correct for whichever
\r
102 * interrupt vector is to be used. Make sure you use a spare interrupt on interrupt
\r
103 * controller 0, otherwise the register used to request context switches will also
\r
104 * require modification.
\r
106 * 2) Change the definition of configYIELD_INTERRUPT_VECTOR within FreeRTOSConfig.h
\r
107 * to be correct for your chosen interrupt vector.
\r
109 * 3) Update the vector table within mcf5225x_vectors.s to install the handler
\r
110 * _vPortYieldISR() in the correct vector position (by default vector number 16 is
\r
113 void vApplicationSetupInterrupts( void )
\r
115 const unsigned portSHORT usCompareMatchValue = ( ( configCPU_CLOCK_HZ / portPRESCALE_VALUE ) / configTICK_RATE_HZ );
\r
117 /* Configure interrupt priority and level and unmask interrupt for PIT0. */
\r
118 MCF_INTC0_ICR55 = ( 1 | ( configKERNEL_INTERRUPT_PRIORITY << 3 ) );
\r
119 MCF_INTC0_IMRH &= ~( MCF_INTC_IMRH_INT_MASK55 );
\r
121 /* Do the same for vector 63 (interrupt controller 0. I don't think the
\r
122 write to MCF_INTC0_IMRH is actually required here but is included for
\r
124 MCF_INTC0_ICR16 = ( 0 | configKERNEL_INTERRUPT_PRIORITY << 3 );
\r
125 MCF_INTC0_IMRL &= ~( MCF_INTC_IMRL_INT_MASK16 | 0x01 );
\r
127 /* Configure PIT0 to generate the RTOS tick. */
\r
128 MCF_PIT0_PCSR |= MCF_PIT_PCSR_PIF;
\r
129 MCF_PIT0_PCSR = ( portPRESCALE_REG_SETTING | MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN );
\r
130 MCF_PIT0_PMR = usCompareMatchValue;
\r
132 /*-----------------------------------------------------------*/
\r
134 __declspec(interrupt:0) void vPIT0InterruptHandler( void )
\r
136 unsigned portLONG ulSavedInterruptMask;
\r
138 /* Clear the PIT0 interrupt. */
\r
139 MCF_PIT0_PCSR |= MCF_PIT_PCSR_PIF;
\r
141 /* Increment the RTOS tick. */
\r
142 ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR();
\r
143 vTaskIncrementTick();
\r
144 portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask );
\r
146 /* If we are using the pre-emptive scheduler then also request a
\r
147 context switch as incrementing the tick could have unblocked a task. */
\r
148 #if configUSE_PREEMPTION == 1
\r