Nios II Classic Software Developer’s Handbook

ID 683282
Date 5/14/2015
Public
Document Table of Contents

6.13.6. Use the Lightweight Device Driver API

The lightweight device driver API allows you to minimize the overhead of accessing device drivers. It has no direct effect on the size of the drivers themselves, but lets you eliminate driver API features which you might not need, reducing the overall size of the HAL code.

The lightweight device driver API is available for character-mode devices. The following device drivers support the lightweight device driver API:

  • JTAG UART
  • UART
  • Optrex 16207 LCD

For these devices, the lightweight device driver API conserves code space by eliminating the dynamic file descriptor table and replacing it with three static file descriptors, corresponding to stdin, stdout, and stderr. Library functions related to opening, closing, and manipulating file descriptors are unavailable, 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 section.