mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 10:27:34 +00:00
Added ADC implementation for STM32
This commit is contained in:
33
src/devices/stm32/adc.cpp
Normal file
33
src/devices/stm32/adc.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <sta/devices/stm32/adc.hpp>
|
||||
|
||||
#ifdef STA_PLATFORM_STM32
|
||||
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
STM32ADC::STM32ADC(ADC_HandleTypeDef * handle)
|
||||
: handle_{handle}
|
||||
{
|
||||
STA_ASSERT(handle != nullptr);
|
||||
}
|
||||
|
||||
void STM32ADC::start()
|
||||
{
|
||||
HAL_ADC_Start(handle_);
|
||||
}
|
||||
|
||||
void STM32ADC::poll(uint32_t timeout)
|
||||
{
|
||||
HAL_StatusTypeDef res = HAL_ADC_PollForConversion(handle_, timeout);
|
||||
|
||||
STA_ASSERT(res == HAL_OK);
|
||||
}
|
||||
|
||||
uint32_t STM32ADC::getValue()
|
||||
{
|
||||
return HAL_ADC_GetValue(handle_);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_STM32
|
Reference in New Issue
Block a user