XilinxProcessorIPLib/drivers/gpio/examples/xgpio_tapp_example.c
int GpioOutputExample(u16 DeviceId, u32 GpioWidth)
{
	volatile int Delay;
	u32 LedBit;
	u32 LedLoop;
	int Status;

	/*
	 * Initialize the GPIO driver so that it's ready to use,
	 * specify the device ID that is generated in xparameters.h
	 */
	 Status = XGpio_Initialize(&GpioOutput, DeviceId);
	 if (Status != XST_SUCCESS)  {
		  return XST_FAILURE;
	 }

	 /* Set the direction for all signals to be outputs */
	 XGpio_SetDataDirection(&GpioOutput, LED_CHANNEL, 0x0);

	 /* Set the GPIO outputs to low */
	 XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 0x0);

	 for (LedBit = 0x0; LedBit < GpioWidth; LedBit++)  {

		for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop++) {

			/* Set the GPIO Output to High */
			XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL,
						1 << LedBit);

#ifndef __SIM__
			/* Wait a small amount of time so the LED is visible */
			for (Delay = 0; Delay < LED_DELAY; Delay++);

#endif
			/* Clear the GPIO Output */
			XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL,
						1 << LedBit);


#ifndef __SIM__
			/* Wait a small amount of time so the LED is visible */
			for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif

		  }

	 }

	 return XST_SUCCESS;

}
/*****************************************************************************/
/**
*
* This function does a minimal test on the GPIO device configured as OUTPUT
* and driver as a example.
*
*
* @param	DeviceId is the XPAR_<GPIO_instance>_DEVICE_ID value from
*		xparameters.h
* @param	GpioWidth is the width of the GPIO
*
* @return
*		- XST_SUCCESS if successful
*		- XST_FAILURE if unsuccessful
*
* @note		None
*
****************************************************************************/
This function does a minimal test on the GPIO device configured as OUTPUT
and driver as a example.
This function does a minimal test on the GPIO device configured as OUTPUT and driver as a example .
int GpioOutputExample(u16 DeviceId, u32 GpioWidth)
{
	volatile int Delay;
	u32 LedBit;
	u32 LedLoop;
	int Status;
	 Status = XGpio_Initialize(&GpioOutput, DeviceId);
	 if (Status != XST_SUCCESS)  {
		  return XST_FAILURE;
	 }
	 XGpio_SetDataDirection(&GpioOutput, LED_CHANNEL, 0x0);
	 XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 0x0);
	 for (LedBit = 0x0; LedBit < GpioWidth; LedBit++)  {
		for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop++) {
			XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL,
						1 << LedBit);
#ifndef __SIM__
			for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif
			XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL,
						1 << LedBit);
#ifndef __SIM__
			for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif
		  }
	 }
	 return XST_SUCCESS;
}
int GpioOutputExample ( u16 DeviceId , u32 GpioWidth ) { volatile int Delay ; u32 LedBit ; u32 LedLoop ; int Status ; Status = XGpio_Initialize ( & GpioOutput , DeviceId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XGpio_SetDataDirection ( & GpioOutput , LED_CHANNEL , 0x0 ) ; XGpio_DiscreteWrite ( & GpioOutput , LED_CHANNEL , 0x0 ) ; for ( LedBit = 0x0 ; LedBit < GpioWidth ; LedBit ++ ) { for ( LedLoop = 0 ; LedLoop < LED_MAX_BLINK ; LedLoop ++ ) { XGpio_DiscreteWrite ( & GpioOutput , LED_CHANNEL , 1 << LedBit ) ; #ifndef __SIM__ for ( Delay = 0 ; Delay < LED_DELAY ; Delay ++ ) ; #endif XGpio_DiscreteClear ( & GpioOutput , LED_CHANNEL , 1 << LedBit ) ; #ifndef __SIM__ for ( Delay = 0 ; Delay < LED_DELAY ; Delay ++ ) ; #endif } } return XST_SUCCESS ; }
This function does a minimal test on the GPIO device configured as OUTPUT
and driver as a example.
This function does a minimal test on the GPIO device configured as OUTPUT and driver as a example .
/*
	 * Initialize the GPIO driver so that it's ready to use,
	 * specify the device ID that is generated in xparameters.h
	 */ /* Set the direction for all signals to be outputs */ /* Set the GPIO outputs to low */ /* Set the GPIO Output to High */ /* Wait a small amount of time so the LED is visible */ /* Clear the GPIO Output */ /* Wait a small amount of time so the LED is visible */