当前位置: 首页>>代码示例>>C++>>正文


C++ xil_printf函数代码示例

本文整理汇总了C++中xil_printf函数的典型用法代码示例。如果您正苦于以下问题:C++ xil_printf函数的具体用法?C++ xil_printf怎么用?C++ xil_printf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xil_printf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() 
{

   static XIntc intc;

   Xil_ICacheEnable();
   Xil_DCacheEnable();

   print("---Entering main---\n\r");

   

   {
      int status;
      
      print("\r\n Running IntcSelfTestExample() for xps_intc_0...\r\n");
      
      status = IntcSelfTestExample(XPAR_XPS_INTC_0_DEVICE_ID);
      
      if (status == 0) {
         print("IntcSelfTestExample PASSED\r\n");
      }
      else {
         print("IntcSelfTestExample FAILED\r\n");
      }
   } 
	
   {
       int Status;

       Status = IntcInterruptSetup(&intc, XPAR_XPS_INTC_0_DEVICE_ID);
       if (Status == 0) {
          print("Intc Interrupt Setup PASSED\r\n");
       } 
       else {
         print("Intc Interrupt Setup FAILED\r\n");
      } 
   }
   

   {
      u32 status;
      
      print("\r\nRunning GpioInputExample() for dip_switches_8bit...\r\n");

      u32 DataRead;
      
      status = GpioInputExample(XPAR_DIP_SWITCHES_8BIT_DEVICE_ID, &DataRead);
      
      if (status == 0) {
         xil_printf("GpioInputExample PASSED. Read data:0x%X\r\n", DataRead);
      }
      else {
         print("GpioInputExample FAILED.\r\n");
      }
   }
   

   {
      u32 status;
      
      print("\r\nRunning GpioOutputExample() for leds_8bit...\r\n");

      status = GpioOutputExample(XPAR_LEDS_8BIT_DEVICE_ID,8);
      
      if (status == 0) {
         print("GpioOutputExample PASSED.\r\n");
      }
      else {
         print("GpioOutputExample FAILED.\r\n");
      }
   }
   

   {
      u32 status;
      
      print("\r\nRunning GpioOutputExample() for leds_positions...\r\n");

      status = GpioOutputExample(XPAR_LEDS_POSITIONS_DEVICE_ID,5);
      
      if (status == 0) {
         print("GpioOutputExample PASSED.\r\n");
      }
      else {
         print("GpioOutputExample FAILED.\r\n");
      }
   }
   

   {
      u32 status;
      
      print("\r\nRunning GpioInputExample() for push_buttons_5bit...\r\n");

      u32 DataRead;
      
      status = GpioInputExample(XPAR_PUSH_BUTTONS_5BIT_DEVICE_ID, &DataRead);
      
      if (status == 0) {
//.........这里部分代码省略.........
开发者ID:fpgadeveloper,项目名称:xupv5-bsb,代码行数:101,代码来源:testperiph.c

示例2: DisplayDemoPrintTest


//.........这里部分代码省略.........
			}

			if (xcoi < xLeft)
			{
				fBlue = 0.0;
				fRed -= xInc;
			}
			else if (xcoi < xMid)
			{
				fBlue += xInc;
				fRed += xInc;
			}
			else if (xcoi < xRight)
			{
				fBlue -= xInc;
				fRed -= xInc;
			}
			else
			{
				fBlue += xInc;
				fRed = 0;
			}
		}
		/*
		 * Flush the framebuffer memory range to ensure changes are written to the
		 * actual memory, and therefore accessible by the VDMA.
		 */
		/*
		 * Andrew Powell - Hopefully, when you have memory reserved you won't have to flush the cache hierarchy.
		 */
		//Xil_DCacheFlushRange((unsigned int) frame, DISPLAYDEMO_MAX_FRAME * 4);
		break;
	case DISPLAYDEMO_PATTERN_1:
		wStride = stride / 4; /* Find the stride in 32-bit words */

		xInt = width / 7; //Seven intervals, each with width/7 pixels
		xInc = 256.0 / ((double) xInt); //256 color intensities per interval. Notice that overflow is handled for this pattern.

		fColor = 0.0;
		wCurrentInt = 1;
		for(xcoi = 0; xcoi < width; xcoi++)
		{
			if (wCurrentInt & 0b001)
				fRed = fColor;
			else
				fRed = 0.0;

			if (wCurrentInt & 0b010)
				fBlue = fColor;
			else
				fBlue = 0.0;

			if (wCurrentInt & 0b100)
				fGreen = fColor;
			else
				fGreen = 0.0;

			/*
			 * Just draw white in the last partial interval (when width is not divisible by 7)
			 */
			if (wCurrentInt > 7)
			{
				wColor = 0x00FFFFFF;
			}
			else
			{
				wColor = ((u32) fRed << BIT_DISPLAY_RED) | ((u32) fBlue << BIT_DISPLAY_BLUE) | ( (u32) fGreen << BIT_DISPLAY_GREEN);
			}
			iPixelAddr = xcoi;

			for(ycoi = 0; ycoi < height; ycoi++)
			{
				frame[iPixelAddr] = wColor;
				/*
				 * This pattern is printed one vertical line at a time, so the address must be incremented
				 * by the stride instead of just 1.
				 */
				iPixelAddr += wStride;
			}

			fColor += xInc;
			if (fColor >= 256.0)
			{
				fColor = 0.0;
				wCurrentInt++;
			}
		}
		/*
		 * Flush the framebuffer memory range to ensure changes are written to the
		 * actual memory, and therefore accessible by the VDMA.
		 */
		/*
		 * Andrew Powell - Hopefully, when you have memory reserved you won't have to flush the cache hierarchy.
		 */
		//Xil_DCacheFlushRange((unsigned int) frame, DISPLAYDEMO_MAX_FRAME * 4);
		break;
	default :
		xil_printf("Error: invalid pattern passed to DisplayDemoPrintTest");
	}
}
开发者ID:andrewandrepowell,项目名称:zybo_petalinux,代码行数:101,代码来源:display_demo.c

