コード例 #1
0
/*
 * The application must provide a function that configures a peripheral to
 * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT()
 * in FreeRTOSConfig.h to call the function.  This file contains a function
 * that is suitable for use on the Zynq SoC.
 */
void vConfigureTickInterrupt( void )
{
static XScuGic xInterruptController; 	/* Interrupt controller instance */
BaseType_t xStatus;
extern void FreeRTOS_Tick_Handler( void );
XScuTimer_Config *pxTimerConfig;
XScuGic_Config *pxGICConfig;
const uint8_t ucRisingEdge = 3;

	/* This function is called with the IRQ interrupt disabled, and the IRQ
	interrupt should be left disabled.  It is enabled automatically when the
	scheduler is started. */

	/* Ensure XScuGic_CfgInitialize() has been called.  In this demo it has
	already been called from prvSetupHardware() in main(). */
	pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
	xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* The priority must be the lowest possible. */
	XScuGic_SetPriorityTriggerType( &xInterruptController, XPAR_SCUTIMER_INTR, portLOWEST_USABLE_INTERRUPT_PRIORITY << portPRIORITY_SHIFT, ucRisingEdge );

	/* Install the FreeRTOS tick handler. */
	xStatus = XScuGic_Connect( &xInterruptController, XPAR_SCUTIMER_INTR, (Xil_ExceptionHandler) FreeRTOS_Tick_Handler, ( void * ) &xTimer );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* Initialise the timer. */
	pxTimerConfig = XScuTimer_LookupConfig( XPAR_SCUTIMER_DEVICE_ID );
	xStatus = XScuTimer_CfgInitialize( &xTimer, pxTimerConfig, pxTimerConfig->BaseAddr );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* Enable Auto reload mode. */
	XScuTimer_EnableAutoReload( &xTimer );

	/* Ensure there is no prescale. */
	XScuTimer_SetPrescaler( &xTimer, 0 );

	/* Load the timer counter register. */
	XScuTimer_LoadTimer( &xTimer, XSCUTIMER_CLOCK_HZ / configTICK_RATE_HZ );

	/* Start the timer counter and then wait for it to timeout a number of
	times. */
	XScuTimer_Start( &xTimer );

	/* Enable the interrupt for the xTimer in the interrupt controller. */
	XScuGic_Enable( &xInterruptController, XPAR_SCUTIMER_INTR );

	/* Enable the interrupt in the xTimer itself. */
	vClearTickInterrupt();
	XScuTimer_EnableInterrupt( &xTimer );
}
コード例 #2
0
ファイル: WaitForStart.cpp プロジェクト: KapSteR/TIHSC
int WaitForStart::ScuTimerWait(u16 DeviceId, u32 timeOut) {

	int Status;
	XScuTimer_Config *ConfigPtr;
	XScuTimer *TimerInstancePtr = &Timer;

	/*
	 * Initialize the Scu Private Timer so that it is ready to use.
	 */
	ConfigPtr = XScuTimer_LookupConfig(DeviceId);

	/*
	 * This is where the virtual address would be used, this example
	 * uses physical address.
	 */
	Status = XScuTimer_CfgInitialize(TimerInstancePtr, ConfigPtr,
			ConfigPtr->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	// XScuTimer_SetPrescaler(TimerInstancePtr,16);
	XScuTimer_SetPrescaler(TimerInstancePtr, 1);

	/*
	 * Load the timer decrement register.
	 */
	XScuTimer_LoadTimer(TimerInstancePtr, timeOut);

	/*
	 * Start the Scu Private Timer device.
	 */
	XScuTimer_Start(TimerInstancePtr);

	while (XScuTimer_GetCounterValue(TimerInstancePtr) != 0) {

		// Wait for timer to expire

	}
	// Stop timer after use
	XScuTimer_Stop(TimerInstancePtr);

	return XST_SUCCESS;

}
コード例 #3
0
ファイル: main.c プロジェクト: njansen28/643project
int main(void) {
    xil_printf("Starting\r\n");

    int Status;
    int i;
    u32 start_time;
    u32 end_time;
    u32 return_val[ACTUAL_READS];

    // Initialize DMA
    Status = DMA_init(DMA_DEV_ID);
    if (Status != XST_SUCCESS) {
        xil_printf("XAxiDma_init: Failed %d\r\n", Status);
        return XST_FAILURE;
    }

    // Initialize PE
    Status = XNeedlemanwunsch_Initialize(&PE, PE_DEV_ID);
    if (Status != XST_SUCCESS) {
        xil_printf("XNeedlemanwunsch_Initialize: Failed %d\r\n", Status);
        return XST_FAILURE;
    }

    XNeedlemanwunsch_DisableAutoRestart(&PE);

    // Initialize timer with maximum value so we can see how far down it
    // goes. It should last about 12 seconds before hitting zero.
    Timer_init(TIMER_DEV_ID);
    XScuTimer_LoadTimer(&Timer, TIMER_MAX);
    XScuTimer_SetPrescaler(&Timer, TIMER_PRESCALE-1);
    start_time = TIMER_MAX;

    // Flush caches
    Xil_DCacheFlushRange((INTPTR)&ref_genome, sizeof(ref_genome));



    XScuTimer_Start(&Timer);

    for (i=0; i<ACTUAL_READS; i++) {
    	DMA_send();
    	writeRead(0, i);

		while(!XNeedlemanwunsch_IsIdle(&PE) && !XNeedlemanwunsch_IsReady(&PE)) {
			xil_printf("Waiting for idle/ready\r\n");
		}
		XNeedlemanwunsch_Start(&PE);
		//if (XNeedlemanwunsch_IsIdle(&PE) || XNeedlemanwunsch_IsReady(&PE)) {
			//xil_printf("Is still idle/ready\r\n");
		//}
		while(!XNeedlemanwunsch_IsDone(&PE) /*&& !XNeedlemanwunsch_IsIdle(&PE) && !XNeedlemanwunsch_IsReady(&PE)*/) {

		}

		return_val[i] = XNeedlemanwunsch_Get_return(&PE);
    }

    XScuTimer_Stop(&Timer);
    end_time = XScuTimer_GetCounterValue(&Timer);

    xil_printf("Done\r\n");
    for (i=0; i<ACTUAL_READS; i++) {
    	xil_printf("read %d best fit at %d\r\n", i, return_val[i]);
    }

    print_time(start_time, end_time);
    return 0;
}