#include "FreeRTOS.h"\r
#include "Task.h"\r
\r
+/* Xilinx includes. */\r
+#include "xscutimer.h"\r
+#include "xscugic.h"\r
+\r
+#define XSCUTIMER_CLOCK_HZ XPAR_CPU_CORTEXA9_0_CPU_CLK_FREQ_HZ/2\r
+\r
+static XScuTimer Timer; /* A9 timer counter */\r
+\r
/*\r
* The application must provide a function that configures a peripheral to\r
* create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT()\r
*/\r
void vConfigureTickInterrupt( void )\r
{\r
+static XScuGic InterruptController; /* Interrupt controller instance */\r
+int Status;\r
+extern void FreeRTOS_Tick_Handler( void );\r
+XScuTimer_Config *ScuConfig;\r
+XScuGic_Config *IntcConfig;\r
+\r
+ IntcConfig = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID);\r
+ Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig, IntcConfig->CpuBaseAddress );\r
+ configASSERT( Status == XST_SUCCESS );\r
+\r
+ /*\r
+ * Connect to the interrupt controller\r
+ */\r
+ Status = XScuGic_Connect(&InterruptController, XPAR_SCUTIMER_INTR, (Xil_ExceptionHandler) FreeRTOS_Tick_Handler, (void *)&Timer);\r
+ configASSERT( Status == XST_SUCCESS );\r
+\r
+ /*\r
+ * Initialize the A9Timer driver.\r
+ */\r
+ ScuConfig = XScuTimer_LookupConfig(XPAR_SCUTIMER_DEVICE_ID);\r
+\r
+ Status = XScuTimer_CfgInitialize(&Timer, ScuConfig, ScuConfig->BaseAddr);\r
+\r
+ configASSERT( Status == XST_SUCCESS );\r
+\r
+ /*\r
+ * Enable Auto reload mode.\r
+ */\r
+ XScuTimer_EnableAutoReload(&Timer);\r
+\r
+ /*\r
+ * Load the timer counter register.\r
+ */\r
+ XScuTimer_LoadTimer(&Timer, XSCUTIMER_CLOCK_HZ / configTICK_RATE_HZ);\r
+\r
+ /*\r
+ * Start the timer counter and then wait for it\r
+ * to timeout a number of times.\r
+ */\r
+ XScuTimer_Start(&Timer);\r
+\r
+ /*\r
+ * Enable the interrupt for the Timer in the interrupt controller\r
+ */\r
+ XScuGic_Enable(&InterruptController, XPAR_SCUTIMER_INTR);\r
+\r
+ /*\r
+ * Enable the timer interrupts for timer mode.\r
+ */\r
+ XScuTimer_EnableInterrupt(&Timer);\r
+\r
+ /*\r
+ * Do NOT enable interrupts in the ARM processor here.\r
+ * This happens when the scheduler is started.\r
+ */\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vInitialiseRunTimeStats( void )\r
{\r
}\r
+/*-----------------------------------------------------------*/\r
+\r
+extern XScuGic_Config XScuGic_ConfigTable[];\r
+static const XScuGic_Config *CfgPtr = &XScuGic_ConfigTable[ XPAR_SCUGIC_SINGLE_DEVICE_ID ];\r
+void vApplicationIRQHandler( uint32_t ulICCIAR )\r
+{\r
+uint32_t ulInterruptID;\r
+XScuGic_VectorTableEntry *TablePtr;\r
+//XScuGic_Config *CfgPtr;\r
+//extern XScuGic_Config XScuGic_ConfigTable[];\r
+\r
+// CfgPtr = &XScuGic_ConfigTable[ XPAR_SCUGIC_SINGLE_DEVICE_ID ];\r
+\r
+ /* Re-enable interrupts. */\r
+ __asm ( "cpsie i" );\r
+\r
+ /* The ID of the interrupt can be obtained by bitwise anding the ICCIAR value\r
+ with 0x3FF. */\r
+ ulInterruptID = ulICCIAR & 0x3FFUL;\r
+\r
+ configASSERT( ulInterruptID < XSCUGIC_MAX_NUM_INTR_INPUTS );\r
+ /* Call the function installed in the array of installed handler functions. */\r
+ TablePtr = &(CfgPtr->HandlerTable[ ulInterruptID ]);\r
+ TablePtr->Handler(TablePtr->CallBackRef);\r
+\r
+// intc_func_table[ ulInterruptID ]( 0 );\r
+}\r
\r
\r
\r
static void prvSetupHardware( void )
{
int Status;
-static XScuGic InterruptController; /* Interrupt controller instance */
+XScuGic InterruptController; /* Interrupt controller instance */
extern void FreeRTOS_IRQ_Handler( void );
extern void FreeRTOS_SWI_Handler( void );
Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig, IntcConfig->CpuBaseAddress );
configASSERT( Status == XST_SUCCESS );
- Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_IRQ_INT, (Xil_ExceptionHandler)FreeRTOS_IRQ_Handler, &InterruptController);
- Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_SWI_INT, (Xil_ExceptionHandler)FreeRTOS_SWI_Handler, &InterruptController);
+// Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_IRQ_INT, (Xil_ExceptionHandler)FreeRTOS_IRQ_Handler, &InterruptController);
+// Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_SWI_INT, (Xil_ExceptionHandler)FreeRTOS_SWI_Handler, &InterruptController);
// Xil_ExceptionEnableMask( XIL_EXCEPTION_ALL );
// Xil_ExceptionEnable();
}
#endif
}
-/*-----------------------------------------------------------*/
-
-void vApplicationIRQHandler( uint32_t ulICCIAR )
-{
-uint32_t ulInterruptID;
-
- /* Re-enable interrupts. */
- __asm ( "cpsie i" );
-
- /* The ID of the interrupt can be obtained by bitwise anding the ICCIAR value
- with 0x3FF. */
- ulInterruptID = ulICCIAR & 0x3FFUL;
-
- /* Call the function installed in the array of installed handler functions. */
-// intc_func_table[ ulInterruptID ]( 0 );
-}