示例3: print_ip

void print_ip(char *msg, struct ip_addr *ip)
{
	print(msg);
	xil_printf("%d.%d.%d.%d\n\r", ip4_addr1(ip), ip4_addr2(ip),
			ip4_addr3(ip), ip4_addr4(ip));
}
开发者ID:Henk234,项目名称:zedboard_ethernet_io_ctrl,代码行数:6,代码来源:eth.c

示例4: init_axiemac

void
init_axiemac(xaxiemacif_s *xaxiemac, struct netif *netif)
{
	int rdy;
	unsigned mac_address = (unsigned)(netif->state);
	unsigned link_speed = 1000;
	unsigned options;
        unsigned lock_message_printed = 0;
	XAxiEthernet *xaxiemacp;
	XAxiEthernet_Config *mac_config;

	/* obtain config of this emac */
	mac_config = lookup_config(mac_address);

	xaxiemacp = &xaxiemac->axi_ethernet;

	XAxiEthernet_CfgInitialize(xaxiemacp, mac_config, mac_config->BaseAddress);

	options = XAxiEthernet_GetOptions(xaxiemacp);
	options |= XAE_FLOW_CONTROL_OPTION;
#ifdef XLLTEMACIF_USE_JUMBO_FRAMES_EXPERIMENTAL
	options |= XAE_JUMBO_OPTION;
#endif
	options |= XAE_TRANSMITTER_ENABLE_OPTION;
	options |= XAE_RECEIVER_ENABLE_OPTION;
	options |= XAE_FCS_STRIP_OPTION;
	options |= XAE_MULTICAST_OPTION;
	XAxiEthernet_SetOptions(xaxiemacp, options);
	XAxiEthernet_ClearOptions(xaxiemacp, ~options);

	/* set mac address */
	XAxiEthernet_SetMacAddress(xaxiemacp, (Xuint8*)(netif->hwaddr));

	/* set PHY <--> MAC data clock */
#ifdef  CONFIG_LINKSPEED_AUTODETECT
	link_speed = get_IEEE_phy_speed(xaxiemacp);
	xil_printf("auto-negotiated link speed: %d\r\n", link_speed);
#elif	defined(CONFIG_LINKSPEED1000)
	link_speed = 1000;
#elif	defined(CONFIG_LINKSPEED100)
	link_speed = 100;
#elif	defined(CONFIG_LINKSPEED10)
	link_speed = 10;
#endif

    	XAxiEthernet_SetOperatingSpeed(xaxiemacp, link_speed);

	/* Setting the operating speed of the MAC needs a delay. */
	{
		volatile int wait;
		for (wait=0; wait < 100000; wait++);
		for (wait=0; wait < 100000; wait++);
	}

#ifdef NOTNOW
        /* in a soft temac implementation, we need to explicitly make sure that
         * the RX DCM has been locked. See xps_ll_temac manual for details.
         * This bit is guaranteed to be 1 for hard temac's
         */
        lock_message_printed = 0;
        while (!(XAxiEthernet_ReadReg(xaxiemacp->Config.BaseAddress, XAE_IS_OFFSET)
                    & XAE_INT_RXDCMLOCK_MASK)) {
                int first = 1;
                if (first) {
                        print("Waiting for RX DCM to lock..");
                        first = 0;
                        lock_message_printed = 1;
                }
        }

        if (lock_message_printed)
                print("RX DCM locked.\r\n");
#endif

	/* start the temac */
    	XAxiEthernet_Start(xaxiemacp);

	/* enable MAC interrupts */
	XAxiEthernet_IntEnable(xaxiemacp, XAE_INT_RECV_ERROR_MASK);
}
开发者ID:Malutan,项目名称:TE060X-GigaBee-Reference-Designs,代码行数:80,代码来源:xaxiemacif_hw.c

