Software Storage Technologies
Virtual RAID, RSTe, and Memory Drive Technology
Announcements
Looking for our RealSense Community? Click HERE

Looking for RAID, VROC? You found the forum to ask questions!

Using UART FD

Chloé_Russell
Beginner
1,571 Views

Hello,

 

This is my first use of Software drivers. I'm working with the Quartus standard version 16.0.

 

when I used the "altera_avalon_uart_write" and "altera_avalon_uart_read" functions, things go right.. but when trying to use FD (altera_avalon_uart_write_fd and altera_avalon_uart_read_fd) , the parameter SP points to a false base address although the file has been correctly opened, it returns a valid value (!=NULL).

 

my code is :

 

int main()

{

 altera_avalon_uart_state* sp_UART_0;

  altera_avalon_uart_state* sp_UART_1;

 

  sp_UART_0->base = UART_0_BASE;

  sp_UART_1->base = UART_1_BASE;

 

  char tx_buffer[8] = "BITBANG";

  char rx_buffer[8];

 

   alt_fd* fp_uart_1;

   alt_fd* fp_uart_0;

 

   fp_uart_1= open ("/dev/uart_1", O_RDWR); //Open file for reading and writing

   fp_uart_0= open ("/dev/uart_0",O_RDWR); //Open file for reading and writing

 

   printf("call init uart\n");

   altera_avalon_uart_init(sp_UART_1, UART_1_IRQ_INTERRUPT_CONTROLLER_ID,UART_1_IRQ);

   altera_avalon_uart_init(sp_UART_0, UART_0_IRQ_INTERRUPT_CONTROLLER_ID,UART_0_IRQ);

 

   int wr = altera_avalon_uart_write_fd (fp_uart_1,tx_buffer,sizeof(tx_buffer)) ;

   printf("wr = %d\n",wr);

   alt_busy_sleep(1000000); / delay 1us /// 1 s

 

   int rd = altera_avalon_uart_read_fd (fp_uart_0,rx_buffer,sizeof(tx_buffer)) ;

   alt_busy_sleep(1000000); / delay 1us /// 1 s

   printf(" rd = %d\n",rd);

 

   printf("rx_buffer = '%s'\n\n",rx_buffer);

 

   printf("sp_UART_0 base = 0x%08X \n", sp_UART_0->base);

   printf("sp_UART_0 ctrl = 0x%08X \n", sp_UART_0->ctrl);

   printf("sp_UART_0 tx_buf = '%s' \n", sp_UART_0->tx_buf);

   printf("sp_UART_0 rx_buf = '%s' \n\n\n", sp_UART_0->rx_buf);

 

   printf("sp_UART_1 base = 0x%08X \n", sp_UART_1->base);

   printf("sp_UART_1 ctrl = 0x%08X \n", sp_UART_1->ctrl);

   printf("sp_UART_1 tx_buf = '%s' \n", sp_UART_1->tx_buf);

   printf("sp_UART_1 rx_buf = '%s' \n\n", sp_UART_1->rx_buf);

 

   printf(" rx_buffer = %s\n",rx_buffer);

 

  altera_avalon_uart_close (fp_uart_1) ;

  altera_avalon_uart_close (fp_uart_0) ;

 

  free(fp_uart_1);

  free(fp_uart_0);

 

 return 0;

}

 

 

I'm not sure if I'm missing or using things wrong, any help would be much appreciated. Thank you in advance

0 Kudos
1 Reply
JosafathB_Intel
Moderator
839 Views
Hello Chloé Russell, Thank you for contacting Intel® SSD Support. We advise to post a question on the Intel Community in the “FPGA Design Tools Forum”. If you have Premier Support, you may submit a ticket by going to the My Intel Dashboard, and under the My Support section, click the Intel® Premier Support button to submit your request.” This case is now closed. Best regards, Josh B. Intel Customer Support Technician Under Contract to Intel Corporation
0 Kudos
Reply