1. Hardware platform structures
in Block Design was added and AXI_GPIO module ZYNQ7 Processing System, double AXI_GPIO set to output the drive external IO device (e.g., LED). Good build the system configuration as shown below:
2. Software design SDK
SDK software design can refer to the official design documents, the main API function has,
- int XGpio_Initialize(XGpio * InstancePtr,u16 DeviceId)
- void XGpio_SetDataDirection(XGpio * InstancePtr,unsigned Channel,u32 DirectionMask)
- void XGpio_DiscreteWrite(XGpio * InstancePtr,unsigned Channel,u32 Data)
- u32 XGpio_DiscreteRead(XGpio * InstancePtr,unsigned Channel)
- void XGpio_DiscreteClear(XGpio * InstancePtr,unsigned Channel,u32 Mask)
Specific code as follows,
int main(void)
{
int Status;
volatile int Delay;
/* Initialize the GPIO driver */
Status = XGpio_Initialize(&Gpio, GPIO_EXAMPLE_DEVICE_ID);
if (Status != XST_SUCCESS) {
xil_printf("Gpio Initialization Failed\r\n");
return XST_FAILURE;
}
/* Set the direction for all signals as inputs except the LED output */
XGpio_SetDataDirection(&Gpio, LED_CHANNEL, ~LED);
xil_printf("Gpio Example\r\n");
/* Loop forever blinking the LED */
while (1) {
/* Set the LED to High */
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, LED);
/* Wait a small amount of time so the LED is visible */
for (Delay = 0; Delay < LED_DELAY; Delay++);
/* Clear the LED bit */
XGpio_DiscreteClear(&Gpio, LED_CHANNEL, LED);
/* Wait a small amount of time so the LED is visible */
for (Delay = 0; Delay < LED_DELAY; Delay++);
}
xil_printf("Successfully ran Gpio Example\r\n");
return XST_SUCCESS;
}
3. compile and run
download FPGA code to run the software Hardware, in the print terminal GPIO Example, outside LED blinking.