#include "sys/alt_stdio.h"
#include "alt_types.h"
#include<io.h>
#include<system.h>
#include<stdio.h>
#include "altera_avalon_pio_regs.h"
#include "altera_avalon_fifo.h"
#include "altera_avalon_fifo_util.h"
#include "altera_avalon_fifo_regs.h"
#define FIFO_0_IN_BASE 0x3000
#define ctrl_address 0x3040
int main()
{
int result,i=0;
int *data=0;
IOWR(ENABLE_BASE, 0, 0x1); // Enable the counter
alt_printf("Hello from Nios II!\n"); // Send Hello World to the JTAG UART
while(1)
{
//*data = IORD_ALTERA_AVALON_FIFO_DATA(FIFO_0_IN_BASE);
data=altera_avalon_read_fifo(FIFO_0_IN_BASE, ctrl_address, 0);
printf("%d\n",*data);
}
/* {
altera_avalon_read_fifo(FIFO_0_IN_CSR_BASE, ctrl_address, *data);
printf("LEVEL: %u\n", level);
while(1)
{
result=IORD(FIFO_0_IN_BASE, 0);
printf("%d\n",result);
}
for (i=0;i<100;i++)
{
result=IORD(COUNTER_OUT_BASE, 0);
printf("%d\n",(result+i));
}*/
return 0;
}