HPS通过HPS-to-FPGA桥访问FPGA的i/o口的问题,不是轻型桥,有没有弄过的,我弄了两天了,就是各种不通。
I/O口访问都是通过轻型桥的,其它桥接都是RAM型的,
#include
#include
#include
#include
#include "hwlib.h"
#include "socal/socal.h"
#include "socal/hps.h"
#include "socal/alt_gpio.h"
#include "hps_0.h"
#define ALT_AXI_HPS2FPGA_OFST (0xC0000000) // axi_master
#define HW_FPGA_AXI_SPAN (0x04000000) // Bridge span
#define HW_FPGA_AXI_MASK ( HW_FPGA_AXI_SPAN - 1 )
int main() {
void *axi_virtual_base;
int fd;
int buf;
static volatile unsigned long *h2p_memory_addr=NULL;
if( ( fd = open( "/dev/mem", ( O_RDWR | O_SYNC ) ) ) == -1 ) {
printf( "ERROR: could not open \"/dev/mem\"...\n" );
return( 1 );
}
axi_virtual_base = mmap( NULL, HW_FPGA_AXI_SPAN, ( PROT_READ | PROT_WRITE ), MAP_SHARED, fd,ALT_AXI_HPS2FPGA_OFST );
if( axi_virtual_base == MAP_FAILED ) {
printf( "ERROR: axi mmap() failed...\n" );
close( fd );
return( 1 );
}
h2p_memory_addr=axi_virtual_base + ( ( unsigned long )(DATA_PIO_0_BASE) & ( unsigned long)( HW_FPGA_AXI_MASK ) );
buf=(*(uint32_t*)h2p_memory_addr);
printf("%d\n",buf);
close( fd );
return( 0 );
}
看看代码有和错误,DATA pio是32位的,求求各位大神!