Nios® V Processor Software Developer Handbook

ID 743810
Date 5/26/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

7.10. Reducing Code Footprint in HAL Embedded Drivers

The HAL provides several options for reducing the size, or footprint, of the BSP code. Some of these options require explicit support from device drivers. If you need to minimize the size of your software, consider using reduced footprint drivers. This technique usually reduces driver functionality.

The HAL defines a C preprocessor macro named ALT_USE_SMALL_DRIVERS that you can use in driver source code to provide alternate behavior for systems that require a minimal code footprint. If ALT_USE_SMALL_DRIVERS is not defined, driver source code implements a fully featured version of the driver. If the macro is defined, the source code might provide a driver with restricted functionality. For example a driver might implement interrupt-driven operation by default, but polled (and presumably smaller) operation if ALT_USE_SMALL_DRIVERS is defined.

When writing a device driver, if you choose to ignore the value of ALT_USE_SMALL_DRIVERS, the same version of the driver is used regardless of the definition of this macro. You can enable ALT_USE_SMALL_DRIVERS in a BSP with the hal.enable_reduced_device_drivers BSP setting.

For more information, refer to the Settings Managed by Nios V Boards Support Package Editor.