39 lines
543 B
C++
39 lines
543 B
C++
/*
|
|
* peripherals_utility.hpp
|
|
*
|
|
* Created on: Feb 24, 2021
|
|
* Author: erki
|
|
*/
|
|
|
|
#ifndef PERIPHERALS_UTILITY_HPP_
|
|
#define PERIPHERALS_UTILITY_HPP_
|
|
|
|
#include <cstdint>
|
|
|
|
#include "peripherals_config.hpp"
|
|
|
|
namespace Peripherals
|
|
{
|
|
|
|
void Initialize();
|
|
|
|
#ifdef PERIPHERALS_USE_DELAY_US
|
|
void DelayUs(const std::uint32_t micros);
|
|
#endif
|
|
|
|
template<typename T>
|
|
constexpr const T& Clamp(const T& v, const T& lo, const T& hi)
|
|
{
|
|
if (v > hi)
|
|
return hi;
|
|
else if (v < lo)
|
|
return lo;
|
|
else
|
|
return v;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endif /* PERIPHERALS_UTILITY_HPP_ */
|