theCore C++ embedded framework
Collaboration diagram for ADC driver:

Data Structures

struct  ecl::channel_group< trig, chans >
 Channels grouped together along with an external trigger. More...
 
struct  ecl::channel_group_sw_trigger< chans >
 Channels grouped together, conversion triggered by software. More...
 
struct  ecl::channel_group_exti_trigger< edge, chans >
 Channels grouped together, conversion triggered by EXTI line. More...
 
struct  ecl::adc_cfg< dev >
 ADC configuration prototype. More...
 
struct  ecl::extractor< chs >
 Extracts information of the given channel group. More...
 
class  ecl::adc_irq_dispatcher
 ADC interrupts helper. More...
 
class  ecl::adc< dev >
 ADC peripheral class. More...
 
class  ecl::mgmt_configurator< dev, mode >
 Management configurator class. More...
 
class  ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >
 Configurator for ADC IRQ mode. More...
 
class  ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >
 Configurator for ADC DMA mode. More...
 

Typedefs

using ecl::adc_evh = std::function< void(adc_event)>
 ADC event handler. Event code signifies result of a conversion. More...
 

Enumerations

enum  ecl::adc_mgmt_mode { ecl::adc_mgmt_mode::dma, ecl::adc_mgmt_mode::irq }
 ADC management mode. More...
 
enum  ecl::adc_trigger {
  ecl::adc_trigger::t1_cc1 = ADC_ExternalTrigConv_T1_CC1, ecl::adc_trigger::t1_cc2 = ADC_ExternalTrigConv_T1_CC2, ecl::adc_trigger::t1_cc3 = ADC_ExternalTrigConv_T1_CC3, ecl::adc_trigger::t2_cc2 = ADC_ExternalTrigConv_T2_CC2,
  ecl::adc_trigger::t2_cc3 = ADC_ExternalTrigConv_T2_CC3, ecl::adc_trigger::t2_cc4 = ADC_ExternalTrigConv_T2_CC4, ecl::adc_trigger::t2_trgo = ADC_ExternalTrigConv_T2_TRGO, ecl::adc_trigger::t3_cc1 = ADC_ExternalTrigConv_T3_CC1,
  ecl::adc_trigger::t3_trgo = ADC_ExternalTrigConv_T3_TRGO, ecl::adc_trigger::t4_cc4 = ADC_ExternalTrigConv_T4_CC4, ecl::adc_trigger::t5_cc1 = ADC_ExternalTrigConv_T5_CC1, ecl::adc_trigger::t5_cc2 = ADC_ExternalTrigConv_T5_CC2,
  ecl::adc_trigger::t5_cc3 = ADC_ExternalTrigConv_T5_CC3, ecl::adc_trigger::t8_cc1 = ADC_ExternalTrigConv_T8_CC1, ecl::adc_trigger::t8_trgo = ADC_ExternalTrigConv_T8_TRGO
}
 The external event used to trigger the start of conversion of a group. More...
 
enum  ecl::adc_trigger_edge { ecl::adc_trigger_edge::rising = ADC_ExternalTrigConvEdge_Rising, ecl::adc_trigger_edge::falling = ADC_ExternalTrigConvEdge_Falling, ecl::adc_trigger_edge::both = ADC_ExternalTrigConvEdge_RisingFalling }
 The external trigger edge in case of EXTI line used as a trigger. More...
 
