+++ /dev/null
-/*\r
- FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
- \r
-\r
- ***************************************************************************\r
- * *\r
- * FreeRTOS tutorial books are available in pdf and paperback. *\r
- * Complete, revised, and edited pdf reference manuals are also *\r
- * available. *\r
- * *\r
- * Purchasing FreeRTOS documentation will not only help you, by *\r
- * ensuring you get running as quickly as possible and with an *\r
- * in-depth knowledge of how to use FreeRTOS, it will also help *\r
- * the FreeRTOS project to continue with its mission of providing *\r
- * professional grade, cross platform, de facto standard solutions *\r
- * for microcontrollers - completely free of charge! *\r
- * *\r
- * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *\r
- * *\r
- * Thank you for using FreeRTOS, and thank you for your support! *\r
- * *\r
- ***************************************************************************\r
-\r
-\r
- This file is part of the FreeRTOS distribution.\r
-\r
- FreeRTOS is free software; you can redistribute it and/or modify it under\r
- the terms of the GNU General Public License (version 2) as published by the\r
- Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
- >>>NOTE<<< The modification to the GPL is included to allow you to\r
- distribute a combined work that includes FreeRTOS without being obliged to\r
- provide the source code for proprietary components outside of the FreeRTOS\r
- kernel. FreeRTOS is distributed in the hope that it will be useful, but\r
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- more details. You should have received a copy of the GNU General Public\r
- License and the FreeRTOS license exception along with FreeRTOS; if not it\r
- can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
- by writing to Richard Barry, contact details for whom are available on the\r
- FreeRTOS WEB site.\r
-\r
- 1 tab == 4 spaces!\r
- \r
- ***************************************************************************\r
- * *\r
- * Having a problem? Start by reading the FAQ "My application does *\r
- * not run, what could be wrong? *\r
- * *\r
- * http://www.FreeRTOS.org/FAQHelp.html *\r
- * *\r
- ***************************************************************************\r
-\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest information, \r
- license and contact details.\r
- \r
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
- including FreeRTOS+Trace - an indispensable productivity tool.\r
-\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
- the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
- the SafeRTOS brand: http://www.SafeRTOS.com.\r
-*/\r
-\r
-/*\r
- * High frequency timer test as described in main.c.\r
- */\r
-\r
-/* Scheduler includes. */\r
-#include "FreeRTOS.h"\r
-\r
-/* Hardware specifics. */\r
-#include <iorx62n.h>\r
-\r
-/* The set frequency of the interrupt. Deviations from this are measured as\r
-the jitter. */\r
-#define timerINTERRUPT_FREQUENCY ( 20000UL )\r
-\r
-/* The expected time between each of the timer interrupts - if the jitter was\r
-zero. */\r
-#define timerEXPECTED_DIFFERENCE_VALUE ( ( unsigned short ) ( ( configPERIPHERAL_CLOCK_HZ / 8UL ) / timerINTERRUPT_FREQUENCY ) )\r
-\r
-/* The highest available interrupt priority. */\r
-#define timerHIGHEST_PRIORITY ( 15 )\r
-\r
-/* Misc defines. */\r
-#define timerTIMER_3_COUNT_VALUE ( *( ( unsigned short * ) 0x8801a ) ) /*( CMT3.CMCNT )*/\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-/* Interrupt handler in which the jitter is measured. */\r
-__interrupt void vTimer2IntHandler( void );\r
-\r
-/* Stores the value of the maximum recorded jitter between interrupts. */\r
-volatile unsigned short usMaxJitter = 0;\r
-\r
-/* Counts the number of high frequency interrupts - used to generate the run\r
-time stats. */\r
-volatile unsigned long ulHighFrequencyTickCount = 0UL;\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void vSetupHighFrequencyTimer( void )\r
-{\r
- /* Timer CMT2 is used to generate the interrupts, and CMT3 is used\r
- to measure the jitter. */\r
-\r
- /* Enable compare match timer 2 and 3. */\r
- MSTP( CMT2 ) = 0;\r
- MSTP( CMT3 ) = 0;\r
- \r
- /* Interrupt on compare match. */\r
- CMT2.CMCR.BIT.CMIE = 1;\r
- \r
- /* Set the compare match value. */\r
- CMT2.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / timerINTERRUPT_FREQUENCY ) -1 ) / 8 );\r
- \r
- /* Divide the PCLK by 8. */\r
- CMT2.CMCR.BIT.CKS = 0;\r
- CMT3.CMCR.BIT.CKS = 0;\r
- \r
- /* Enable the interrupt... */\r
- _IEN( _CMT2_CMI2 ) = 1;\r
- \r
- /* ...and set its priority to the maximum possible, this is above the priority\r
- set by configMAX_SYSCALL_INTERRUPT_PRIORITY so will nest. */\r
- _IPR( _CMT2_CMI2 ) = timerHIGHEST_PRIORITY;\r
- \r
- /* Start the timers. */\r
- CMT.CMSTR1.BIT.STR2 = 1;\r
- CMT.CMSTR1.BIT.STR3 = 1;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#pragma vector = VECT_CMT2_CMI2\r
-__interrupt void vTimer2IntHandler( void )\r
-{\r
-volatile unsigned short usCurrentCount;\r
-static unsigned short usMaxCount = 0;\r
-static unsigned long ulErrorCount = 0UL;\r
-\r
- /* We use the timer 1 counter value to measure the clock cycles between\r
- the timer 0 interrupts. First stop the clock. */\r
- CMT.CMSTR1.BIT.STR3 = 0;\r
- portNOP();\r
- portNOP();\r
- usCurrentCount = timerTIMER_3_COUNT_VALUE;\r
-\r
- /* Is this the largest count we have measured yet? */\r
- if( usCurrentCount > usMaxCount )\r
- {\r
- if( usCurrentCount > timerEXPECTED_DIFFERENCE_VALUE )\r
- {\r
- usMaxJitter = usCurrentCount - timerEXPECTED_DIFFERENCE_VALUE;\r
- }\r
- else\r
- {\r
- /* This should not happen! */\r
- ulErrorCount++;\r
- }\r
- \r
- usMaxCount = usCurrentCount;\r
- }\r
- \r
- /* Used to generate the run time stats. */\r
- ulHighFrequencyTickCount++;\r
-\r
- /* Clear the timer. */\r
- timerTIMER_3_COUNT_VALUE = 0;\r
- \r
- /* Then start the clock again. */\r
- CMT.CMSTR1.BIT.STR3 = 1;\r
-}\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r