(2)编写代码main.c #include "xgpiops.h" #include "sleep.h" int main() { static XGpioPs psGpioInstancePtr; XGpioPs_Config* GpioConfigPtr; int Led0 = 0; //MIO0_led int Led1 = 13; //MIO13_LED u32 uPinDirection = 0x1;//1表示输出,0表示输入 int xStatus; //--MIO的初始化 GpioConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID); if(GpioConfigPtr == NULL) return XST_FAILURE; xStatus = XGpioPs_CfgInitialize(&psGpioInstancePtr,GpioConfigPtr, GpioConfigPtr->BaseAddr); if(XST_SUCCESS != xStatus) print(" PS GPIO INIT FAILED \n\r"); //--MIO的输入输出操作 XGpioPs_SetDirectionPin(&psGpioInstancePtr, Led0,uPinDirection);//配置MIO输出方向 XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, Led0,1);//配置MIO的第0位输出 XGpioPs_SetDirectionPin(&psGpioInstancePtr, Led1,uPinDirection);//配置MIO输出方向 XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, Led1,1);//配置MIO的第13位输出 while(1) { XGpioPs_WritePin(&psGpioInstancePtr, Led0, 0);//MIO的第0位输出0 XGpioPs_WritePin(&psGpioInstancePtr, Led1, 1);//MIO的第13位输出1 sleep(1);//延时 XGpioPs_WritePin(&psGpioInstancePtr, Led0, 1);//MIO的第0位输出1 XGpioPs_WritePin(&psGpioInstancePtr, Led1, 0);//MIO的第13位输出0 sleep(1);//延时 } return 0; } 这里的0和13是电路图上PS端LED灯的所在位置如下图
|