MicroZed Chronicles リスト http://adiuvoengineering.com/?page_id=285
@ Adam Taylor blog
xgpiops.h
Macros and functions required to drive the IO are defined with the file xgpiops.h, which is available under the BSP include files. This file contains the needed configuration and initialization functions for the Zynq SoC’s GPIO, along with functions to support reading from and writing to the GPIO, which is after all what we are most interested in.
使用例
定義など
#include "xgpiops.h"
#define ledpin 47
XGpioPs Gpio;
int Status;
XGpioPs_Config *GPIOConfigPtr;
XGpioPsで検索するともれなくXGpioPs_Configも検索されるというBad naming。
ソールリーディングがしにくくなるので、XGpioPSをXGpioPs_typeのような別名にマクロ定義するなどした方がいいのだろうか。
初期化
//GPIO Initilization
GPIOConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
Status = XGpioPs_CfgInitialize(&Gpio, GPIOConfigPtr, GPIOConfigPtr ->BaseAddr);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
方向設定と書込み
XGpioPs_SetDirectionPin(&Gpio, ledpin, 1);
XGpioPs_SetOutputEnablePin(&Gpio, ledpin, 1);
XGpioPs_WritePin(&Gpio, ledpin, 0x0);
読込み
XGpioPs_ReadPin(&Gpio, INPUT_PIN);