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

Overview

This file contains a example for using AXI GPIO hardware and driver.

This example assumes that there is a UART Device or STDIO Device in the hardware system.

Note

None

MODIFICATION HISTORY:
Ver     Who  Date         Changes


1.00a sv 04/15/05 Initial release for TestApp integration. 3.00a sv 11/21/09 Updated to use HAL Processor APIs. 3.01a bss 04/18/13 Removed incorrect Documentation lines.(CR #701641) 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.10 gm 07/11/23 Added SDT support. 4.10 gm 08/28/23 Update example to support peripheral tests. 4.13 vlt 12/17/25 Update Doxygen comments to include SDT flow details.

 
#include "xparameters.h"
#include "xgpio.h"
#include "stdio.h"
#include "xstatus.h"
#include "xil_printf.h"

Functions

int GpioOutputExample (XGpio *GpioOutputPtr, UINTPTR BaseAddress)
 This function does a minimal test on the GPIO device configured as OUTPUT and driver as a example. More...
 
int GpioInputExample (UINTPTR BaseAddress, u32 *DataRead)
 This function performs a test on the GPIO driver/device with the GPIO configured as INPUT. More...
 
int main (void)
 Main function to call the example. More...
 

Function Documentation

int GpioInputExample ( UINTPTR  BaseAddress,
u32 *  DataRead 
)

This function performs a test on the GPIO driver/device with the GPIO configured as INPUT.

Parameters
BaseAddresscontains the base address of the device
DataReadis the pointer where the data read from GPIO Input is returned
Returns
  • XST_SUCCESS if the Test is successful
  • XST_FAILURE if the test is not successful
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XGpio_DiscreteRead(), XGpio_Initialize(), and XGpio_SetDataDirection().

Referenced by main().

int GpioOutputExample ( XGpio GpioOutputPtr,
UINTPTR  BaseAddress 
)

This function does a minimal test on the GPIO device configured as OUTPUT and driver as a example.

Parameters
GpioOutputPtris a pointer to the GPIO driver Instance
BaseAddresscontains the base address of the device
Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if unsuccessful
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XGpio_Config::Width, XGpio_DiscreteClear(), XGpio_DiscreteWrite(), XGpio_Initialize(), XGpio_LookupConfig(), and XGpio_SetDataDirection().

Referenced by main().

int main ( void  )

Main function to call the example.

This function is not included if the example is generated from the Peripheral Tests in SDK.

Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if unsuccessful
Note
None

References GpioInputExample(), and GpioOutputExample().