Add HAL init

This commit is contained in:
Henrik Stickann 2022-04-24 13:41:21 +02:00
parent 867d884d67
commit f940dd9710
2 changed files with 39 additions and 0 deletions

17
include/sta/hal/init.hpp Normal file
View File

@ -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

22
src/hal/init.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <sta/hal/init.hpp>
#include <sta/assert.hpp>
#ifdef STA_HAL_DELAY_US_TIM
#include <tim.h>
#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
}
}