Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

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?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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