Example #1
0
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;

}
Example #2
0
int main(void) {

	XGpio dip, push;
	XScuTimer Timer;  /* Cortex A9 SCU Private Timer Instance */
	XScuTimer_Config *ConfigPtr;
	int value, skip, psb_check, dip_check, status, timerCounter, time1, time2;
	VectorArray AInst;
	VectorArray BTinst;
	VectorArray PInst;
	
	xil_printf("-- Start of the Program --\r\n");
	xil_printf("Enter choice: 1 (SW->Leds), 2 (Timer->Leds), 3 (Matrix), 4 (Exit) \r\n");

	XGpio_Initialize(&dip, XPAR_SW_8BIT_DEVICE_ID);
	XGpio_SetDataDirection(&dip, 1, 0xffffffff);

	XGpio_Initialize(&push, XPAR_BTNS_5BIT_DEVICE_ID);
	XGpio_SetDataDirection(&push, 1, 0xffffffff);

	ConfigPtr = XScuTimer_LookupConfig (XPAR_PS7_SCUTIMER_0_DEVICE_ID);
	status = XScuTimer_CfgInitialize (&Timer, ConfigPtr, ConfigPtr->BaseAddr);

	if(status != XST_SUCCESS){
		xil_printf("Timer init() failed\r\n");
		return XST_FAILURE;
	}

	// Load timer with delay
	XScuTimer_LoadTimer(&Timer, ONE_SECOND);
	// Set AutoLoad mode
	XScuTimer_EnableAutoReload(&Timer);

	while (1) {
		xil_printf("CMD:> ");
		// Read an input value from the console.
		value = inbyte();
		skip = inbyte(); //CR
		skip = inbyte(); //LF
		switch (value) {
			case '1':
				while(!XGpio_DiscreteRead(&push, 1))
				{
					dip_check = XGpio_DiscreteRead(&dip, 1);
					LED_IP_mWriteReg(XPAR_LED_IP_S_AXI_BASEADDR, 0, dip_check);
					for (skip = 0; skip < 9999999; skip++);
				}
				break;
			case '2':

				timerCounter = 0;
				XScuTimer_Start(&Timer);

				while(!XGpio_DiscreteRead(&push, 1))
				{
					if(XScuTimer_IsExpired(&Timer))
					{
						XScuTimer_ClearInterruptStatus(&Timer);
						timerCounter = (timerCounter + 1) % 256;
						LED_IP_mWriteReg(XPAR_LED_IP_S_AXI_BASEADDR, 0, timerCounter);
					}
				}
				break;
			case '3':
				setInputMatrices(AInst, BTinst);
				displayMatrix(AInst);
				displayMatrix(BTinst);

				XScuTimer_Start(&Timer);
				// Software matrix
				time1 = XScuTimer_GetCounterValue(&Timer);
				multiMatrixSoft(AInst, BTinst, PInst);
				time2 = XScuTimer_GetCounterValue(&Timer);

				xil_printf("SW time: %d\n\n", time1-time2);
				displayMatrix(PInst);

				// Hardware matrix
				time1 = XScuTimer_GetCounterValue(&Timer);
				multiMatrixHard(AInst, BTinst, PInst);
				time2 = XScuTimer_GetCounterValue(&Timer);

				XScuTimer_Stop(&Timer);

				xil_printf("HW time: %d\n\n", time1-time2);
				displayMatrix(PInst);
				break;
			case '4':
				// Exit
				return XST_SUCCESS;
				break;
			default :
				break;
		}
	}
}
Example #3
0
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;
}
Example #4
0
int main (void) 
{

   XGpio dip, push;
   int psb_check, dip_check, dip_check_prev, count, Status;

   // PS Timer related definitions
   XScuTimer_Config *ConfigPtr;
   XScuTimer *TimerInstancePtr = &Timer;

   xil_printf("-- Start of the Program --\r\n");
 
   XGpio_Initialize(&dip, XPAR_SW_4BIT_DEVICE_ID);
   XGpio_SetDataDirection(&dip, 1, 0xffffffff);
	
   XGpio_Initialize(&push, XPAR_BTNS_4BIT_DEVICE_ID);
   XGpio_SetDataDirection(&push, 1, 0xffffffff);

   count = 0;
	
   // Initialize the timer
   ConfigPtr = XScuTimer_LookupConfig(XPAR_PS7_SCUTIMER_0_DEVICE_ID);
   Status = XScuTimer_CfgInitialize(TimerInstancePtr, ConfigPtr, ConfigPtr->BaseAddr);
   if(Status != XST_SUCCESS){
	   return XST_FAILURE;
   }
   // Read dip switch values
   dip_check_prev = XGpio_DiscreteRead(&dip, 1);
   // Load timer with delay in multiple of ONE_SECOND
   XScuTimer_LoadTimer(TimerInstancePtr,  ONE_SECOND*dip_check_prev);
   // Set AutoLoad mode
   XScuTimer_EnableAutoReload(TimerInstancePtr);
   // Start the timer
   XScuTimer_Start(TimerInstancePtr);

   while (1)
   {
	  // Read push buttons and break the loop if Center button pressed
	  psb_check = XGpio_DiscreteRead(&push, 1);
	  if(psb_check & 0x1)
	  {
		  XScuTimer_Stop(TimerInstancePtr);
		  break;
	  }
	  dip_check = XGpio_DiscreteRead(&dip, 1);
	  if (dip_check != dip_check_prev) {
		  xil_printf("DIP Switch Status %x, %x\r\n", dip_check_prev, dip_check);
		  dip_check_prev = dip_check;
	  	  // load timer with the new switch settings
		  XScuTimer_LoadTimer(TimerInstancePtr, ONE_SECOND*dip_check_prev);
		  count = 0;
	  }
	  if(XScuTimer_IsExpired(TimerInstancePtr)) {
			  // clear status bit
		  XScuTimer_ClearInterruptStatus(TimerInstancePtr);
		  	  // output the count to LED and increment the count
		  LED_IP_mWriteReg(XPAR_LED_IP_S_AXI_BASEADDR, 0, count);
		  count++;

	  }
   }
   return 0;
}