semf
semf::Stm32AnalogIn Class Reference

Stm32 driver for using a anologIn channel. More...

#include <stm32analogin.h>

Inheritance diagram for semf::Stm32AnalogIn:
Inheritance graph
Collaboration diagram for semf::Stm32AnalogIn:
Collaboration graph

Public Types

enum class  ErrorCode : uint8_t {
  Start_HalError = 0 , Start_HalBusy , Start_HalTimeout , Stop_HalError ,
  Stop_HalBusy , Stop_HalTimeout , IsrError_Isr
}
 

Public Member Functions

 Stm32AnalogIn (ADC_HandleTypeDef &hwHandle)
 Constructor. More...
 
 Stm32AnalogIn (const Stm32AnalogIn &other)=delete
 
virtual ~Stm32AnalogIn ()=default
 
virtual void start ()
 Starts the hardware module (ADC) for reading ADC values. After finishing analog to digital conversion, the dataAvailable signal will be emitted. More...
 
virtual uint32_t value ()
 Returns the last read value. More...
 
void stop () override
 
void isr (ADC_HandleTypeDef &adc)
 Interrupt service routine for adc conversion finished. More...
 
void isrError (ADC_HandleTypeDef &adc)
 Sending a error signal. More...
 
- Public Member Functions inherited from semf::AnalogIn
virtual ~AnalogIn ()=default
 
virtual void start ()=0
 Starts the hardware module (ADC) for reading ADC values. After finishing analog to digital conversion, the dataAvailable signal will be emitted. More...
 
virtual uint32_t value ()=0
 Returns the last read value. More...
 
virtual void stop ()=0
 
- Public Member Functions inherited from semf::LinkedQueue< T >::Node
virtual ~Node ()=default
 
T * next () const
 Returns a pointer to the next element in a queue. More...
 
void setNext (T *next)
 Sets a pointer to the next element in a list. More...
 
bool isInQueue (LinkedQueue &queue)
 Returns if a node is part of this LinkedQueue. More...
 

Static Public Member Functions

static LinkedQueue< Stm32AnalogIn > * queue ()
 Get the list with all analog ins. More...
 
static void systemIsr (ADC_HandleTypeDef &adc)
 System-wide interrupt service routine for adc conversion finished. More...
 
static void systemIsrError (ADC_HandleTypeDef &adc)
 System-wide interrupt service routine for adc error. More...
 

Additional Inherited Members

- Public Attributes inherited from semf::AnalogIn
Signal dataAvailable
 
Signal< Errorerror
 

Detailed Description

Stm32 driver for using a anologIn channel.

Attention
You cannot call the start() function inside the dataAvailable slot. In case continuous conversions are desired, you have to configure the ADC accordingly.

Definition at line 25 of file stm32analogin.h.

Member Enumeration Documentation

◆ ErrorCode

enum class semf::Stm32AnalogIn::ErrorCode : uint8_t
strong

Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).

Enumerator
Start_HalError 
Start_HalBusy 
Start_HalTimeout 
Stop_HalError 
Stop_HalBusy 
Stop_HalTimeout 
IsrError_Isr 

Definition at line 29 of file stm32analogin.h.

Constructor & Destructor Documentation

◆ Stm32AnalogIn() [1/2]

semf::Stm32AnalogIn::Stm32AnalogIn ( ADC_HandleTypeDef &  hwHandle)
explicit

Constructor.

Parameters
hwHandleadc hardware interface

Definition at line 16 of file stm32analogin.cpp.

Here is the call graph for this function:

◆ Stm32AnalogIn() [2/2]

semf::Stm32AnalogIn::Stm32AnalogIn ( const Stm32AnalogIn other)
explicitdelete

◆ ~Stm32AnalogIn()

virtual semf::Stm32AnalogIn::~Stm32AnalogIn ( )
virtualdefault

Member Function Documentation

◆ isr()

void semf::Stm32AnalogIn::isr ( ADC_HandleTypeDef &  adc)

Interrupt service routine for adc conversion finished.

Parameters
adcHardware handler.

Definition at line 97 of file stm32analogin.cpp.

◆ isrError()

void semf::Stm32AnalogIn::isrError ( ADC_HandleTypeDef &  adc)

Sending a error signal.

Parameters
adcPointer to adc hardware handler.
Exceptions
IsrError_IsrIf the AnalogIn-IRQ results in an error.

Definition at line 106 of file stm32analogin.cpp.

◆ queue()

LinkedQueue< Stm32AnalogIn > * semf::Stm32AnalogIn::queue ( )
static

Get the list with all analog ins.

Returns
The list with all analog ins.

Definition at line 79 of file stm32analogin.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void semf::Stm32AnalogIn::start ( )
virtual

Starts the hardware module (ADC) for reading ADC values. After finishing analog to digital conversion, the dataAvailable signal will be emitted.

Exceptions
Start_HalErrorIf the ST-HAL stumbles upon an error.
Start_HalBusyIf the ST-HAL is busy.
Start_HalTimeoutIf the ST-HAL times out.
Attention
Do not call this function inside your dataAvailable slot.

Implements semf::AnalogIn.

Definition at line 22 of file stm32analogin.cpp.

◆ stop()

void semf::Stm32AnalogIn::stop ( )
overridevirtual

Stops the ADC hardware.

Exceptions
Stop_HalErrorIf the ST-HAL stumbles upon an error.
Stop_HalBusyIf the ST-HAL is busy.
Stop_HalTimeoutIf the ST-HAL times out.

Implements semf::AnalogIn.

Definition at line 54 of file stm32analogin.cpp.

◆ systemIsr()

void semf::Stm32AnalogIn::systemIsr ( ADC_HandleTypeDef &  adc)
static

System-wide interrupt service routine for adc conversion finished.

Parameters
adcHardware handler.

Definition at line 85 of file stm32analogin.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemIsrError()

void semf::Stm32AnalogIn::systemIsrError ( ADC_HandleTypeDef &  adc)
static

System-wide interrupt service routine for adc error.

Parameters
adcHardware handler.

Definition at line 91 of file stm32analogin.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ value()

uint32_t semf::Stm32AnalogIn::value ( )
virtual

Returns the last read value.

Note
This function should be called after receiving the dataAvailable signal.
Returns
analog value

Implements semf::AnalogIn.

Definition at line 47 of file stm32analogin.cpp.