Hardware Abstraction Layer (HAL)
Introduction
The Hardware Abstraction Layer (HAL) is a crate which should provide the following:
- Serial communication drivers
- GPIO drivers
- ADC/DAC drivers (if applicable)
- Clocks / Timers
- Hardware Interrupts
Normally, a HAL would also provide the initialization code for the microcontroller. But, in our case, the Ada runtime for the MCU already provides it.
The HAL implementation should have a dependency on the hal
crate, which is already available in the community Alire index. This crate provides an interface that will need to be implemented for each of the microcontrollers we are using. To make this task easier, we will use the SVD bindings (see next section) that are generated by the svd2ada utility.
Creating a Hardware Abstraction Layer
Creating an hardware abstraction layer for the first time will be a challenging task. However there are many great resources to learn how to complete it. Here are a few of them: