LoginSignup
0
0

More than 5 years have passed since last update.

Zybo > Chronicles blog 10 > xgpiops.h / 使用例 > Macros and functions required to drive the IO are defined with

Last updated at Posted at 2016-05-13

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);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0