+++ /dev/null
-/*\r
- * FreeRTOS Kernel V10.1.0\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
- * this software and associated documentation files (the "Software"), to deal in\r
- * the Software without restriction, including without limitation the rights to\r
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
- * the Software, and to permit persons to whom the Software is furnished to do so,\r
- * subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * http://www.FreeRTOS.org\r
- * http://aws.amazon.com/freertos\r
- *\r
- * 1 tab == 4 spaces!\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 "iodefine.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
-static void prvTimer2IntHandler( void );\r
-\r
-/* Stores the value of the maximum recorded jitter between interrupts. This is\r
-displayed on one of the served web pages. */\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 interrupt ( prvTimer2IntHandler( vect = _VECT( _CMT2_CMI2 ), enable ) )\r
-static void prvTimer2IntHandler( 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
- nop();\r
- nop();\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