int ppc_pit_init( void )
{
	// 1. Register Profile_intr_handler as Interrupt handler
	// 2. Set PIT Timer Interrupt and Enable it.
	Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_PIT_INT,
			    (Xil_ExceptionHandler)profile_intr_handler,(void *)0);
	XTime_PITSetInterval( timer_clk_ticks ) ;
	XTime_PITEnableAutoReload() ;
	return 0;
}
Example #2
0
//***************************************************************
//******************* INTERRUPT FUNCTIONS ***********************
//***************************************************************
void Interrupt_Init(void)
{
	//PUSH BUTTON INTERRUPT
	/* Code */
	XIntc_Initialize(&Intc, INTC_DEVICE_ID);
	XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
	XIntc_Connect(&Intc, INTR_ID, GpioIsr, &Gpio);
	
	/* Buttons are all inputs */
	XGpio_SetDataDirection(&Gpio, BUTTON_CHANNEL, GPIO_ALL_BUTTONS);
	
	XGpio_InterruptEnable(&Gpio, BUTTON_INTERRUPT);
	XGpio_InterruptGlobalEnable(&Gpio);
	
	/* Enable the Interrupt vector at the interrupt controller */
	XIntc_Enable(&Intc, INTR_ID);
	
	XExc_Init();
	
	/*****************************************************************
	* Initialize the PPC405 exception table and register the interrupt
	* controller handler with the exception table
	******************************************************************/
	XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)XIntc_InterruptHandler, &Intc);
	/* Now Register Timer Interrupt */
	XExc_RegisterHandler(XEXC_ID_PIT_INT, (XExceptionHandler)TimerIsr, (void *)0);
	
		
	/* Enable non-critical exceptions in the PowerPC */
	XExc_mEnableExceptions(XEXC_NON_CRITICAL);
	
	/*******************************************************************
	* Start the interrput controller such that interrupts are recognized
	* and handled by the processor.
	********************************************************************/
	XIntc_Start(&Intc, XIN_REAL_MODE);
	
	//TIMER INTERRUPT
	/* Set Timer Interval (1 Sec) */
	XTime_PITSetInterval(0x0F000000);
	/* Automatically Restarts Timer */
	XTime_PITEnableAutoReload();
	/* Clear Timer Reg */
	XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL);
	/* Clear Queued Timer Interrupts */
	XTime_PITClearInterrupt();
	/* Enable Interrupt */
	XTime_PITEnableInterrupt();	
}
Example #3
0
/*
 * Hardware initialisation to generate the RTOS tick.   
 */
static void prvSetupTimerInterrupt( void )
{
const uint32_t ulInterval = ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL );

	XTime_PITClearInterrupt();
	XTime_FITClearInterrupt();
	XTime_WDTClearInterrupt();
	XTime_WDTDisableInterrupt();
	XTime_FITDisableInterrupt();

	XExc_RegisterHandler( XEXC_ID_PIT_INT, ( XExceptionHandler ) vPortTickISR, ( void * ) 0 );

	XTime_PITEnableAutoReload();
	XTime_PITSetInterval( ulInterval );
	XTime_PITEnableInterrupt();
}
void
platform_setup_timer()
{
#ifdef XPAR_CPU_PPC440_CORE_CLOCK_FREQ_HZ
    XExc_RegisterHandler(XEXC_ID_DEC_INT, (XExceptionHandler)xadapter_timer_handler, NULL);

    /* Set DEC to interrupt every 250 mseconds */
    XTime_DECSetInterval(PIT_INTERVAL);
    XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL);
    XTime_DECEnableAutoReload();
#else
    XExc_RegisterHandler(XEXC_ID_PIT_INT, (XExceptionHandler)xadapter_timer_handler, NULL);

    /* Set PIT to interrupt every 250 mseconds */
    XTime_PITSetInterval(PIT_INTERVAL);
    XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL);
    XTime_PITEnableAutoReload();
    XTime_PITEnableInterrupt();
#endif
}
Example #5
0
void InitInterrupts() {
	// Initialize wireless uart
	XUartLite_Initialize(&(wireless.uart), XPAR_WIRELESS_UART_DEVICE_ID);
	XUartLite_ResetFifos(&(wireless.uart));
	Wireless_Init(&wireless);

	// Initialize gameboard uart
	XUartLite_Initialize(&gameboard_uart, XPAR_GAMEBOARD_UART_DEVICE_ID);
	XUartLite_ResetFifos(&gameboard_uart);

	// Initialize the interrupt controller
	XIntc_Initialize(&InterruptController, XPAR_INTC_0_DEVICE_ID);

	// Connect the wireless uart to the interrupt controller
	XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_WIRELESS_UART_INTERRUPT_INTR,
			(XInterruptHandler)XUartLite_InterruptHandler,
			(void *)&(wireless.uart));

	// Connect the gameboard uart to the interrupt controller
	XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_GAMEBOARD_UART_INTERRUPT_INTR,
			(XInterruptHandler)XUartLite_InterruptHandler,
			(void *)&gameboard_uart);

	//XIntc_Connect(&InterruptController, XPAR_INTC_0_GPIO_0_VEC_ID,
	//		      (Xil_ExceptionHandler)GpioHandler, &Gpio);

	XIntc_Start(&InterruptController, XIN_REAL_MODE);

	// Enable interrupts for serial controllers
	XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_WIRELESS_UART_INTERRUPT_INTR);
	XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_GAMEBOARD_UART_INTERRUPT_INTR);

	// Enable interrupts for the GPIO
	//XIntc_Enable(&InterruptController, XPAR_INTC_0_GPIO_0_VEC_ID);

	Xil_ExceptionInit();

	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
			(Xil_ExceptionHandler)XIntc_InterruptHandler,
			&InterruptController);

	Xil_ExceptionEnable();

	// Set up send/receive handlers for wireless uart
	XUartLite_SetSendHandler(&(wireless.uart), WirelessSendHandler, &(wireless.uart));
	XUartLite_SetRecvHandler(&(wireless.uart), WirelessRecvHandler, &(wireless.uart));

	//XUartLite_SetRecvHandler(&(wireless.uart), WirelessRecvHandlerNonBlocking, &(wireless.uart));
	Wireless_Debug("Wireless should be set up now");

	// Set up send/receive handlers for gameboard uart
	XUartLite_SetSendHandler(&gameboard_uart, GameboardSendHandler, &gameboard_uart);
	XUartLite_SetRecvHandler(&gameboard_uart, GameboardRecvHandler, &gameboard_uart);

	XUartLite_EnableInterrupt(&(wireless.uart));
	XUartLite_EnableInterrupt(&gameboard_uart);

	// Enable interrupts for GPIO
	//XGpio_InterruptEnable(&Gpio, XGPIO_IR_CH2_MASK);
	//XGpio_InterruptGlobalEnable(&Gpio);

	// Set up PIT
	XExceptionHandler pithandler = &my_pitHandler;
	XExc_RegisterHandler(XEXC_ID_PIT_INT, pithandler,
			0);
	XTime_PITEnableAutoReload();
	// PIT should be set to 1ms
	XTime_PITSetInterval(300000);
	XExc_mEnableExceptions(XEXC_ALL);
	XTime_PITEnableInterrupt();
	XTime_PITClearInterrupt();
}