From f940dd9710b1c906ea522ded4ec663e86b9ef257 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Sun, 24 Apr 2022 13:41:21 +0200 Subject: [PATCH] Add HAL init --- include/sta/hal/init.hpp | 17 +++++++++++++++++ src/hal/init.cpp | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/sta/hal/init.hpp create mode 100644 src/hal/init.cpp diff --git a/include/sta/hal/init.hpp b/include/sta/hal/init.hpp new file mode 100644 index 0000000..4c8cd48 --- /dev/null +++ b/include/sta/hal/init.hpp @@ -0,0 +1,17 @@ +/** + * @brief Global HAL initialization. + */ +#ifndef STA_HAL_INIT_HPP +#define STA_HAL_INIT_HPP + + +namespace sta +{ + /** + * @brief Initialize global HAL objects. + */ + void initHAL(); +} // namespace sta + + +#endif // STA_HAL_INIT_HPP diff --git a/src/hal/init.cpp b/src/hal/init.cpp new file mode 100644 index 0000000..4d6d13a --- /dev/null +++ b/src/hal/init.cpp @@ -0,0 +1,22 @@ +#include + +#include + +#ifdef STA_HAL_DELAY_US_TIM +#include +#endif // STA_HAL_DELAY_US_TIM + + +namespace sta +{ + void initHAL() + { +#ifdef STA_HAL_DELAY_US_TIM + // Validate TIM used for delayUs + extern bool isValidDelayUsTIM(); + STA_ASSERT(isValidDelayUsTIM()); + // Start timer base + HAL_TIM_Base_Start(&STA_HAL_DELAY_US_TIM); +#endif // STA_HAL_DELAY_US_TIM + } +}