semf
semf::Stm32AnalogOutDma Class Reference

#include <stm32analogoutdma.h>

Inheritance diagram for semf::Stm32AnalogOutDma:
Inheritance graph
Collaboration diagram for semf::Stm32AnalogOutDma:
Collaboration graph

Public Types

enum class  ErrorCode : uint8_t {
  Start_DataInvalid = 0 , Start_HalError , Start_HalBusy , Start_HalTimeout ,
  Stop_DataInvalid , Stop_HalError , Stop_HalBusy , Stop_HalTimeout ,
  IsrError_Isr
}
 
enum class  Alignment : uint32_t { Align_8bitRight = 0 , Align_12bitLeft , Align_12bitRight }
 

Public Member Functions

 Stm32AnalogOutDma (DAC_HandleTypeDef &hwHandle, uint32_t channel, Alignment alignment)
 Constructor. More...
 
 Stm32AnalogOutDma (const Stm32AnalogOutDma &other)=delete
 
virtual ~Stm32AnalogOutDma ()=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 setData (const uint8_t data[], size_t dataSize) override
 Sets the pointer to the data memory location and its size for starting DAC later by start() function. to output them on the AnalogOutDma pin. More...
 
void isrError (DAC_HandleTypeDef &dac)
 Sending a error signal. More...
 
void isr (DAC_HandleTypeDef &dac)
 Sending a error signal. More...
 
- Public Member Functions inherited from semf::AnalogOutDma
virtual ~AnalogOutDma ()=default
 
virtual void start () const =0
 Starts the hardware module (DAC) for writing DAC values to the output. More...
 
virtual void stop () const =0
 
virtual void setData (const uint8_t data[], size_t dataSize)=0
 Sets the pointer to the data memory location and its size for starting DAC later by start() function. to output them on the AnalogOutDma pin. 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< Stm32AnalogOutDma > * queue ()
 Get the list with all analog outs. More...
 
static void systemIsrError (DAC_HandleTypeDef &dac)
 System-wide interrupt service routine for dac error. More...
 
static void systemIsr (DAC_HandleTypeDef &dac)
 System-wide interrupt service routine for dac conversion finished. More...
 

Additional Inherited Members

- Public Attributes inherited from semf::AnalogOutDma
Signal dataWritten
 
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 stm32analogoutdma.h.

Member Enumeration Documentation

◆ Alignment

enum class semf::Stm32AnalogOutDma::Alignment : uint32_t
strong

Alignment settings support by the MCU.

Enumerator
Align_8bitRight 
Align_12bitLeft 
Align_12bitRight 

Definition at line 40 of file stm32analogoutdma.h.

◆ ErrorCode

enum class semf::Stm32AnalogOutDma::ErrorCode : uint8_t
strong

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

Enumerator
Start_DataInvalid 
Start_HalError 
Start_HalBusy 
Start_HalTimeout 
Stop_DataInvalid 
Stop_HalError 
Stop_HalBusy 
Stop_HalTimeout 
IsrError_Isr 

Definition at line 27 of file stm32analogoutdma.h.

Constructor & Destructor Documentation

◆ Stm32AnalogOutDma() [1/2]

semf::Stm32AnalogOutDma::Stm32AnalogOutDma ( 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 stm32analogoutdma.cpp.

Here is the call graph for this function:

◆ Stm32AnalogOutDma() [2/2]

semf::Stm32AnalogOutDma::Stm32AnalogOutDma ( const Stm32AnalogOutDma other)
explicitdelete

◆ ~Stm32AnalogOutDma()

virtual semf::Stm32AnalogOutDma::~Stm32AnalogOutDma ( )
virtualdefault

Member Function Documentation

◆ isr()

void semf::Stm32AnalogOutDma::isr ( 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 114 of file stm32analogoutdma.cpp.

◆ isrError()

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

Sending a error signal.

Parameters
dacPointer to dac hardware handler.

Definition at line 105 of file stm32analogoutdma.cpp.

◆ queue()

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

Get the list with all analog outs.

Returns
The list with all analog outs.

Definition at line 87 of file stm32analogoutdma.cpp.

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

◆ setData()

void semf::Stm32AnalogOutDma::setData ( const uint8_t  data[],
size_t  dataSize 
)
overridevirtual

Sets the pointer to the data memory location and its size for starting DAC later by start() function. to output them on the AnalogOutDma pin.

Note
For using halfword DAC setting, use a uint16_t array, cast it to uint8_t* and double the size of the array. For using word DAC setting, use a uint32_t array, cast it to uint8_t* and multiple the size of the array by four.
Parameters
dataPointer to the digital to analog value array.
dataSizeByte size of the value array

Implements semf::AnalogOutDma.

Definition at line 80 of file stm32analogoutdma.cpp.

◆ start()

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

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

Exceptions
Start_DataInvalidIf the data is invalid (nullptr or size = 0).
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::AnalogOutDma.

Definition at line 23 of file stm32analogoutdma.cpp.

◆ stop()

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

Stops the DAC hardware.

Exceptions
Stop_DataInvalidIf the data is invalid (nullptr or size = 0).
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::AnalogOutDma.

Definition at line 55 of file stm32analogoutdma.cpp.

◆ systemIsr()

void semf::Stm32AnalogOutDma::systemIsr ( DAC_HandleTypeDef &  dac)
static

System-wide interrupt service routine for dac conversion finished.

Parameters
dacHardware handler.

Definition at line 99 of file stm32analogoutdma.cpp.

Here is the call graph for this function:

◆ systemIsrError()

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

System-wide interrupt service routine for dac error.

Parameters
dacHardware handler.

Definition at line 93 of file stm32analogoutdma.cpp.

Here is the call graph for this function: