Software Drivers

xgpiops.c File Reference

#include "xgpiops.h"

Functions

void StubHandler (void *CallBackRef, int Bank, u32 Status)
int XGpioPs_CfgInitialize (XGpioPs *InstancePtr, XGpioPs_Config *ConfigPtr, u32 EffectiveAddr)
u32 XGpioPs_Read (XGpioPs *InstancePtr, u8 Bank)
int XGpioPs_ReadPin (XGpioPs *InstancePtr, int Pin)
void XGpioPs_Write (XGpioPs *InstancePtr, u8 Bank, u32 Data)
void XGpioPs_WritePin (XGpioPs *InstancePtr, int Pin, int Data)
void XGpioPs_SetDirection (XGpioPs *InstancePtr, u8 Bank, u32 Direction)
void XGpioPs_SetDirectionPin (XGpioPs *InstancePtr, int Pin, int Direction)
u32 XGpioPs_GetDirection (XGpioPs *InstancePtr, u8 Bank)
int XGpioPs_GetDirectionPin (XGpioPs *InstancePtr, int Pin)
void XGpioPs_SetOutputEnable (XGpioPs *InstancePtr, u8 Bank, u32 OpEnable)
void XGpioPs_SetOutputEnablePin (XGpioPs *InstancePtr, int Pin, int OpEnable)
u32 XGpioPs_GetOutputEnable (XGpioPs *InstancePtr, u8 Bank)
int XGpioPs_GetOutputEnablePin (XGpioPs *InstancePtr, int Pin)
void XGpioPs_GetBankPin (u8 PinNumber, u8 *BankNumber, u8 *PinNumberInBank)

Variables

unsigned int XGpioPsPinTable []

Detailed Description

The XGpioPs driver. Functions in this file are the minimum required functions for this driver. See xgpiops.h for a detailed description of the driver.

 MODIFICATION HISTORY:
 Ver   Who  Date     Changes
 ----- ---- -------- -----------------------------------------------
 1.00a sv   01/15/10 First Release
 1.01a sv   04/15/12 Removed the APIs XGpioPs_SetMode, XGpioPs_SetModePin
                     XGpioPs_GetMode, XGpioPs_GetModePin as they are not
		      relevant to Zynq device. The interrupts are disabled
		      for output pins on all banks during initialization.
 2.1   hk   04/29/14 Use Input data register DATA_RO for read. CR# 771667.
 

Function Documentation

void StubHandler ( void *  CallBackRef,
int  Bank,
u32  Status 
)

This is a stub for the status callback. The stub is here in case the upper layers do not set the handler.

Parameters:
CallBackRef is a pointer to the upper layer callback reference
Bank is the GPIO Bank in which an interrupt occurred.
Status is the Interrupt status of the GPIO bank.
Returns:
None.
Note:
None.
int XGpioPs_CfgInitialize ( XGpioPs InstancePtr,
XGpioPs_Config ConfigPtr,
u32  EffectiveAddr 
)
void XGpioPs_GetBankPin ( u8  PinNumber,
u8 *  BankNumber,
u8 *  PinNumberInBank 
)
u32 XGpioPs_GetDirection ( XGpioPs InstancePtr,
u8  Bank 
)

Get the Direction of the pins of the specified GPIO Bank.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Bank is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1.

return Returns a 32 bit mask of the Direction register. Bits with 0 are in Input mode, bits with 1 are in Output Mode.

Note:
None.
int XGpioPs_GetDirectionPin ( XGpioPs InstancePtr,
int  Pin 
)

Get the Direction of the specified pin.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Pin is the pin number for which the Direction is to be retrieved. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1.
Returns:
Direction of the specified pin.
  • 0 for Input Direction
  • 1 for Output Direction
Note:
None.
u32 XGpioPs_GetOutputEnable ( XGpioPs InstancePtr,
u8  Bank 
)