enum  ecl::adc_channel {
  ecl::adc_channel::ch0 = ADC_Channel_0, ecl::adc_channel::ch1 = ADC_Channel_1, ecl::adc_channel::ch2 = ADC_Channel_2, ecl::adc_channel::ch3 = ADC_Channel_3,
  ecl::adc_channel::ch4 = ADC_Channel_4, ecl::adc_channel::ch5 = ADC_Channel_5, ecl::adc_channel::ch6 = ADC_Channel_6, ecl::adc_channel::ch7 = ADC_Channel_7,
  ecl::adc_channel::ch8 = ADC_Channel_8, ecl::adc_channel::ch9 = ADC_Channel_9, ecl::adc_channel::ch10 = ADC_Channel_10, ecl::adc_channel::ch11 = ADC_Channel_11,
  ecl::adc_channel::ch12 = ADC_Channel_12, ecl::adc_channel::ch13 = ADC_Channel_13, ecl::adc_channel::ch14 = ADC_Channel_14, ecl::adc_channel::ch15 = ADC_Channel_15,
  ecl::adc_channel::ch16 = ADC_Channel_16, ecl::adc_channel::ch17 = ADC_Channel_17, ecl::adc_channel::ch18 = ADC_Channel_18
}
 ADC possible channels. More...
 

Functions

static adc_irq_dispatcherecl::adc_irq_dispatcher::get_instance ()
 Gets dispatcher instance. More...
 
template<adc_dev dev>
void ecl::adc_irq_dispatcher::subscribe (const adc_evh &h)
 Subscribes for ADC events and registers given handler handler. More...
 
template<adc_dev dev>
void ecl::adc_irq_dispatcher::unsubscribe ()
 Unsubscribes from ADC events and deregisters event handler. More...
 
static void ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >::init ()
 Initializes ADC to work in the IRQ mode. More...
 
template<typename Group >
static void ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >::enable_channels (typename adc< dev >::template sample_array< Group > &out_samples)
 Enables IRQ mode for given channels. More...
 
static void ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >::single (const adc_evh &evh)
 Performs IRQ configuration for single-mode async conversion. More...
 
static void ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >::init ()
 Initializes ADC to work in the DMA mode. More...
 
template<typename Group >
static void ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >::enable_channels (typename adc< dev >::template sample_array< Group > &out_samples)
 Enables DMA mode for given channels. More...
 
static void ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >::single (const adc_evh &evh)
 Performs DMA configuration for single-mode async conversion. More...
 
static void ecl::adc< dev >::init ()
 Initializes given ADC. More...
 
template<typename Group >
static void ecl::adc< dev >::enable_channels (sample_array< Group > &out_samples)
 Configures ADC to work with given channels, in IRQ mode. More...
 
static err ecl::adc< dev >::single ()
 Performs single conversion of the previously configured channels and waits till the end of the conversion. More...
 
static err ecl::adc< dev >::single (const adc_evh &evh)
 Performs single conversion of the previously configured channels asynchronously. More...
 

Detailed Description

Typedef Documentation

◆ adc_evh

using ecl::adc_evh = typedef std::function<void(adc_event)>

ADC event handler. Event code signifies result of a conversion.

Enumeration Type Documentation

◆ adc_mgmt_mode

enum ecl::adc_mgmt_mode
strong

ADC management mode.

Samples readings can occur either by software after end-of-conversion IRQ is generated or with help of DMA.

Enumerator
dma 
irq 

ADC managed using DMA.

ADC managed using IRQ.

◆ adc_trigger

enum ecl::adc_trigger
strong

The external event used to trigger the start of conversion of a group.

Enumerator
t1_cc1 
t1_cc2 
t1_cc3 
t2_cc2 
t2_cc3 
t2_cc4 
t2_trgo 
t3_cc1 
t3_trgo 
t4_cc4 
t5_cc1 
t5_cc2 
t5_cc3 
t8_cc1 
t8_trgo 

◆ adc_trigger_edge

enum ecl::adc_trigger_edge
strong

The external trigger edge in case of EXTI line used as a trigger.

For F4 family EXTI 11 line can be configured as EXTI trigger for regular channel group or EXTI 15 for injected group.

Enumerator
rising 
falling 
both 

◆ adc_channel

enum ecl::adc_channel
strong

ADC possible channels.

Be careful, since not all channels are connected to every ADC.

Enumerator
ch0 
ch1 
ch2 
ch3 
ch4 
ch5 
ch6 
ch7 
ch8 
ch9 
ch10 
ch11 
ch12 
ch13 
ch14 
ch15 
ch16 
ch17 
ch18 

