Using C HAL in C++ projects
In Chapter 12, we explored the benefits of using C++ for HAL development. However, despite these advantages, target vendors provide HALs as C libraries. These libraries have been thoroughly tested on millions of devices worldwide, and vendors usually maintain them well, offering regular updates. Thus, it makes more sense to use them rather than re-implement the HAL in C++.
Next, we will create an interface-based design for the UART peripheral, which will provide us with a more flexible software design and allow us to decouple components that are using the UART interface from low-level details.
UART interface for flexible software design
In Chapter 5, we covered the importance of interfaces for flexible software design. There, we had an uart interface class that was implemented by the uart_stm32 class. The gsm_lib class depended on the uart interface, meaning we can reuse it with different uart interface implementations.
The uart_stm32 class...