|
#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 );
} |
|