int main(int argc, char **argv)
{
void *virtual_base;
int fd;
unsigned char indata;
// map the address space for the LED registers into user space so we can interact with them.
// we'll actually map in the entire CSR span of the HPS since we want to access various registers within that span
if( ( fd = open( "/dev/mem", ( O_RDWR | O_SYNC ) ) ) == -1 ) {
printf( "ERROR: could not open \"/dev/mem\"...\n" );
return( 1 );
}
virtual_base = mmap( NULL, HW_REGS_SPAN, ( PROT_READ | PROT_WRITE ), MAP_SHARED, fd, HW_REGS_BASE );
if( virtual_base == MAP_FAILED ) {
printf( "ERROR: mmap() failed...\n" );
close( fd );
return(1);
}
h2p_lw_uart_addr=virtual_base + ( ( unsigned long )( ALT_LWFPGASLVS_OFST + UART_BASE ) & ( unsigned long)( HW_REGS_MASK ) );
/***********************************************************
DATA REGIST:
8. . . 0 DATA R/W The value to transfer to/from the RS232
UART Core. When writing, the DATA field
is a character to be written to the write FIFO.
When reading, the DATA field is a character
read from the read FIFO.
9 PE R Indicates whether the DATA field had a parity
error.
15 RVALID R Indicates whether the DATA and PE fields
contain valid data.
23. . . 16 RAVAIL R The number of characters remaining in the
read FIFO (including this read).
CONTROL REGIST
0 RE R/W Interrupt-enable bit for read interrupts
1 WE R/W Interrupt-enable bit for write interrupts
8 RI R Indicates that the read interrupt is pending
9 WI R Indicates that the write interrupt is pending
23. . . 16 WSPACE R The number of spaces available in the write
IFO.