Xilinx / embeddedsw

Xilinx Embedded Software (embeddedsw) Development
Other
933 stars 1.07k forks source link

xgpiops_polled_example.c GPIO LED pin for Versal #159

Open sarenameas opened 3 years ago

sarenameas commented 3 years ago

Hello! In the xgpiops_polled_example.c, only the Zynq platforms are shown. What is the Output_Pin value for the Versal Development kit's USER GPIO LED? I am having trouble finding it based on the schematics and the register reference.

https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/gpiops/examples/xgpiops_polled_example.c#L153-L163

int GpioPolledExample(u16 DeviceId, u32 *DataRead)
{
    int Status;
    XGpioPs_Config *ConfigPtr;
    int Type_of_board;

    /* Initialize the GPIO driver. */
    ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);
    Type_of_board = XGetPlatform_Info();
    switch (Type_of_board) {
        case XPLAT_ZYNQ_ULTRA_MP:
            Input_Pin = 22;
            Output_Pin = 23;
            break;

        case XPLAT_ZYNQ:
            Input_Pin = 14;
            Output_Pin = 10;
            break;
    }
gcnugoud commented 3 years ago

Hi,

On Versal Development Kits LED/Switch are connected to EMIO pin not to the MIO bank, you need PL design for the same.

Versal Platform we have two GPIOPS instances :PMC GPIO and PS GPIO PMC GPIO contain 4 banks and 116 pins, organized as follows:

Driver supports both PS GPIO and PMC GPIO. For accessing PMC GPIOs application you need to set "GPIO.PmcGpio = 1" otherwise it accesses PS GPIO.

Here is reference code

ifdef versal

    case XPLAT_VERSAL:
        /* Accessing PMC GPIO by setting field to 1 */
        Gpio.PmcGpio =  1;
        Input_Pin    = 56;
        Output_Pin   = 52;
        break;

endif

Thanks, Srinivas