moerjielovecookie

Sawen_Blog

一个普通工科牲的博客网站
x
github
follow
email

ZYNQ-IP-AXI-GPIO

AXI GPIO は、PS 側の AXI 4-Lite インターフェースを GPIO インターフェースに変換でき、単一ポートまたは双ポートとして構成でき、各チャネルのビット幅を独立して設定できます。
三態ゲートを有効にすることで、ポートを動的に入力または出力として構成できます。
axigpio|500
AXIGPIO は ZYNQ PL 側の IP コアで、AXI-Lite マスターを GPIO に変換でき、1 つの AXI-Lite インターフェースは AXI インターコネクトモジュールを介して複数の AXI-GPIO を制御できます。

AXI-GPIO IP 設定#

最大クロック周波数#

|500
$Zynq 7020$ の最大周波数は $Artix 7-2$ の速度と同じで、$140 MHz$ です。

AXI GPIO 設定#

AXIGPIOip|500
デフォルトでは単一チャネルです。GPIO の方向はここで設定した後、vitis で GPIO の方向を設定することはできません。
割り込みは PL から PS への割り込みで、ZYNQ 7 Processing System でチェックを入れる必要があります。
|500

生成された vitis のコードでは、xparameters.hの id はデフォルトで ID 0 から始まり、vivado 側の AXI-GPIO のシーケンス番号が 0 から始まるか 1 から始まるかに関係なくなります。

[!note]

  1. GPIO はチャネル全体の割り込みを有効にすることしかできず、チャネル内の特定のピンの割り込みを個別に有効にすることはできません。
  2. |400
    割り込みタイプは立ち上がりエッジまたは高レベルに設定する必要があります。

AXI-GPIO 関連コード#

初期化#

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

/**

* 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)

入出力方向の設定#

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

/**

* 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 の読み書き#

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

/**

* 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)
読み込み中...
文章は、創作者によって署名され、ブロックチェーンに安全に保存されています。