Function Documentation

◆ get_instance()

adc_irq_dispatcher & ecl::adc_irq_dispatcher::get_instance ( )
inlinestatic

Gets dispatcher instance.

◆ subscribe()

template<adc_dev dev>
void ecl::adc_irq_dispatcher::subscribe ( const adc_evh h)
inline

Subscribes for ADC events and registers given handler handler.

Template Parameters
adcADC device for which event handler should be registered.
Parameters
[in]hADC event handler.
Here is the call graph for this function:

◆ unsubscribe()

template<adc_dev dev>
void ecl::adc_irq_dispatcher::unsubscribe ( )
inline

Unsubscribes from ADC events and deregisters event handler.

Template Parameters
adcADC device for which events should be disabled.
Here is the call graph for this function:

◆ init() [1/3]

template<adc_dev dev>
void ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >::init ( )
static

Initializes ADC to work in the IRQ mode.

Here is the call graph for this function:

◆ enable_channels() [1/3]

template<adc_dev dev>
template<typename Group >
void ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >::enable_channels ( typename adc< dev >::template sample_array< Group > &  out_samples)
static

Enables IRQ mode for given channels.

◆ single() [1/4]

template<adc_dev dev>
void ecl::mgmt_configurator< dev, adc_mgmt_mode::irq >::single ( const adc_evh evh)
static

Performs IRQ configuration for single-mode async conversion.

◆ init() [2/3]

template<adc_dev dev>
void ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >::init ( )
static

Initializes ADC to work in the DMA mode.

Here is the call graph for this function:

◆ enable_channels() [2/3]

template<adc_dev dev>
template<typename Group >
void ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >::enable_channels ( typename adc< dev >::template sample_array< Group > &  out_samples)
static

Enables DMA mode for given channels.

◆ single() [2/4]

template<adc_dev dev>
void ecl::mgmt_configurator< dev, adc_mgmt_mode::dma >::single ( const adc_evh evh)
static

Performs DMA configuration for single-mode async conversion.

Here is the call graph for this function:

◆ init() [3/3]

template<adc_dev dev>
void ecl::adc< dev >::init ( )
static

Initializes given ADC.

◆ enable_channels() [3/3]

template<adc_dev dev>
template<typename Group >
void ecl::adc< dev >::enable_channels ( sample_array< Group > &  out_samples)
static

Configures ADC to work with given channels, in IRQ mode.

Parameters
[in,out]out_samplesSamples array that will be populated with target samples. Should not be destroyed until conversion of given channels will complete.
Note
ADC configured in IRQ mode cannot handle conversion of more than 1 channel. Use DMA mode. See ecl::adc_cfg to get hints about how to configure ADC in DMA mode.
Here is the call graph for this function:

◆ single() [3/4]

template<adc_dev dev>
err ecl::adc< dev >::single ( )
static

Performs single conversion of the previously configured channels and waits till the end of the conversion.

Results will be saved to a buffer previously passed with enable_channels(). If external trigger is selected then conversion will start after trigger will hit. Otherwise, conversion will be immediately triggered by software.

Precondition
Channels configured with use_channels() call.
Returns
Result of operation.
Return values
ecl::err::okChannels are converted and data is stored in the buffer.
Todo:
Implement support for external triggers.

◆ single() [4/4]

template<adc_dev dev>
err ecl::adc< dev >::single ( const adc_evh evh)
static

Performs single conversion of the previously configured channels asynchronously.

After end of conversion event handler will be called. In case of successfull conversion results will be saved to a buffer previously passed with enable_channels(). If external trigger is selected then conversion will start after trigger will hit. Otherwise, conversion will be immediately triggered by software.

Precondition
Channels configured with use_channels() call.
Returns
Result of operation.
Return values
ecl::err::okChannels conversion is pending.
Todo:
Implement support for external triggers.