Get the Output Enable status of the pins of the specified GPIO Bank.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Bank is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1.

return Returns a a 32 bit mask of the Output Enable register. Bits with 0 are in Disabled state, bits with 1 are in Enabled State.

Note:
None.
int XGpioPs_GetOutputEnablePin ( XGpioPs InstancePtr,
int  Pin 
)

Get the Output Enable status of the specified pin.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Pin is the pin number for which the Output Enable status is to be retrieved. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1.
Returns:
Output Enable of the specified pin.
  • 0 if Output Enable is disabled for this pin
  • 1 if Output Enable is enabled for this pin
Note:
None.
u32 XGpioPs_Read ( XGpioPs InstancePtr,
u8  Bank 
)

Read the Data register of the specified GPIO bank.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Bank is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1.
Returns:
Current value of the Data register.
Note:
This function is used for reading the state of all the GPIO pins of specified bank.
int XGpioPs_ReadPin ( XGpioPs InstancePtr,
int  Pin 
)

Read Data from the specified pin.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Pin is the pin number for which the data has to be read. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. See xgpiops.h for the mapping of the pin numbers in the banks.
Returns:
Current value of the Pin (0 or 1).
Note:
This function is used for reading the state of the specified GPIO pin.
void XGpioPs_SetDirection ( XGpioPs InstancePtr,
u8  Bank,
u32  Direction 
)

Set the Direction of the pins of the specified GPIO Bank.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Bank is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1.
Direction is the 32 bit mask of the Pin direction to be set for all the pins in the Bank. Bits with 0 are set to Input mode, bits with 1 are set to Output Mode.
Returns:
None.
Note:
This function is used for setting the direction of all the pins in the specified bank. The previous state of the pins is not maintained.
void XGpioPs_SetDirectionPin ( XGpioPs InstancePtr,
int  Pin,
int  Direction 
)

Set the Direction of the specified pin.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Pin is the pin number to which the Data is to be written. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1.
Direction is the direction to be set for the specified pin. Valid values are 0 for Input Direction, 1 for Output Direction.
Returns:
None.
void XGpioPs_SetOutputEnable ( XGpioPs InstancePtr,
u8  Bank,
u32  OpEnable 
)

Set the Output Enable of the pins of the specified GPIO Bank.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Bank is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1.
OpEnable is the 32 bit mask of the Output Enables to be set for all the pins in the Bank. The Output Enable of bits with 0 are disabled, the Output Enable of bits with 1 are enabled.
Returns:
None.
Note:
This function is used for setting the Output Enables of all the pins in the specified bank. The previous state of the Output Enables is not maintained.
void XGpioPs_SetOutputEnablePin ( XGpioPs InstancePtr,
int  Pin,
int  OpEnable 
)

Set the Output Enable of the specified pin.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Pin is the pin number to which the Data is to be written. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1.
OpEnable specifies whether the Output Enable for the specified pin should be enabled. Valid values are 0 for Disabling Output Enable, 1 for Enabling Output Enable.
Returns:
None.
Note:
None.
void XGpioPs_Write ( XGpioPs InstancePtr,
u8  Bank,
u32  Data 
)

Write to the Data register of the specified GPIO bank.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Bank is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1.
Data is the value to be written to the Data register.
Returns:
None.
Note:
This function is used for writing to all the GPIO pins of the bank. The previous state of the pins is not maintained.
void XGpioPs_WritePin ( XGpioPs InstancePtr,
int  Pin,
int  Data 
)

Write data to the specified pin.

Parameters:
InstancePtr is a pointer to the XGpioPs instance.
Pin is the pin number to which the Data is to be written. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1.
Data is the data to be written to the specified pin (0 or 1).
Returns:
None.
Note:
This function does a masked write to the specified pin of the specified GPIO bank. The previous state of other pins is maintained.

Variable Documentation

unsigned int XGpioPsPinTable[]
Initial value:
 {
        31,
        53,
        85,
        117
}