2024-01-07 23:23:35 +01:00

55 lines
1.1 KiB
C++

#ifndef STA_CORE_STM32_ADC_HPP
#define STA_CORE_STM32_ADC_HPP
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/devices/stm32/hal.hpp>
# ifdef HAL_ADC_MODULE_ENABLED
# define STA_STM32_ADC_ENABLED
# endif
#endif
#if defined(STA_STM32_ADC_ENABLED) || defined(DOXYGEN)
namespace sta
{
/**
* @brief A wrapper class for the STM32 ADC peripheral.
*
* @ingroup sta_core_stm32
*/
class STM32ADC
{
public:
/**
* @param handle A handle to a STM32 ADC.
*/
STM32ADC(ADC_HandleTypeDef * handle);
/**
* @brief Starts conversion of the incoming analog signal.
*/
void start();
/**
* @brief Polls for the converted analog signal.
*
* @param timeout
*/
void poll(uint32_t timeout);
/**
* @brief Get the value of the converted analog signal.
*
* @return uint32_t
*/
uint32_t getValue();
private:
ADC_HandleTypeDef * handle_;
};
} // namespace sta
#endif // STA_STM32_ADC_ENABLED
#endif // STA_CORE_STM32_ADC_HPP