ZYNQ-IP-AXI-GPIO

AXI GPIO 可以将 PS 端的一个 AXI 4-Lite 接口转化为 GPIO 接口,并且可以被配置为单端口或双端口,每个通道的位宽可以独立配置。

通过使能三态门可以将端口动态地配置为输入或输出。

AXIGPIO 是 ZYNQ PL 端的一个 IP 核,可以将 AXI-Lite Master 转为 GPIO,并且一个 AXI-Lite 接口可以通过 AXI interconnect 模块控制多个 AXI-GPIO。

AXI-GPIO IP 设置

最大时钟频率


Z y n q 7020 Zynq 7020 Zynq7020 的最大频率和 A r t i x 7 − 2 Artix 7-2 Artix7−2 的速率相同,为 140 M H z 140 MHz 140MHz。

AXI GPIO 设置

默认为单通道。GPIO 的方向在这里设置了以后就不能在 vitis 中设置 GPIO 的方向。

中断属于 PL 对 PS 的中断,需要在 ZYNQ 7 Processing System 中勾选

生成的 vitis 的代码中,xparameters.h 中的 id 默认从 ID 0 开始,不管 vivado 这边的 AXI-GPIO 的序号是从 0 开始还是从 1 开始。

!note

  1. GPIO 只能使能整个通道中断,无法单独使能通道中的某个引脚中断

  2. 中断类型只能设置为上升沿或高电平

AXI-GPIO 相关代码

初始化

c 复制代码
/****************************************************************************/

/**

* Initialize the XGpio instance provided by the caller based on the

* given configuration data.

*

* Nothing is done except to initialize the InstancePtr.

*

* @param    InstancePtr is a pointer to an XGpio instance. The memory the

*       pointer references must be pre-allocated by the caller. Further

*       calls to manipulate the driver through the XGpio API must be

*       made with this pointer.

* @param    Config is a reference to a structure containing information

*       about a specific GPIO device. This function initializes an

*       InstancePtr object for a specific device specified by the

*       contents of Config. This function can initialize multiple

*       instance objects with the use of multiple calls giving different

*       Config information on each call.

* @param    EffectiveAddr is the device base address in the virtual memory

*       address space. The caller is responsible for keeping the address

*       mapping from EffectiveAddr to the device physical base address

*       unchanged once this function is invoked. Unexpected errors may

*       occur if the address mapping changes after this function is

*       called. If address translation is not used, use

*       Config->BaseAddress for this parameters, passing the physical

*       address instead.

*

* @return

*       - XST_SUCCESS if the initialization is successful.

*

* @note     None.

*

*****************************************************************************/

int XGpio_CfgInitialize(XGpio * InstancePtr, XGpio_Config * Config,

            UINTPTR EffectiveAddr)

设置输入输出方向

c 复制代码
/****************************************************************************/

/**

* Set the input/output direction of all discrete signals for the specified

* GPIO channel.
*
* @param    InstancePtr is a pointer to an XGpio instance to be worked on.

* @param    Channel contains the channel of the GPIO (1 or 2) to operate on.

* @param    DirectionMask is a bitmask specifying which discretes are input

*       and which are output. Bits set to 0 are output and bits set to 1
*       are input.
*
* @return   None.

*

* @note     The hardware must be built for dual channels if this function

*       is used with any channel other than 1.  If it is not, this

*       function will assert.

*

*****************************************************************************/

void XGpio_SetDataDirection(XGpio *InstancePtr, unsigned Channel, u32 DirectionMask)

GPIO 读写

c 复制代码
/****************************************************************************/

/**

* Read state of discretes for the specified GPIO channel.


* @param    InstancePtr is a pointer to an XGpio instance to be worked on.
* @param    Channel contains the channel of the GPIO (1 or 2) to operate on.

* @return   Current copy of the discretes register.


* @note     The hardware must be built for dual channels if this function

*       is used with any channel other than 1.  If it is not, this

*       function will assert.
*****************************************************************************/

u32 XGpio_DiscreteRead(XGpio * InstancePtr, unsigned Channel)

/****************************************************************************/

/**

* Write to discretes register for the specified GPIO channel.

*

* @param    InstancePtr is a pointer to an XGpio instance to be worked on.

* @param    Channel contains the channel of the GPIO (1 or 2) to operate on.

* @param    Mask is the value to be written to the discretes register.

*

* @return   None.

*

* @note     The hardware must be built for dual channels if this function

*       is  used with any channel other than 1.  If it is not, this

*       function will assert. See also XGpio_DiscreteSet() and

*       XGpio_DiscreteClear().

*

*****************************************************************************/

void XGpio_DiscreteWrite(XGpio * InstancePtr, unsigned Channel, u32 Mask)
相关推荐
szxinmai主板定制专家8 小时前
国产RK3568+FPGA以 ‌“实时控制+高精度采集+灵活扩展”‌ 为核心的解决方案
大数据·运维·网络·人工智能·fpga开发·机器人
FPGA_ADDA8 小时前
基于FPGA 和DSP 的高性能6U VPX 采集处理板
fpga开发·dsp·6u vpx·8通道采集
FakeOccupational11 小时前
fpga系列 HDL:跨时钟域同步 脉冲展宽同步 Pulse Synchronization
fpga开发
丶七年先生12 小时前
牛客 verilog入门 VIP
fpga开发
hahaha601615 小时前
ARINC818协议(六)
网络·fpga开发
深圳信迈科技DSP+ARM+FPGA15 小时前
基于ARM+FPGA+DSP的储能协调控制器解决方案,支持国产化
arm开发·fpga开发·信号处理
承接电子控制相关项目19 小时前
单片机与FPGA的核心差异、优缺点、编程差异、典型应用场景、选型等对比分析
单片机·嵌入式硬件·fpga开发
XINVRY-FPGA21 小时前
XCZU19EG-2FFVC1760I Xilinx赛灵思FPGA Zynq UltraScale+MPSoC
c++·嵌入式硬件·阿里云·fpga开发·云计算·硬件工程·fpga
kanhao1001 天前
为什么FPGA中一般不使用浮点数进行计算?
fpga开发
9527华安1 天前
国产紫光同创FPGA实现SDI视频编解码+图像缩放,基于HSSTHP高速接口,提供2套工程源码和技术支持
fpga开发·视频编解码·图像缩放·紫光同创·sdi·高速接口·hssthp