Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,252 Views

How to know what files to include in Nios II main file?

When I initially created a system with just a JTAG UART as peripheral and then chose "Nios II application and BSP from template" and then selected small hello world, the .c file with the main routine contained only 1 header file: 

# include "sys/alt_stdio.h" 

 

I assume that this contains the printf function used for hello world application. However, I do not find a folder named sys anywhere in the things generated by the Nios II Eclipse IDE. 

 

Anyway, when I later add more peripherals like PIO to my design and regenerate the SOPC file, how do I know what header files to include so I can use the new peripherals? Also, where are the HAL version of IORD and IORW declared for the new peripherals like the PIO?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
145 Views

Hello XAUI 

 

You have to look into the board support package project (BSP project) 

 

Example:  

C:\FpgaQsysProjects\Q16\tse_tutorial\software\tse_hello_world == your files 

C:\FpgaQsysProjects\Q16\tse_tutorial\software\tse_hello_world_bsp\drivers\inc == supporting routines for the hardware selected. 

 

These files are not generated by Eclipse but by Qsys based on the configuration you built in Qsys. 

 

Best Regards, 

Johi.
Altera_Forum
Honored Contributor I
145 Views

Yes after experimentation I found what files are needed, depends on what we are doing. 

 

alt_stdio for stdin and stdout 

system.h always needed as it has constants needed for HAL functions 

io.h if we are using the iord and iowr functions 

peripheral headers e.g alt_timer_regs.h if we are using the timer as it contains timer specific HAL functions that are easier to use then IORD and IOWR 

if we use usleep then we need unistd.h 

if we are using interrupts that need to be registerd then we must include alt_irq.h 

then if we are using HAL types like alt_uint16 then we need alt_types.h too 

 

yes it keeps going
Reply