예제 #1
0
void
timer_callback(XScuTimer * TimerInstance)
{
#if LWIP_DHCP==1
    static int dhcp_timer = 0;
#endif
	/* we need to call tcp_fasttmr & tcp_slowtmr at intervals specified by lwIP.
	 * It is not important that the timing is absoluetly accurate.
	 */
	static int odd = 1;
	TcpFastTmrFlag = 1;
	odd = !odd;
	if (odd) {
#if LWIP_DHCP==1
		dhcp_timer++;
		dhcp_timoutcntr--;
#endif
		TxPerfConnMonCntr++;
		TcpSlowTmrFlag = 1;
#if LWIP_DHCP==1
		dhcp_fine_tmr();
		if (dhcp_timer >= 120) {
			dhcp_coarse_tmr();
			dhcp_timer = 0;
		}
#endif
	}
	XScuTimer_ClearInterruptStatus(TimerInstance);
}
예제 #2
0
/*
 * The ISR used for the scheduler tick.
 */
void vTickISR( XScuTimer *Timer )
{
	/* Increment the RTOS tick count, then look for the highest priority
	task that is ready to run. */
	vTaskIncrementTick();

	#if configUSE_PREEMPTION == 1
		vTaskSwitchContext();
	#endif

	XScuTimer_ClearInterruptStatus(Timer);
}
예제 #3
0
void
timer_callback(XScuTimer * TimerInstance)
{
	/* we need to call tcp_fasttmr & tcp_slowtmr at intervals specified
	 * by lwIP. It is not important that the timing is absoluetly accurate.
	 */
	static int odd = 1;
#if LWIP_DHCP==1
    static int dhcp_timer = 0;
#endif

	odd = !odd;
#ifndef USE_SOFTETH_ON_ZYNQ
	ResetRxCntr++;
#endif
	tcp_fasttmr();
	if (odd) {
#if LWIP_DHCP==1
		dhcp_timer++;
		dhcp_timoutcntr--;
#endif
		tcp_slowtmr();
#if LWIP_DHCP==1
		dhcp_fine_tmr();
		if (dhcp_timer >= 120) {
			dhcp_coarse_tmr();
			dhcp_timer = 0;
		}
#endif
	}

	/* For providing an SW alternative for the SI #692601. Under heavy
	 * Rx traffic if at some point the Rx path becomes unresponsive, the
	 * following API call will ensures a SW reset of the Rx path. The
	 * API xemacpsif_resetrx_on_no_rxdata is called every 100 milliseconds.
	 * This ensures that if the above HW bug is hit, in the worst case,
	 * the Rx path cannot become unresponsive for more than 100
	 * milliseconds.
	 */
#ifndef USE_SOFTETH_ON_ZYNQ
	if (ResetRxCntr >= RESET_RX_CNTR_LIMIT) {
		xemacpsif_resetrx_on_no_rxdata(echo_netif);
		ResetRxCntr = 0;
	}
#endif
	XScuTimer_ClearInterruptStatus(TimerInstance);
}
static void TimerIntrHandler(void *CallBackRef)
{
	//unsigned int cpu0;

	XScuTimer *TimerInstancePtr = (XScuTimer *) CallBackRef;
	XScuTimer_ClearInterruptStatus(TimerInstancePtr);
	//load timer
	XScuTimer_LoadTimer(&Timer, TIMER_LOAD_VALUE);
	//start timer

	XGpio_DiscreteWrite(&Gpio,CHANNEL,cpu0);

	XScuTimer_Start(&Timer);



}
예제 #5
0
/**
*
* This function does a minimal test on the SCU Private timer device and driver.
* The purpose of this function is to illustrate how to use the XScuTimer driver.
*
* @param	DeviceId is the unique device id of the device.
*
* @return	XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note		None.
*
****************************************************************************/
int scu_sleep(unsigned int seconds)
	{
//	volatile u32 tEnd, tCur;
	volatile u32 tLoad;
	XScuTimer *TimerInstancePtr = &Timer;


	/*
	 * Calculate load value for seconds
	 */
	tLoad  = ((u32) seconds) * COUNTS_PER_SECOND;

	/*
	 * Clear expired timer flag and Load the timer counter register. Timer should start
	 */
	XScuTimer_ClearInterruptStatus(TimerInstancePtr);
	XScuTimer_LoadTimer(TimerInstancePtr, tLoad);

	while ( !XScuTimer_IsExpired(TimerInstancePtr)) {
//		xil_printf("SCU Timer 0x%04x\n\r", XScuTimer_GetCounterValue(TimerInstancePtr));
	}

	return 0;
}
예제 #6
0
void vClearTickInterrupt( void )
{
	XScuTimer_ClearInterruptStatus( &xTimer );
}
예제 #7
0
파일: portZynq7000.c 프로젝트: jsyk/miilink
void FreeRTOS_ClearTickInterrupt( void )
{
	XScuTimer_ClearInterruptStatus( &xTimer );
}
예제 #8
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;
		}
	}
}
예제 #9
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;
}
예제 #10
0
int main()
{
    init_platform();

    XScuTimer Timer;
    XGpio ce, axis_data, axis_sw, btn, rst, sw;

	//setup of the timer
    XScuTimer_Config *TimerConfigPtr;
    XScuTimer *TimerInstancePtr = &Timer;
    TimerConfigPtr = XScuTimer_LookupConfig(TIMER_DEVICE_ID);

	int status, readFlag, switchVal, i = 0;
	int16_t rawData = 0; 			  //the raw binary from the ACL chip
	float   res 	= 0.003921568627; //resolution of each bit in the raw binary
	double gData, angle, sumAngle = 0;


	/* Initialize all the GPIOs used */
	status = XGpio_Initialize(&btn, BTN_ID);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	status = XGpio_Initialize(&sw, SW_ID);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	status = XGpio_Initialize(&ce, CE_ID);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	status = XGpio_Initialize(&axis_data, AXIS_DATA_ID);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	status = XGpio_Initialize(&axis_sw, AXIS_SW_ID);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	status = XGpio_Initialize(&rst, RST_ID);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Private Timer Initialization */
	status = XScuTimer_CfgInitialize(&Timer, TimerConfigPtr, TimerConfigPtr->BaseAddr);
	if (status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	XScuTimer_LoadTimer(TimerInstancePtr, TIMER_LOAD_VALUE); //loaded with 65

	XScuTimer_EnableAutoReload(TimerInstancePtr);

	XScuTimer_Start(TimerInstancePtr);

	while(1){

		/* Constantly read the switches */
		switchVal = XGpio_DiscreteRead(&sw, 1);

		/* Constantly looking for when the reset button (btn0) is pressed */
		XGpio_DiscreteWrite(&rst, 1, XGpio_DiscreteRead(&btn, 1));

		/* Tells the PmodACL HW model what switches are active */
		XGpio_DiscreteWrite(&axis_sw, 1, switchVal);

		/* Used to see if the axis data gpio has been read yet */
		readFlag = 0;

		if (XGpio_DiscreteRead(&ce, 1) == 0){

			XScuTimer_LoadTimer(TimerInstancePtr, TIMER_LOAD_VALUE);

			/* This keeps us in here until it's done sending/receiving */
			while (XGpio_DiscreteRead(&ce, 1) == 0){

				if (XScuTimer_IsExpired(TimerInstancePtr)){

					rawData = XGpio_DiscreteRead(&axis_data, 1);

					readFlag = 1; //you've read!

					XScuTimer_ClearInterruptStatus(TimerInstancePtr);
				}

			}

		}

		if (readFlag == 1){

			/* This state is used to see if the number received is negative or not (rawData > 512 is negative) */
			if (rawData < 512){
				gData = rawData * res; //res is the resolution of each bit received
			}else{
				gData = (512 - rawData) * res; //subtracting rawData from 512 is used to get the actual negative number
			}								   //not the binary unsigned

			/* This switch is used to see what axis you're using and what to display
			 * NOTE: The Z-axis is setup to do angle measurement! */
			switch(switchVal){
			case 0:
				printf("x-axis:%fg\r\n", gData);
				break;
			case 1:
				printf("y-axis:%fg\r\n", gData);
				break;
			case 2:
				gData    += .0991; 				  //add the offset
				gData     = (gData>1)? 1 : gData; //if gData is greater than 1, gData = 1 (because you can't take the acos
				angle     = acos(gData);		  //of a number greater than 1)
				angle    *= (180 / 3.14159); 	  //acos gives you the angle in radians, this converts it to degrees
				sumAngle += angle; 				  //used for finding the average
				i++;

				/* After 20 samples it prints the average value out */
				if (i == 20){

					printf("z-axis:%f degrees\r\n", (sumAngle / 20) );

					i = 0;
					sumAngle = 0;

				}

				break;
			default:
				printf("x-axis:%fg\r\n", gData); //chooses x-axis by default
				break;
			}

			readFlag = 0;
		}

	}

    cleanup_platform();
    return 0;
}