--- /dev/null
+/*\r
+ FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that has become a de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly and support the FreeRTOS *\r
+ * project by purchasing a FreeRTOS tutorial book, reference *\r
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * Thank you! *\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
+\r
+ >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+ >>! a combined work that includes FreeRTOS without being obliged to provide\r
+ >>! the source code for proprietary components outside of the FreeRTOS\r
+ >>! kernel.\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
+ link: http://www.freertos.org/a00114.html\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
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+ license and Real Time Engineers Ltd. contact details.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+*/\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+\r
+/* Demo includes. */\r
+#include "IntQueueTimer.h"\r
+#include "IntQueue.h"\r
+\r
+/* Xilinx includes. */\r
+#include "xstatus.h"\r
+#include "xil_io.h"\r
+#include "xil_exception.h"\r
+#include "xttcps.h"\r
+#include "xscugic.h"\r
+\r
+#define tmrTIMER_0_FREQUENCY ( 2000UL )\r
+#define tmrTIMER_1_FREQUENCY ( 2001UL )\r
+\r
+#define TTC_TICK_DEVICE_ID XPAR_XTTCPS_0_DEVICE_ID\r
+#define TTC_TICK_INTR_ID XPAR_XTTCPS_0_INTR\r
+#define INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID\r
+\r
+/*\r
+ * Constants to set the basic operating parameters.\r
+ * PWM_DELTA_DUTY is critical to the running time of the test. Smaller values\r
+ * make the test run longer.\r
+ */\r
+#define TICK_TIMER_FREQ_HZ 100 /* Tick timer counter's output frequency */\r
+\r
+#define TICKS_PER_CHANGE_PERIOD TICK_TIMER_FREQ_HZ /* Tick signals per update */\r
+\r
+#define TIMERS_USED 2\r
+\r
+static void TickHandler(void *CallBackRef);\r
+\r
+static volatile uint8_t UpdateFlag; /* Flag to update the seconds counter */\r
+static uint32_t TickCount; /* Ticker interrupts between seconds change */\r
+static XTtcPs TtcPsInst[ TIMERS_USED ]; /* Timer counter instance */\r
+\r
+typedef struct {\r
+ u32 OutputHz; /* Output frequency */\r
+ u16 Interval; /* Interval value */\r
+ u8 Prescaler; /* Prescaler value */\r
+ u16 Options; /* Option settings */\r
+} TmrCntrSetup;\r
+\r
+static const TmrCntrSetup SettingsTable[ TIMERS_USED ] = { { tmrTIMER_0_FREQUENCY, 0, 0, XTTCPS_OPTION_INTERVAL_MODE | XTTCPS_OPTION_WAVE_DISABLE },\r
+ { tmrTIMER_1_FREQUENCY, 0, 0, XTTCPS_OPTION_INTERVAL_MODE | XTTCPS_OPTION_WAVE_DISABLE } };\r
+\r
+BaseType_t DeviceIDs[ TIMERS_USED ] = { XPAR_XTTCPS_0_DEVICE_ID, XPAR_XTTCPS_1_DEVICE_ID };\r
+BaseType_t InterruptIDs[ TIMERS_USED ] = { XPAR_XTTCPS_0_INTR, XPAR_XTTCPS_1_INTR };\r
+\r
+void vInitialiseTimerForIntQueueTest( void )\r
+{\r
+int Status;\r
+TmrCntrSetup *TimerSetup;\r
+XTtcPs *TtcPsTick;\r
+extern XScuGic xInterruptController;\r
+BaseType_t xTimer;\r
+XTtcPs *Timer;\r
+XTtcPs_Config *Config;\r
+\r
+ for( xTimer = 0; xTimer < TIMERS_USED; xTimer++ )\r
+ {\r
+\r
+ TimerSetup = &( SettingsTable[ xTimer ] );\r
+ Timer = &TtcPsInst[ xTimer ];\r
+\r
+ /*\r
+ * Look up the configuration based on the device identifier\r
+ */\r
+ Config = XTtcPs_LookupConfig(DeviceIDs[ xTimer ]);\r
+ configASSERT( Config );\r
+\r
+ /*\r
+ * Initialize the device\r
+ */\r
+ Status = XTtcPs_CfgInitialize(Timer, Config, Config->BaseAddress);\r
+ configASSERT(Status == XST_SUCCESS);\r
+\r
+ /*\r
+ * Stop the timer first\r
+ */\r
+ XTtcPs_Stop( Timer );\r
+\r
+ /*\r
+ * Set the options\r
+ */\r
+ XTtcPs_SetOptions(Timer, TimerSetup->Options);\r
+\r
+ /*\r
+ * Timer frequency is preset in the TimerSetup structure,\r
+ * however, the value is not reflected in its other fields, such as\r
+ * IntervalValue and PrescalerValue. The following call will map the\r
+ * frequency to the interval and prescaler values.\r
+ */\r
+ XTtcPs_CalcIntervalFromFreq(Timer, TimerSetup->OutputHz,\r
+ &(TimerSetup->Interval), &(TimerSetup->Prescaler));\r
+\r
+ /*\r
+ * Set the interval and prescale\r
+ */\r
+ XTtcPs_SetInterval(Timer, TimerSetup->Interval);\r
+ XTtcPs_SetPrescaler(Timer, TimerSetup->Prescaler);\r
+\r
+\r
+ /*\r
+ * Connect to the interrupt controller\r
+ */\r
+ Status = XScuGic_Connect(&xInterruptController, InterruptIDs[ xTimer ], (Xil_InterruptHandler)TickHandler, (void *)Timer);\r
+ configASSERT( Status == XST_SUCCESS);\r
+\r
+ /*\r
+ * Enable the interrupt for the Timer counter\r
+ */\r
+ XScuGic_Enable(&xInterruptController, InterruptIDs[ xTimer ]);\r
+\r
+ /*\r
+ * Enable the interrupts for the tick timer/counter\r
+ * We only care about the interval timeout.\r
+ */\r
+ XTtcPs_EnableInterrupts(Timer, XTTCPS_IXR_INTERVAL_MASK);\r
+\r
+ /*\r
+ * Start the tick timer/counter\r
+ */\r
+ XTtcPs_Start(Timer);\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vT2InterruptHandler( void )\r
+{\r
+ portEND_SWITCHING_ISR( xFirstTimerHandler() );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vT3InterruptHandler( void )\r
+{\r
+ portEND_SWITCHING_ISR( xSecondTimerHandler() );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+volatile uint32_t ulTimer1Count = 0, ulTimer2Count = 0;\r
+\r
+static void TickHandler(void *CallBackRef)\r
+{\r
+uint32_t StatusEvent;\r
+XTtcPs *pxTtcPs = (XTtcPs *)CallBackRef;\r
+ /*\r
+ * Read the interrupt status, then write it back to clear the interrupt.\r
+ */\r
+ StatusEvent = XTtcPs_GetInterruptStatus(pxTtcPs);\r
+ XTtcPs_ClearInterruptStatus(pxTtcPs, StatusEvent);\r
+\r
+ if (0 != (XTTCPS_IXR_INTERVAL_MASK & StatusEvent)) {\r
+ if( pxTtcPs->Config.DeviceId == DeviceIDs[ 0 ] )\r
+ {\r
+ ulTimer1Count++;\r
+ }\r
+ else\r
+ {\r
+ ulTimer2Count++;\r
+ }\r
+ TickCount++;\r
+ }\r
+}\r
+\r
+#if 0\r
+int SetupTimer(int DeviceID)\r
+{\r
+ int Status;\r
+ XTtcPs_Config *Config;\r
+ XTtcPs *Timer;\r
+ TmrCntrSetup *TimerSetup;\r
+\r
+ TimerSetup = &SettingsTable;\r
+\r
+ Timer = &TtcPsInst;\r
+ /*\r
+ * Stop the timer first\r
+ */\r
+ XTtcPs_Stop( &TtcPsInst );\r
+\r
+ /*\r
+ * Look up the configuration based on the device identifier\r
+ */\r
+ Config = XTtcPs_LookupConfig(DeviceIDs[ DeviceID ]);\r
+ configASSERT( Config );\r
+\r
+ /*\r
+ * Initialize the device\r
+ */\r
+ Status = XTtcPs_CfgInitialize(Timer, Config, Config->BaseAddress);\r
+ configASSERT(Status == XST_SUCCESS);\r
+\r
+ /*\r
+ * Set the options\r
+ */\r
+ XTtcPs_SetOptions(Timer, TimerSetup->Options);\r
+\r
+ /*\r
+ * Timer frequency is preset in the TimerSetup structure,\r
+ * however, the value is not reflected in its other fields, such as\r
+ * IntervalValue and PrescalerValue. The following call will map the\r
+ * frequency to the interval and prescaler values.\r
+ */\r
+ XTtcPs_CalcIntervalFromFreq(Timer, TimerSetup->OutputHz,\r
+ &(TimerSetup->Interval), &(TimerSetup->Prescaler));\r
+\r
+ /*\r
+ * Set the interval and prescale\r
+ */\r
+ XTtcPs_SetInterval(Timer, TimerSetup->Interval);\r
+ XTtcPs_SetPrescaler(Timer, TimerSetup->Prescaler);\r
+\r
+ return XST_SUCCESS;\r
+}\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd. \r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that has become a de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly and support the FreeRTOS *\r
+ * project by purchasing a FreeRTOS tutorial book, reference *\r
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * Thank you! *\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
+\r
+ >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+ >>! a combined work that includes FreeRTOS without being obliged to provide\r
+ >>! the source code for proprietary components outside of the FreeRTOS\r
+ >>! kernel.\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
+ link: http://www.freertos.org/a00114.html\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
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+ license and Real Time Engineers Ltd. contact details.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef INT_QUEUE_TIMER_H\r
+#define INT_QUEUE_TIMER_H\r
+\r
+void vInitialiseTimerForIntQueueTest( void );\r
+portBASE_TYPE xTimer0Handler( void );\r
+portBASE_TYPE xTimer1Handler( void );\r
+\r
+#endif\r
+\r