API: DriverLib vs. HAL

DriverLib and HAL are both forms of API, and therefore, it is easy to confuse them with each other. The ideas behind each are similar: to highlight the basic purposes of functions by hiding away the exact hardware details needed to make them work. However, it is important to note that the DriverLib is not a form of HAL.

While DriverLib does obscure hardware details to an extent, DriverLib functions are generally not portable. Most DriverLib functions require specific parameters that are unique to the Launchpad’s architecture. Trying to use a DriverLib function to develop on an Arduino won’t get you anywhere. It’s also important to note that DriverLib functions are pre-existing functions that were developed by Texas Instruments. They are merely a convenience to use. Whether you use them or not makes no difference to a programmer trying to port your code to an entirely new architecture, because DriverLib and bit manipulation will both look nonsensical and will have to be scrapped to support the new architecture.


HAL is more of an abstract concept than an actual tool. The programmer has to develop their own HAL when writing code; it is not a convenient library developed by Texas Instruments that you can just import. Because HAL functions are so generalized, it is much easier to port code that has that abstraction layer than code that consists purely of DriverLib functions. A programmer trying to port your code to an Arduino will have an easier time due to the HAL. If they see a function called TurnOn_LED(), all they have to do is replace the function definition with the specific hardware configurations needed to turn on the Arduino’s LED.

This below repository contains four projects. All four implement a simple application that uses one LED and one switch on the Launchpad board. It shows how to program a GPIO. One of the projects uses both HAL and Driverlib functions (HAL_Driverlib). One uses neither of them (noHAL_noDriverlib), while the remaining two uses only one of HAL or Driverlib (noHAL_Driverlib and HAL_noDriverlib).

https://github.com/ECE2564-VT/basic_example_GPIO.git

The below image provides a graphical view of how various software layers and hardware are stacked in the above example. It also summarizes the positive and negative points associated with each approach.