Specifications

but all other library functionality is available. You can refer to stdin, stdout, and stderr as you would to
any other file descriptor. You can also refer to the following predefined file numbers:
#define STDIN 0
#define STDOUT 1
#define STDERR 2
This option is appropriate if your program has a limited need for file I/O. The Altera host-based file
system and the Altera read-only zip file system are not available with the reduced device driver API. You
can select the reduced device drivers through BSP settings.
By default, the lightweight device driver API is disabled.
For more information about the lightweight device driver API, refer to the Developing Device Drivers for
the Hardware Abstraction Layer chapter of the Nios II Software Developer’s Handbook.
Related Information
Developing Programs Using the Hardware Abstraction Layer on page 6-1
Use the Minimal Character-Mode API
If you can limit your use of character-mode I/O to very simple features, you can reduce code footprint by
using the minimal character-mode API. This API includes the following functions:
alt_printf()
alt_putchar()
alt_putstr()
alt_getchar()
These functions are appropriate if your program only needs to accept command strings and send simple
text messages. Some of them are helpful only in conjunction with the lightweight device driver API.
For more information, refer to the “Use the Lightweight Device Driver API” chapter.
To use the minimal character-mode API, include the header file sys/alt_stdio.h.
The following sections outline the effects of the functions on code footprint.
Related Information
Use the Lightweight Device Driver API on page 6-31
alt_printf()
This function is similar to printf(), but supports only the %c %s, %x, and %% substitution strings.
alt_printf() takes up substantially less code space than printf(), regardless whether you select the
lightweight device driver API. alt_printf() occupies less than 1 KBKB with compiler optimization level
-O2.
alt_putchar()
Equivalent to putchar(). In conjunction with the lightweight device driver API, this function further
reduces code footprint. In the absence of the lightweight API, it calls putchar().
alt_putstr()
Similar to puts(), except that it does not append a newline character to the string. In conjunction with
the lightweight device driver API, this function further reduces code footprint. In the absence of the
lightweight API, it calls puts().
6-32
Use the Minimal Character-Mode API
NII5V2
2015.05.14
Altera Corporation
Developing Programs Using the Hardware Abstraction Layer
Send Feedback