Specifications
The HAL Peripheral-Specific API
If the peripheral does not belong to one of the HAL generic device model classes, you need to provide a
device driver with an interface that is specific to the hardware implementation. In this case, the API to the
device is separate from the HAL API. Programs access the hardware by calling the functions you provide,
not the HAL API.
The up-front effort to implement integration in the HAL API is higher, but you gain the benefit of the
HAL and C standard library API to manipulate devices.
For details about integration in the HAL API, refer to the “Integrating a Device Driver in the HAL”
chapter.
All the other sections in this chapter apply to integrating drivers in the HAL API and creating drivers with
a peripheral-specific API.
Note: Although C++ is supported for programs based on the HAL, HAL drivers can not be written in C+
+. Restrict your driver code to either C or assembly language. C is preferred for portability.
Related Information
Integrating a Device Driver in the HAL on page 7-15
Preparing for HAL Driver Development
This chapter assumes that you are familiar with C programming for the HAL.
For more information, refer to the "Developing Programs Using the Hardware Abstraction Layer" chapter
of the Nios II Software Developer’s Handbook.
Note:
This chapter uses the variable <Altera installation> to represent the location where the Altera
®
Complete Design Suite is installed. On a Windows system, by default, that location is c:/altera/
<version number>.
Related Information
Developing Programs Using the Hardware Abstraction Layer on page 6-1
Development Flow for Creating Device Drivers
The steps to develop a new driver for the HAL depend on your device details. However, the following
generic steps apply to all device classes.
1. Create the device header file that describes the registers. This header file might be the only interface
required.
2. Implement the driver functionality.
3. Test from main().
4. Proceed to the final integration of the driver in the HAL environment.
5. Integrate the device driver in the HAL framework.
7-2
The HAL Peripheral-Specific API
NII5V2
2015.05.14
Altera Corporation
Developing Device Drivers for the Hardware Abstraction Layer
Send Feedback