Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

8.10.2.2. Using Macros

When you build your BSP with ALT_USE_DIRECT_DRIVERS enabled, instead of using file descriptors, the HAL accesses your drivers with the following macros:
  • ALT_DRIVER_READ(instance, buffer, len, flags)
  • ALT_DRIVER_WRITE(instance, buffer, len, flags)
  • ALT_DRIVER_IOCTL(instance, req, arg)

These macros are defined in < Nios® II EDS install path>/components/altera_hal/HAL/inc/sys/alt_driver.h.

These macros, together with the system-specific macros that the Nios® II SBT creates in system.h, generate calls to your driver functions. For example, with lightweight drivers turned on, printf() calls the HAL write() function, which directly calls your driver’s <component class> _write() function, bypassing file descriptors.

You can enable ALT_USE_DIRECT_DRIVERS in a BSP with the hal.enable_lightweight_device_driver_api BSP setting.

For more information, refer to the " Nios® II Software Build Tools Reference" chapter.