示例5: DisplayDemoChangeRes

void DisplayDemoChangeRes(DisplayCtrl *dispPtr)
{
	char userInput = 0;
	int fResSet = 0;
	int status;

	while (!fResSet)
	{
		DisplayDemoCRMenu(dispPtr);

		/* Store the first character in the UART recieve FIFO and echo it */
		userInput = getchar();
		xil_printf("%c", userInput);
		status = XST_SUCCESS;
		switch (userInput)
		{
		case '1':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_640x480);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '2':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_800x600);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '3':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_1280x720);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '4':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_1280x1024);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '5':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_1920x1080);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case 'q':
			fResSet = 1;
			break;
		default :
			xil_printf("\n\rInvalid Selection");
			{
				struct timespec ts;
				ts.tv_sec = 0;
				ts.tv_nsec = 500000000;
				nanosleep( &ts, NULL );
			}
		}
		if (status == XST_DMA_ERROR)
		{
			xil_printf("\n\rWARNING: AXI VDMA Error detected and cleared\n\r");
		}
	}
}
开发者ID:andrewandrepowell,项目名称:zybo_petalinux,代码行数:64,代码来源:display_demo.c

示例6: main

int main (void) {

   init_platform();
   XEmacLite *EmacLiteInstPtr = &EmacLiteInstance;
   XEmacLite_Config *ConfigPtr;

   ConfigPtr = XEmacLite_LookupConfig(EMAC_DEVICE_ID);
   XEmacLite_CfgInitialize(EmacLiteInstPtr, ConfigPtr, ConfigPtr->BaseAddress);

   // Hold AXI4-Stream Packet Generator/Checker
   Xil_Out32(XPAR_NF10_AXIS_GEN_CHECK_0_BASEADDR+0x3, 0x1);
   Xil_Out32(XPAR_NF10_AXIS_GEN_CHECK_1_BASEADDR+0x3, 0x1);

   char s;
   int port, dev;
   unsigned int value;

#if AEL2005_SR
   char port_mode_new[4] = {-1,-1,-1,-1};
   char port_mode[4] = {-1,-1,-1,-1};
#endif
   print("hiiiiiiiiiiiiiii");
   goto INIT;

   while(1){
       print("==NetFPGA-10G==\r\n");
       print("i : Initialize AEL2005\r\n");
       print("s : Dump status\r\n");
       print("t : Run AXI4-Stream Gen/Check\r\n");
       print("r : Stop AXI4-Stream Gen/Check\r\n");

       s = inbyte();
       if(s == 'i'){
INIT:      for(port = 0; port < 4; port ++){
               if(port == 0) dev = 2;
    		   if(port == 1) dev = 1;
    		   if(port == 2) dev = 0;
    		   if(port == 3) dev = 3;

    		   xil_printf("Port %d: ", port);
    		   ael2005_read (EmacLiteInstPtr, dev, 1, 0xa, &value);
    		   /*if(value == 0) {
    		       	print("No Signal.\r\n");
    		       	continue;
    		   }*/
    		   for(s = 20; s < 36; s++){
    		       	ael2005_i2c_read (EmacLiteInstPtr, dev, MODULE_DEV_ADDR, s, &value);
    		       	xil_printf("%c", value);
    		   }
    		   for(s = 40; s < 56; s++){
    		       	ael2005_i2c_read (EmacLiteInstPtr, dev, MODULE_DEV_ADDR, s, &value);
    		       	xil_printf("%c", value);
    		   }
    		   print("\r\n");

#if AEL2005_SR
    		   // Check if we have a 10GBASE-SR cable
    		   ael2005_i2c_read (EmacLiteInstPtr, dev, MODULE_DEV_ADDR, 0x3, &value);
    		   if((value >> 4) == 1) port_mode_new[port] = MODE_SR;
    		   else port_mode_new[port] = MODE_TWINAX;

    		   if(port_mode_new[port] != port_mode[port]){
    		       xil_printf("Port %d Detected new mode %x\r\n", port, port_mode_new[port]);
                   test_initialize(EmacLiteInstPtr, dev, port_mode_new[port]);
                   port_mode[port] = port_mode_new[port];
               }
#else
               test_initialize(EmacLiteInstPtr, dev, MODE_TWINAX);
#endif
           }
       }
开发者ID:feiranchen,项目名称:projectNPU,代码行数:71,代码来源:helloworld.c

示例7: printFloat

void printFloat(float f) {
	uint32_t scale = 100;
	uint32_t left = (int)(f*scale);
	xil_printf("%d", left);
}
开发者ID:parkerpatriot,项目名称:space-invaders,代码行数:5,代码来源:main.c

示例8: Dprx_InterruptHandlerNoVideo

/**
 * This function is the callback function for when a no video interrupt occurs.
 *
 * @param	InstancePtr is a pointer to the XDp instance.
 *
 * @return	None.
 *
 * @note	None.
 *
*******************************************************************************/
static void Dprx_InterruptHandlerNoVideo(void *InstancePtr)
{
	xil_printf("> Interrupt: no-video flags in the VBID field after active "
						"video has been received.\n");
}
开发者ID:bisptop,项目名称:embeddedsw,代码行数:15,代码来源:xdp_rx_intr_timer_example.c

示例9: Dprx_InterruptHandlerVideo

/**
 * This function is the callback function for when a valid video interrupt
 * occurs.
 *
 * @param	InstancePtr is a pointer to the XDp instance.
 *
 * @return	None.
 *
 * @note	None.
 *
*******************************************************************************/
static void Dprx_InterruptHandlerVideo(void *InstancePtr)
{
	xil_printf("> Interrupt: a valid video frame is detected on main "
								"link.\n");
}
开发者ID:bisptop,项目名称:embeddedsw,代码行数:16,代码来源:xdp_rx_intr_timer_example.c

示例10: hello_rotary

// Main Loop
int hello_rotary(void)
{

    unsigned int data;
    int pulses=0, dir=0;

	/***
    XUartNs550_SetBaud(UART_BASEADDR, UART_CLOCK, UART_BAUDRATE);
    XUartNs550_mSetLineControlReg(UART_BASEADDR, XUN_LCR_8_DATA_BITS);
    ***/

    xil_printf("\n\r********************************************************");
    xil_printf("\n\r********************************************************");
    xil_printf("\n\r**     KC705 - Rotary Switch Test                     **");
    xil_printf("\n\r********************************************************");
    xil_printf("\n\r********************************************************\r\n");
    xil_printf("Watch the ROTARY pulses count:\r\n");

    xil_printf("press any key to exit the test\r\n");
    XUartNs550_ReadReg(STDIN_BASEADDRESS, XUN_RBR_OFFSET);

    //set GPIO input mode
	XGpio_mSetDataReg(XPAR_ROTARY_GPIO_BASEADDR, 4, 0xffffffff);

	while(1)
	{
		/////////////////////////////////////
		// STATE 1: Get the direction pulse
		//xil_printf("   \r\nState1 \r\n");
		do
		{
			// get hold of a pulse that tells one of below
			// 		bits[1:0] = 01 Left rotation
			//		bits[1:0] = 10 Right rotation
			//		bit 2     =  1 button press

			data = XGpio_mGetDataReg(XPAR_ROTARY_GPIO_BASEADDR, 0);
			if(data & 0x1)
			{
				dir = DIR_LEFT;
				break;
			}
			if(data & 0x2)
			{
				dir = DIR_RIGHT;
				break;
			}

			if( XUartNs550_IsReceiveData(STDIN_BASEADDRESS) )
				goto rotary_exit;

		} while( (data& 0x3) == 0);

		//////////////////////////////////////////////
		// STATE 2: Get the pulses from both switches
		//xil_printf("   State2 \r\n");
		do
		{
			data = XGpio_mGetDataReg(XPAR_ROTARY_GPIO_BASEADDR, 0);
			if( XUartNs550_IsReceiveData(STDIN_BASEADDRESS) )
				goto rotary_exit;

		} while( (data& 0x3) != 0x3);

		/////////////////////////////////////////////////////
		// STATE 3: Get the pulses from both switches to NULL
		//xil_printf("   State3 \r\n");
		do
		{
			data = XGpio_mGetDataReg(XPAR_ROTARY_GPIO_BASEADDR, 0);
			if( XUartNs550_IsReceiveData(STDIN_BASEADDRESS) )
				goto rotary_exit;
		} while( (data& 0x3) != 0);

		// PRESS ANY KEY TO EXIT
		if( XUartNs550_IsReceiveData(STDIN_BASEADDRESS) )
			goto rotary_exit;

		// RESULT TO USER
		pulses += dir;
		xil_printf("%s-%d  [Exit: press anykey]\r\n",
				(dir==DIR_RIGHT) ? "Anti-Clockwise" : "     Clockwise",
				abs(pulses) );
	}

rotary_exit:
	XUartNs550_ReadReg(STDIN_BASEADDRESS, XUN_RBR_OFFSET);

	return 0;
}
开发者ID:fbalakirev,项目名称:kc705,代码行数:91,代码来源:rotary_simple.c

示例11: Dprx_InterruptHandlerPowerState

/**
 * This function is the callback function for when the power state interrupt
 * occurs.
 *
 * @param	InstancePtr is a pointer to the XDp instance.
 *
 * @return	None.
 *
 * @note	None.
 *
*******************************************************************************/
static void Dprx_InterruptHandlerPowerState(void *InstancePtr)
{
	xil_printf("> Interrupt: power state change request.\n");
}
开发者ID:bisptop,项目名称:embeddedsw,代码行数:15,代码来源:xdp_rx_intr_timer_example.c

示例12: XAxiDma_DumpBd

/**
 * Dump the fields of a BD.
 *
 * @param	BdPtr is the BD to operate on.
 *
 * @return	None
 *
 * @note	This function can be used only when DMA is in SG mode
 *
 *****************************************************************************/
void XAxiDma_DumpBd(XAxiDma_Bd* BdPtr)
{

	xil_printf("Dump BD %x:\r\n", (unsigned int)BdPtr);
	xil_printf("\tNext Bd Ptr: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_NDESC_OFFSET));
	xil_printf("\tBuff addr: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_BUFA_OFFSET));
	xil_printf("\tMCDMA Fields: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_MCCTL_OFFSET));
	xil_printf("\tVSIZE_STRIDE: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr,
					XAXIDMA_BD_STRIDE_VSIZE_OFFSET));
	xil_printf("\tContrl len: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_CTRL_LEN_OFFSET));
	xil_printf("\tStatus: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_STS_OFFSET));

	xil_printf("\tAPP 0: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_USR0_OFFSET));
	xil_printf("\tAPP 1: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_USR1_OFFSET));
	xil_printf("\tAPP 2: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_USR2_OFFSET));
	xil_printf("\tAPP 3: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_USR3_OFFSET));
	xil_printf("\tAPP 4: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_USR4_OFFSET));

	xil_printf("\tSW ID: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_ID_OFFSET));
	xil_printf("\tStsCtrl: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr,
	           XAXIDMA_BD_HAS_STSCNTRL_OFFSET));
	xil_printf("\tDRE: %x\r\n",
	    (unsigned int)XAxiDma_BdRead(BdPtr, XAXIDMA_BD_HAS_DRE_OFFSET));

	xil_printf("\r\n");
}
开发者ID:alown,项目名称:zynq,代码行数:49,代码来源:xaxidma_bd.c

示例13: pong

void pong(DisplayCtrl *video ,u32 uartAddress, XGpio *btn, XGpio *sw){
	u32 	height = video->vMode.height,
			width = video->vMode.width,
			stride = video->stride,
			*frame,
			speed = 2,
			pause=false;
	char 	entrada;
	frame=video->framePtr[video->curFrame];

	xil_printf("\x1B[H"); //Set cursor to top left of terminal
	xil_printf("\x1B[2J"); //Clear terminal


	Rectangulo bola=crearRectangulo(10,10,RED,ANCHO_BOLA,ALTO_BOLA);
	Rectangulo palaIzquierda = crearRectangulo(0,height/2-ALTO_PALA/2,GREEN,ANCHO_PALA,ALTO_PALA);
	Rectangulo palaDerecha = crearRectangulo(width-ANCHO_PALA,height/2-ALTO_PALA/2,GREEN,ANCHO_PALA,ALTO_PALA);

	int dir_x=true, dir_y=true, indice_frame=0,salir=0,pulsar=0,puntuacionA=0,puntuacionB=0;

	salir = XGpio_DiscreteRead(sw, 1);
	while(salir & 0x8){

		if (salir & 0x1) // 0x1=0b0001=posicion de SW0
			bola.color = WHITE;
		else
			bola.color = RED;

		//apunta a al siguente frame
		indice_frame=nextFrame(video,&frame);
		pintarFondo(frame, BLACK, width,height,stride);

		//movimiento y colision
		if(dir_x == DERECHA)
			if ((bola.x+ANCHO_BOLA > palaDerecha.x) && (bola.y >= palaDerecha.y && bola.y < palaDerecha.y+ALTO_PALA )){
				bola.x-=speed;
				dir_x = IZQUIERDA;
			}else{
				bola.x+=speed;
			}
		else
			if ((bola.x < palaIzquierda.x+ANCHO_PALA) && (bola.y >= palaIzquierda.y && bola.y < palaIzquierda.y+ALTO_PALA)){
				bola.x+=speed;
				dir_x = DERECHA;
			}else{
				bola.x-=speed;
			}
		if(dir_y == ABAJO)
			bola.y+=speed;
		else
			bola.y-=speed;
		//control de direccion
		if (bola.x<0){
			bola.x=width/2;
			bola.y=height/2;
			dir_x=DERECHA;
			puntuacionB++;
			xil_printf("%d - %d\n\r",puntuacionA,puntuacionB);
			TimerDelay(1500000);
		}else if(bola.x>width - ANCHO_BOLA){
			bola.x=width/2;
			bola.y=height/2;
			dir_x=IZQUIERDA;
			puntuacionA++;
			xil_printf("%d - %d\n\r",puntuacionA,puntuacionB);
			TimerDelay(1500000);
		}
		if (bola.y<0){
			bola.y=0;
			dir_y=ABAJO;
		}else if(bola.y>height - ALTO_BOLA){
			bola.y=height - ALTO_BOLA;
			dir_y=ARRIBA;
		}

		//pintar la pelota y las palas
		pintarRectangulo(frame,&bola,width,height,stride);
		pintarRectangulo(frame,&palaDerecha,width,height,stride);
		pintarRectangulo(frame,&palaIzquierda,width,height,stride);
		//flush
		Xil_DCacheFlushRange((unsigned int) frame, DISPLAY_MAX_FRAME * 4);
		DisplayChangeFrame(video,indice_frame);
		//TimerDelay(17000);
		salir = XGpio_DiscreteRead(sw, 1);
		pulsar = XGpio_DiscreteRead(btn, 1);

		//control de las palas
		if (pulsar & 0x1){  	//Pala derecha
			if (palaDerecha.y+ALTO_PALA < height){
				palaDerecha.y+=speed;
			}
		}else if(pulsar & 0x2){
			if (palaDerecha.y >= 0){
				palaDerecha.y-=speed;
			}
		}

		if (pulsar & 0x4 ){		//Pala izquierda
			if (palaIzquierda.y+ALTO_PALA < height){
				palaIzquierda.y+=speed;
//.........这里部分代码省略.........
开发者ID:felipebetancur,项目名称:Zybo,代码行数:101,代码来源:pong.c

示例14: DisplayDemoChangeRes

void DisplayDemoChangeRes(DisplayCtrl *dispPtr, u32 uartAddr)
{
	char userInput = 0;
	int fResSet = 0;
	int status;

	/* Flush UART FIFO */
	while (XUartPs_IsReceiveData(uartAddr))
	{
		XUartPs_ReadReg(uartAddr, XUARTPS_FIFO_OFFSET);
	}

	while (!fResSet)
	{
		DisplayDemoCRMenu(dispPtr);

		/* Wait for data on UART */
		while (!XUartPs_IsReceiveData(uartAddr))
		{}

		/* Store the first character in the UART recieve FIFO and echo it */
		userInput = XUartPs_ReadReg(uartAddr, XUARTPS_FIFO_OFFSET);
		xil_printf("%c", userInput);
		status = XST_SUCCESS;
		switch (userInput)
		{
		case '1':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_640x480);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '2':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_800x600);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '3':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_1280x720);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '4':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_1280x1024);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case '5':
			status = DisplayStop(dispPtr);
			DisplaySetMode(dispPtr, &VMODE_1920x1080);
			DisplayStart(dispPtr);
			fResSet = 1;
			break;
		case 'q':
			fResSet = 1;
			break;
		default :
			xil_printf("\n\rInvalid Selection");
			TimerDelay(500000);
		}
		if (status == XST_DMA_ERROR)
		{
			xil_printf("\n\rWARNING: AXI VDMA Error detected and cleared\n\r");
		}
	}
}
开发者ID:felipebetancur,项目名称:Zybo,代码行数:69,代码来源:pong.c

示例15: MainDemoPrintMenu

void MainDemoPrintMenu()
{
	xil_printf("\x1B[H"); //Set cursor to top left of terminal
	xil_printf("\x1B[2J"); //Clear terminal
	xil_printf("**************************************************\n\r");
	xil_printf("**************************************************\n\r");
	xil_printf("*         ZYBO Base System User Demo             *\n\r");
	xil_printf("**************************************************\n\r");
	xil_printf("**************************************************\n\r");
	xil_printf("\n\r");
	xil_printf("1 - Audio Demo\n\r");
	xil_printf("2 - VGA output demo\n\r");
	xil_printf("3 - HDMI output demo\n\r");
	xil_printf("q - Quit\n\r");
	xil_printf("\n\r");
	xil_printf("Select a demo to run:");
}
开发者ID:felipebetancur,项目名称:Zybo,代码行数:17,代码来源:main.c


注:本文中的xil_printf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。