1 原理介绍
一个AXI GPIO 模块有两个GPIO,分别是GPIO和GPIO2,也就是channel1和channel2,为
双向IO。
AXI GPIO的寄存器也不多,主要是两个channel
的数据寄存器GPIO_DATA和GPIO2_DATA,两个channel的方向控制GPIO_TRI和GPIO2_TRI,以
及全局中断使能寄存器GIER,IP的中断使能IP IER和中断状态寄存器ISR,具体的功能可以看
AXI GPIO 的文档 pg144。
AXI_GPIO 直接操作寄存器输出
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xgpio.h"
#include "sleep.h"
#define GPIO_BASEADDR 0x41200000
#define DATA_OFFSET 0x0
#define TRI_OFFSET 0x4
#define LED_DELAY 100000000
int main()
{
init_platform();
print("Hello World\n\r");
//volatile int Delay;
/* Set the direction for all signals as outputs */
*(int *)(GPIO_BASEADDR + TRI_OFFSET) = 0x00 ;
while (1) {
/* Set the LED to High */
*(int *)(GPIO_BASEADDR + DATA_OFFSET) = 0xF ;
/* Wait a small amount of time so the LED is visible */
//for (Delay = 0; Delay < LED_DELAY; Delay++);
sleep(1);
/* Set the LED to Low */
*(int *)(GPIO_BASEADDR + DATA_OFFSET) = 0x00 ;
/* Wait a small amount of time so the LED is visible */
//for (Delay = 0; Delay < LED_DELAY; Delay++);
sleep(1);
}
cleanup_platform();
return 0;
}
本实验中断来自PL,PS最大可以接收
16 个来自PL的中断信号,都是上升沿或高电平触发。