#include "xstatus.h"
#include "xgpiops_hw.h"
Classes | |
struct | XGpioPs_Config |
struct | XGpioPs |
Defines | |
#define | XGPIOPS_H |
#define | XGPIOPS_BANK0 0 |
#define | XGPIOPS_BANK1 1 |
#define | XGPIOPS_BANK2 2 |
#define | XGPIOPS_BANK3 3 |
#define | XGPIOPS_MAX_BANKS 4 |
#define | XGPIOPS_BANK_MAX_PINS 32 |
#define | XGPIOPS_DEVICE_MAX_PIN_NUM 118 |
Interrupt types | |
#define | XGPIOPS_IRQ_TYPE_EDGE_RISING 0 |
#define | XGPIOPS_IRQ_TYPE_EDGE_FALLING 1 |
#define | XGPIOPS_IRQ_TYPE_EDGE_BOTH 2 |
#define | XGPIOPS_IRQ_TYPE_LEVEL_HIGH 3 |
#define | XGPIOPS_IRQ_TYPE_LEVEL_LOW 4 |
Typedefs | |
typedef void(* | XGpioPs_Handler )(void *CallBackRef, int Bank, u32 Status) |
Functions | |
int | XGpioPs_CfgInitialize (XGpioPs *InstancePtr, XGpioPs_Config *ConfigPtr, u32 EffectiveAddr) |
u32 | XGpioPs_Read (XGpioPs *InstancePtr, u8 Bank) |
void | XGpioPs_Write (XGpioPs *InstancePtr, u8 Bank, u32 Data) |
void | XGpioPs_SetDirection (XGpioPs *InstancePtr, u8 Bank, u32 Direction) |
u32 | XGpioPs_GetDirection (XGpioPs *InstancePtr, u8 Bank) |
void | XGpioPs_SetOutputEnable (XGpioPs *InstancePtr, u8 Bank, u32 Enable) |
u32 | XGpioPs_GetOutputEnable (XGpioPs *InstancePtr, u8 Bank) |
void | XGpioPs_GetBankPin (u8 PinNumber, u8 *BankNumber, u8 *PinNumberInBank) |
int | XGpioPs_ReadPin (XGpioPs *InstancePtr, int Pin) |
void | XGpioPs_WritePin (XGpioPs *InstancePtr, int Pin, int Data) |
void | XGpioPs_SetDirectionPin (XGpioPs *InstancePtr, int Pin, int Direction) |
int | XGpioPs_GetDirectionPin (XGpioPs *InstancePtr, int Pin) |
void | XGpioPs_SetOutputEnablePin (XGpioPs *InstancePtr, int Pin, int Enable) |
int | XGpioPs_GetOutputEnablePin (XGpioPs *InstancePtr, int Pin) |
int | XGpioPs_SelfTest (XGpioPs *InstancePtr) |
void | XGpioPs_IntrEnable (XGpioPs *InstancePtr, u8 Bank, u32 Mask) |
void | XGpioPs_IntrDisable (XGpioPs *InstancePtr, u8 Bank, u32 Mask) |
u32 | XGpioPs_IntrGetEnabled (XGpioPs *InstancePtr, u8 Bank) |
u32 | XGpioPs_IntrGetStatus (XGpioPs *InstancePtr, u8 Bank) |
void | XGpioPs_IntrClear (XGpioPs *InstancePtr, u8 Bank, u32 Mask) |
void | XGpioPs_SetIntrType (XGpioPs *InstancePtr, u8 Bank, u32 IntrType, u32 IntrPolarity, u32 IntrOnAny) |
void | XGpioPs_GetIntrType (XGpioPs *InstancePtr, u8 Bank, u32 *IntrType, u32 *IntrPolarity, u32 *IntrOnAny) |
void | XGpioPs_SetCallbackHandler (XGpioPs *InstancePtr, void *CallBackRef, XGpioPs_Handler FuncPtr) |
void | XGpioPs_IntrHandler (XGpioPs *InstancePtr) |
void | XGpioPs_SetIntrTypePin (XGpioPs *InstancePtr, int Pin, u8 IrqType) |
u8 | XGpioPs_GetIntrTypePin (XGpioPs *InstancePtr, int Pin) |
void | XGpioPs_IntrEnablePin (XGpioPs *InstancePtr, int Pin) |
void | XGpioPs_IntrDisablePin (XGpioPs *InstancePtr, int Pin) |
int | XGpioPs_IntrGetEnabledPin (XGpioPs *InstancePtr, int Pin) |
int | XGpioPs_IntrGetStatusPin (XGpioPs *InstancePtr, int Pin) |
void | XGpioPs_IntrClearPin (XGpioPs *InstancePtr, int Pin) |
XGpioPs_Config * | XGpioPs_LookupConfig (u16 DeviceId) |
#define XGPIOPS_BANK0 0 |
GPIO Bank 0
#define XGPIOPS_BANK1 1 |
GPIO Bank 1
#define XGPIOPS_BANK2 2 |
GPIO Bank 2
#define XGPIOPS_BANK3 3 |
GPIO Bank 3
#define XGPIOPS_BANK_MAX_PINS 32 |
Max pins in a GPIO bank
#define XGPIOPS_DEVICE_MAX_PIN_NUM 118 |
#define XGPIOPS_H |
#define XGPIOPS_IRQ_TYPE_EDGE_BOTH 2 |
Interrupt on both edges
#define XGPIOPS_IRQ_TYPE_EDGE_FALLING 1 |
Interrupt Falling edge
#define XGPIOPS_IRQ_TYPE_EDGE_RISING 0 |
Interrupt on Rising edge
#define XGPIOPS_IRQ_TYPE_LEVEL_HIGH 3 |
Interrupt on high level
#define XGPIOPS_IRQ_TYPE_LEVEL_LOW 4 |
Interrupt on low level
#define XGPIOPS_MAX_BANKS 4 |
Max banks in a GPIO device
typedef void(* XGpioPs_Handler)(void *CallBackRef, int Bank, u32 Status) |
This handler data type allows the user to define a callback function to handle the interrupts for the GPIO device. The application using this driver is expected to define a handler of this type, to support interrupt driven mode. The handler executes in an interrupt context such that minimal processing should be performed.
CallBackRef | is a callback reference passed in by the upper layer when setting the callback functions for a GPIO bank. It is passed back to the upper layer when the callback is invoked. Its type is not important to the driver component, so it is a void pointer. | |
Bank | is the bank for which the interrupt status has changed. | |
Status | is the Interrupt status of the GPIO bank. |
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.
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.
int XGpioPs_GetDirectionPin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
Get the Direction of the specified pin.
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. |
void XGpioPs_GetIntrType | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 * | IntrType, | |||
u32 * | IntrPolarity, | |||
u32 * | IntrOnAny | |||
) |
This function is used for getting the Interrupt Type, Interrupt Polarity and Interrupt On Any for the specified GPIO Bank pins.
InstancePtr | is a pointer to an XGpioPs instance. | |
Bank | is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1. | |
IntrType | returns the 32 bit mask of the interrupt type. 0 means Level Sensitive and 1 means Edge Sensitive. | |
IntrPolarity | returns the 32 bit mask of the interrupt polarity. 0 means Active Low or Falling Edge and 1 means Active High or Rising Edge. | |
IntrOnAny | returns the 32 bit mask of the interrupt trigger for edge triggered interrupts. 0 means trigger on single edge using the configured interrupt polarity and 1 means trigger on both edges. |
u8 XGpioPs_GetIntrTypePin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
This function returns the IRQ Type of a given GPIO pin.
InstancePtr | is a pointer to an XGpioPs instance. | |
Pin | is the pin number whose IRQ type is to be obtained. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. |
u32 XGpioPs_GetOutputEnable | ( | XGpioPs * | InstancePtr, | |
u8 | Bank | |||
) |
Get the Output Enable status of the pins of the specified GPIO Bank.
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.
int XGpioPs_GetOutputEnablePin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
Get the Output Enable status of the specified pin.
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. |
void XGpioPs_IntrClear | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | Mask | |||
) |
This function clears pending interrupt(s) with the provided mask. This function should be called after the software has serviced the interrupts that are pending.
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. | |
Mask | is the mask of the interrupts to be cleared. Bit positions of 1 will be cleared. Bit positions of 0 will not change the previous interrupt status. |
void XGpioPs_IntrClearPin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
This function clears the specified pending interrupt. This function should be called after the software has serviced the interrupts that are pending.
InstancePtr | is a pointer to the XGpioPs instance. | |
Pin | is the pin number for which the interrupt status is to be cleared. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. |
void XGpioPs_IntrDisable | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | Mask | |||
) |
This function disables the interrupts for the specified pins in the specified bank.
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. | |
Mask | is the bit mask of the pins for which interrupts are to be disabled. Bit positions of 1 will be disabled. Bit positions of 0 will keep the previous setting. |
void XGpioPs_IntrDisablePin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
This function disables the interrupts for the specified pin.
InstancePtr | is a pointer to the XGpioPs instance. | |
Pin | is the pin number for which the interrupt is to be disabled. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. |
void XGpioPs_IntrEnable | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | Mask | |||
) |
This function enables the interrupts for the specified pins in the specified bank.
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. | |
Mask | is the bit mask of the pins for which interrupts are to be enabled. Bit positions of 1 will be enabled. Bit positions of 0 will keep the previous setting. |
void XGpioPs_IntrEnablePin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
This function enables the interrupt for the specified pin.
InstancePtr | is a pointer to the XGpioPs instance. | |
Pin | is the pin number for which the interrupt is to be enabled. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. |
u32 XGpioPs_IntrGetEnabled | ( | XGpioPs * | InstancePtr, | |
u8 | Bank | |||
) |
This function returns the interrupt enable status for a bank.
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. |
int XGpioPs_IntrGetEnabledPin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
This function returns whether interrupts are enabled for the specified pin.
InstancePtr | is a pointer to the XGpioPs instance. | |
Pin | is the pin number for which the interrupt enable status is to be known. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. |
u32 XGpioPs_IntrGetStatus | ( | XGpioPs * | InstancePtr, | |
u8 | Bank | |||
) |
This function returns interrupt status read from Interrupt Status Register.
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. |
int XGpioPs_IntrGetStatusPin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
This function returns interrupt enable status of the specified pin.
InstancePtr | is a pointer to the XGpioPs instance. | |
Pin | is the pin number for which the interrupt enable status is to be known. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. |
void XGpioPs_IntrHandler | ( | XGpioPs * | InstancePtr | ) |
This function is the interrupt handler for GPIO interrupts.It checks the interrupt status registers of all the banks to determine the actual bank in which an interrupt has been triggered. It then calls the upper layer callback handler set by the function XGpioPs_SetBankHandler(). The callback is called when an interrupt
InstancePtr | is a pointer to the XGpioPs instance. |
XGpioPs_Config* XGpioPs_LookupConfig | ( | u16 | DeviceId | ) |
This function looks for the device configuration based on the unique device ID. The table XGpioPs_ConfigTable[] contains the configuration information for each device in the system.
DeviceId | is the unique device ID of the device being looked up. |
u32 XGpioPs_Read | ( | XGpioPs * | InstancePtr, | |
u8 | Bank | |||
) |
Read the Data register of the specified GPIO bank.
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. |
int XGpioPs_ReadPin | ( | XGpioPs * | InstancePtr, | |
int | Pin | |||
) |
Read Data from the specified pin.
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. |
int XGpioPs_SelfTest | ( | XGpioPs * | InstancePtr | ) |
This function runs a self-test on the GPIO driver/device. This function does a register read/write test on some of the Interrupt Registers.
InstancePtr | is a pointer to the XGpioPs instance. |
void XGpioPs_SetCallbackHandler | ( | XGpioPs * | InstancePtr, | |
void * | CallBackRef, | |||
XGpioPs_Handler | FuncPtr | |||
) |
This function sets the status callback function. The callback function is called by the XGpioPs_IntrHandler when an interrupt occurs.
InstancePtr | is a pointer to the XGpioPs instance. | |
CallBackRef | is the upper layer callback reference passed back when the callback function is invoked. | |
FuncPtr | is the pointer to the callback function. |
void XGpioPs_SetDirection | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | Direction | |||
) |
Set the Direction of the pins of the specified GPIO Bank.
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. |
void XGpioPs_SetDirectionPin | ( | XGpioPs * | InstancePtr, | |
int | Pin, | |||
int | Direction | |||
) |
Set the Direction of the specified pin.
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. |
void XGpioPs_SetIntrType | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | IntrType, | |||
u32 | IntrPolarity, | |||
u32 | IntrOnAny | |||
) |
This function is used for setting the Interrupt Type, Interrupt Polarity and Interrupt On Any for the specified GPIO Bank pins.
InstancePtr | is a pointer to an XGpioPs instance. | |
Bank | is the bank number of the GPIO to operate on. Valid values are 0 to XGPIOPS_MAX_BANKS - 1. | |
IntrType | is the 32 bit mask of the interrupt type. 0 means Level Sensitive and 1 means Edge Sensitive. | |
IntrPolarity | is the 32 bit mask of the interrupt polarity. 0 means Active Low or Falling Edge and 1 means Active High or Rising Edge. | |
IntrOnAny | is the 32 bit mask of the interrupt trigger for edge triggered interrupts. 0 means trigger on single edge using the configured interrupt polarity and 1 means trigger on both edges. |
void XGpioPs_SetIntrTypePin | ( | XGpioPs * | InstancePtr, | |
int | Pin, | |||
u8 | IrqType | |||
) |
This function is used for setting the IRQ Type of a single GPIO pin.
InstancePtr | is a pointer to an XGpioPs instance. | |
Pin | is the pin number whose IRQ type is to be set. Valid values are 0 to XGPIOPS_DEVICE_MAX_PIN_NUM - 1. | |
IrqType | is the IRQ type for GPIO Pin. Use XGPIOPS_IRQ_TYPE_* defined in xgpiops.h to specify the IRQ type. |
void XGpioPs_SetOutputEnable | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | OpEnable | |||
) |
Set the Output Enable of the pins of the specified GPIO Bank.
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. |
void XGpioPs_SetOutputEnablePin | ( | XGpioPs * | InstancePtr, | |
int | Pin, | |||
int | OpEnable | |||
) |
Set the Output Enable of the specified pin.
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. |
void XGpioPs_Write | ( | XGpioPs * | InstancePtr, | |
u8 | Bank, | |||
u32 | Data | |||
) |
Write to the Data register of the specified GPIO bank.
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. |
void XGpioPs_WritePin | ( | XGpioPs * | InstancePtr, | |
int | Pin, | |||
int | Data | |||
) |
Write data to the specified pin.
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). |
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.