semf
stm32analogin.h
Go to the documentation of this file.
1
10#ifndef SEMF_HARDWAREABSTRACTION_STM32_STM32ANALOGIN_H_
11#define SEMF_HARDWAREABSTRACTION_STM32_STM32ANALOGIN_H_
12
15
16#if defined(STM32) && defined(HAL_ADC_MODULE_ENABLED)
17#include <semf/input/analogin.h>
18namespace semf
19{
25class Stm32AnalogIn : public AnalogIn, public LinkedQueue<Stm32AnalogIn>::Node
26{
27public:
29 enum class ErrorCode : uint8_t
30 {
31 Start_HalError = 0,
32 Start_HalBusy,
33 Start_HalTimeout,
34 Stop_HalError,
35 Stop_HalBusy,
36 Stop_HalTimeout,
37 IsrError_Isr
38 };
39
44 explicit Stm32AnalogIn(ADC_HandleTypeDef& hwHandle);
45 explicit Stm32AnalogIn(const Stm32AnalogIn& other) = delete;
46 virtual ~Stm32AnalogIn() = default;
47
55 virtual void start();
56 virtual uint32_t value();
63 void stop() override;
73 static void systemIsr(ADC_HandleTypeDef& adc);
78 static void systemIsrError(ADC_HandleTypeDef& adc);
83 void isr(ADC_HandleTypeDef& adc);
89 void isrError(ADC_HandleTypeDef& adc);
90
91private:
93 ADC_HandleTypeDef* m_hwHandle;
95 static constexpr Error::ClassID kSemfClassId = Error::ClassID::Stm32AnalogIn;
96};
97} /* namespace semf */
98#endif
99#endif /* SEMF_HARDWAREABSTRACTION_STM32_STM32ANALOGIN_H_ */
Interface for using ADC (Analog to Digital Conversion) hardware in interrupt mode.
Definition: analogin.h:27
ClassID
Semf class IDs.
Definition: error.h:28
LinkedQueue is an managed single linked queue implementation.
Definition: linkedqueue.h:38
Stm32 driver for using a anologIn channel.
Definition: stm32analogin.h:26
static void systemIsrError(ADC_HandleTypeDef &adc)
System-wide interrupt service routine for adc error.
void stop() override
static LinkedQueue< Stm32AnalogIn > * queue()
Get the list with all analog ins.
virtual ~Stm32AnalogIn()=default
Stm32AnalogIn(ADC_HandleTypeDef &hwHandle)
Constructor.
void isrError(ADC_HandleTypeDef &adc)
Sending a error signal.
void isr(ADC_HandleTypeDef &adc)
Interrupt service routine for adc conversion finished.
Stm32AnalogIn(const Stm32AnalogIn &other)=delete
virtual void start()
Starts the hardware module (ADC) for reading ADC values. After finishing analog to digital conversion...
virtual uint32_t value()
Returns the last read value.
static void systemIsr(ADC_HandleTypeDef &adc)
System-wide interrupt service routine for adc conversion finished.