licensing and training services.\r
*/\r
\r
+/*\r
+ * It is intended that the tasks and timers in this file cause interrupts to\r
+ * nest at least one level deeper than they would otherwise.\r
+ *\r
+ * A timer is configured to create an interrupt at moderately high frequency,\r
+ * as defined by the tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ constant. The\r
+ * interrupt priority is by configHIGH_FREQUENCY_TIMER_PRIORITY, which is set\r
+ * to ( configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ), the second highest\r
+ * priority from which interrupt safe FreeRTOS API calls can be made.\r
+ *\r
+ * The timer interrupt handler counts the number of times it is called. When\r
+ * it has determined that the number of calls means that 10ms has passed, it\r
+ * 'gives' a semaphore, and resets it call count.\r
+ *\r
+ * A high priority task is used to receive the data posted to the queue by the\r
+ * interrupt service routine. The task should, then, leave the blocked state\r
+ * and 'take' the available semaphore every 10ms. The frequency at which it\r
+ * actually leaves the blocked state is verified by the demo's check task (see\r
+ * the the documentation for the entire demo on the FreeRTOS.org web site),\r
+ * which then flags an error if the frequency lower than expected.\r
+ */\r
+\r
/* Standard includes. */\r
#include <stdlib.h>\r
#include <string.h>\r
#include <machine/cint.h>\r
#include <machine/wdtcon.h>\r
\r
-#warning DOCUMENT THIS\r
/* This constant is specific to this test application. It allows the high\r
frequency (interrupt nesting test) timer to know how often to trigger, and the\r
check task to know how many iterations to expect at any given time. */\r
#define tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ ( 8931UL )\r
\r
+/*\r
+ * The handler for the high priority timer interrupt.\r
+ */\r
static void prvPortHighFrequencyTimerHandler( int iArg ) __attribute__((longcall));\r
+\r
+/*\r
+ * The task that receives messages posted to a queue by the higher priority\r
+ * timer interrupt.\r
+ */\r
static void prvHighFrequencyTimerTask( void *pvParameters );\r
\r
+/* Constants used to configure the timer and determine how often the task\r
+should receive data. */\r
static const unsigned long ulCompareMatchValue = configPERIPHERAL_CLOCK_HZ / tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ;\r
static const unsigned long ulInterruptsPer10ms = tmrtestHIGH_FREQUENCY_TIMER_TEST_HZ / 100UL;\r
static const unsigned long ulSemaphoreGiveRate_ms = 10UL;\r
\r
+/* The semaphore used to synchronise the interrupt with the task. */\r
static xSemaphoreHandle xHighFrequencyTimerSemaphore = NULL;\r
-static unsigned long ulHighFrequencyCounterIterations = 0UL;\r
+\r
+/* Holds the count of the number of times the task is unblocked by the timer. */\r
+static volatile unsigned long ulHighFrequencyTaskIterations = 0UL;\r
\r
/*-----------------------------------------------------------*/\r
\r
\r
unsigned long ulInterruptNestingTestGetIterationCount( unsigned long *pulExpectedIncFrequency_ms )\r
{\r
+unsigned long ulReturn;\r
+\r
*pulExpectedIncFrequency_ms = ulSemaphoreGiveRate_ms;\r
- return ulHighFrequencyCounterIterations;\r
+ portENTER_CRITICAL();\r
+ {\r
+ ulReturn = ulHighFrequencyTaskIterations;\r
+ ulHighFrequencyTaskIterations = 0UL;\r
+ }\r
+\r
+ return ulReturn;\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
/* Just count how many times the task has been unblocked before\r
returning to wait for the semaphore again. */\r
- ulHighFrequencyCounterIterations++;\r
+ ulHighFrequencyTaskIterations++;\r
}\r
}\r
/*-----------------------------------------------------------*/\r
ulExecutionCounter = 0UL;\r
}\r
\r
+ /* Context switch on exit if necessary. */\r
portYIELD_FROM_ISR( ulHigherPriorityTaskWoken );\r
}\r
/* Demo Includes. */\r
#include "serial.h"\r
\r
+/*****************************************************************************\r
+ * Please note!\r
+ *\r
+ * This file is here to provide a means of generating interrupts to test the\r
+ * FreeRTOS tricore port. First - it configures the UART into loopback mode,\r
+ * and has only been used in loopback mode. Therefore, the baud rate\r
+ * calculation used has never been verified for correctness. Second -\r
+ * characters are passed into and out of the interrupt service routines using\r
+ * character queues. This provides a good test of the interrupt interaction,\r
+ * context switching mechanism, and kernel loading, it is however highly\r
+ * inefficient if the UART is being used to handle even moderate amounts of\r
+ * data throughput.\r
+ */\r
+\r
+\r
/*---------------------------------------------------------------------------*/\r
\r
/*\r
xTransmitStatus = 0UL;\r
}\r
\r
- /* Finally end ISR and switch Task. */\r
+ /* Finally end ISR and switch Task if necessary. */\r
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
}\r
/*---------------------------------------------------------------------------*/\r
/* Error handling code can go here. */\r
}\r
\r
- /* Finally end ISR and switch Task. */\r
+ /* Finally end ISR and switch Task if necessary. */\r
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
}\r
/*---------------------------------------------------------------------------*/\r
{\r
/* Check to see if the interrupt handler is working its way through the\r
buffer. */\r
- if ( 0 == xTransmitStatus )\r
+ if( 0 == xTransmitStatus )\r
{\r
/* Not currently operational so kick off the first byte. */\r
ASC0_TBSRC.reg |= 0x8000UL;\r