gpio
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Macros Groups Pages
xgpio_low_level_example.c File Reference

Overview

Demonstrates usage of the GPIO low-level driver and hardware device.

This file contains a design example using the General Purpose I/O (GPIO) low level driver and hardware device. It only uses channel 1 of a GPIO device.

MODIFICATION HISTORY:
Ver   Who  Date  Changes


1.00b jhl 04/29/02 First release 2.00a jhl 12/30/02 Addition of dual channel capability 2.00a sv 04/18/05 Minor changes to comply to Doxygen and coding guidelines 3.00a ktn 11/21/09 Removed the macros XGpio_mSetDataDirection, XGpio_mGetDataReg and XGpio_mSetDataReg. Users should use XGpio_WriteReg/XGpio_ReadReg to achieve the same functionality. 4.1 lks 11/18/15 Updated to use canonical xparameters and clean up of the comments and code for CR 900381 4.3 ms 01/23/17 Added xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. 4.5 sne 06/12/19 Fixed IAR compiler warning. 4.10 gm 07/11/23 Added SDT support. 4.14 vn 09/10/26 Align Doxygen comments with AMD standards

#include "xparameters.h"
#include "xgpio_l.h"
#include "xil_printf.h"

Macros

#define LED   0x01
 Assumes bit 0 of GPIO is connected to an LED. More...
 
#define LED_DELAY   1000000
 LED visibility delay count. More...
 
#define LED_CHANNEL   1
 LED channel selection. More...
 
Device parameters

The following constants map to the XPAR parameters created in the xparameters.h file.

They are defined here so that all the needed parameters can be easily changed in one place.

#define GPIO_REG_BASEADDR   XPAR_XGPIO_0_BASEADDR
 GPIO base address. More...
 

Functions

int main (void)
 Demonstrates turning on and off an LED using the GPIO low-level driver. More...
 

Macro Definition Documentation

#define GPIO_REG_BASEADDR   XPAR_XGPIO_0_BASEADDR

GPIO base address.

Referenced by main().

#define LED   0x01

Assumes bit 0 of GPIO is connected to an LED.

Referenced by main().

#define LED_CHANNEL   1

LED channel selection.

The following constant is used to determine which channel of the GPIO is used for the LED if there are two channels supported.

Referenced by main().

#define LED_DELAY   1000000

LED visibility delay count.

The following constant is used to wait after an LED is turned on to make sure that it is visible to the human eye. This constant might need to be tuned for faster or slower processor speeds.

Referenced by main().

Function Documentation

int main ( void  )

Demonstrates turning on and off an LED using the GPIO low-level driver.

Returns
Always 0.
Note
The main function returns an integer to prevent compiler warnings.

References GPIO_REG_BASEADDR, LED, LED_CHANNEL, LED_DELAY, XGPIO_CHAN_OFFSET, XGPIO_DATA_OFFSET, XGpio_ReadReg, XGPIO_TRI_OFFSET, and XGpio_WriteReg.