semf
semf::Stm32AnalogOut Class Reference

#include <stm32analogout.h>

Inheritance diagram for semf::Stm32AnalogOut:
Inheritance graph
Collaboration diagram for semf::Stm32AnalogOut:
Collaboration graph

Public Types

enum class  ErrorCode : uint8_t {
  Start_HalError = 0 , Start_HalBusy , Start_HalTimeout , Stop_HalError ,
  Stop_HalBusy , Stop_HalTimeout , SetValue_HalError , SetValue_HalBusy ,
  SetValue_HalTimeout , IsrError_Isr
}
 
enum class  Alignment : uint32_t { Align8bitRight = 0 , Align12bitLeft , Align12bitRight }
 

Public Member Functions

 Stm32AnalogOut (DAC_HandleTypeDef &hwHandle, uint32_t channel, Alignment alignment)
 Constructor. More...
 
 Stm32AnalogOut (const Stm32AnalogOut &other)=delete
 
virtual ~Stm32AnalogOut ()=default
 
void start () const override
 Starts the hardware module (DAC) for writing DAC values to the output. Call setValue before. More...
 
void stop () const override
 
void setValue (uint32_t value) override
 Writes value into hardware register. Call start to output the value. More...
 
void isrError (DAC_HandleTypeDef &dac)
 Sending a error signal. More...
 
virtual void start () const =0
 Starts the hardware module (DAC) for writing DAC values to the output. Call setValue before. More...
 
virtual void stop () const =0
 
virtual void setValue (uint32_t value)=0
 Writes value into hardware register. Call start to output the value. More...
 
- 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< Stm32AnalogOut > * queue ()
 Get the list with all analog outs. More...
 
static void systemIsrError (DAC_HandleTypeDef &dac)
 System-wide interrupt service routine for dac error. More...
 

Additional Inherited Members

- Public Attributes inherited from semf::AnalogOut
Signal< Errorerror
 

Detailed Description

Attention
For channel setting use DAC_CHANNEL_1 or DAC_CHANNEL_2.
If using a hardware timer as a trigger, start it manually before starting the DMA output.

Definition at line 23 of file stm32analogout.h.

Member Enumeration Documentation

◆ Alignment

enum class semf::Stm32AnalogOut::Alignment : uint32_t
strong

Alignment settings support by the MCU.

Enumerator
Align8bitRight 
Align12bitLeft 
Align12bitRight 

Definition at line 41 of file stm32analogout.h.

◆ ErrorCode

enum class semf::Stm32AnalogOut::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 
SetValue_HalError 
SetValue_HalBusy 
SetValue_HalTimeout 
IsrError_Isr 

Definition at line 27 of file stm32analogout.h.

Constructor & Destructor Documentation

◆ Stm32AnalogOut() [1/2]

semf::Stm32AnalogOut::Stm32AnalogOut ( DAC_HandleTypeDef &  hwHandle,
uint32_t  channel,
Alignment  alignment 
)

Constructor.

Parameters
hwHandleReference to hardware handle.
channelDma channel, please see STM documentation. Value is forwarded to the HAL drivers.
alignmentAlignment setting for channel.

Definition at line 15 of file stm32analogout.cpp.

Here is the call graph for this function:

◆ Stm32AnalogOut() [2/2]

semf::Stm32AnalogOut::Stm32AnalogOut ( const Stm32AnalogOut other)
explicitdelete

◆ ~Stm32AnalogOut()

virtual semf::Stm32AnalogOut::~Stm32AnalogOut ( )
virtualdefault

Member Function Documentation

◆ isrError()

void semf::Stm32AnalogOut::isrError ( DAC_HandleTypeDef &  dac)

Sending a error signal.

Parameters
dacPointer to dac hardware handler.
Exceptions
IsrError_IsrIf the AnalogIn-IRQ results in an error.

Definition at line 110 of file stm32analogout.cpp.

◆ queue()

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

Get the list with all analog outs.

Returns
The list with all analog outs.

Definition at line 98 of file stm32analogout.cpp.

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

◆ setValue()

void semf::Stm32AnalogOut::setValue ( uint32_t  value)
overridevirtual

Writes value into hardware register. Call start to output the value.

Parameters
valueDigital to analog value.

Implements semf::AnalogOut.

Definition at line 73 of file stm32analogout.cpp.

◆ start()

void semf::Stm32AnalogOut::start ( ) const
overridevirtual

Starts the hardware module (DAC) for writing DAC values to the output. Call setValue before.

Exceptions
Start_HalErrorIf the ST-HAL stumbles upon an error.
Start_HalBusyIf the ST-HAL is busy.
Start_HalTimeoutIf the ST-HAL times out.

Implements semf::AnalogOut.

Definition at line 23 of file stm32analogout.cpp.

◆ stop()

void semf::Stm32AnalogOut::stop ( ) const
overridevirtual

Stops the DAC 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::AnalogOut.

Definition at line 48 of file stm32analogout.cpp.

◆ systemIsrError()

void semf::Stm32AnalogOut::systemIsrError ( DAC_HandleTypeDef &  dac)
static

System-wide interrupt service routine for dac error.

Parameters
dacHardware handler.

Definition at line 104 of file stm32analogout.cpp.

Here is the call graph for this function: