HARMcksL: ARM HAL toolbox (yet STM32 oriented) 1.6
SMFSW collection of HAL hacks for STM32
Loading...
Searching...
No Matches
ADC_ex.h File Reference

Simple extension for ADCs. More...

#include "sarmfsw.h"
#include "ADC_cfg.h"
Include dependency graph for ADC_ex.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  ADC_Cfg
 ADC channel declaration config structure. More...

Macros

#define Def_VAlim   VDD_VALUE
 < Alias for legacy code using TEMP_CALC_V25 or TEMP_CALC_V30
#define ADC_RESOLUTION   12U
 ADC resolution in bits (defaults to 12 if not set).
#define DefRangeADC   (LSHIFT(1U, ADC_RESOLUTION) - 1U)
 ADC digital range.
#define Def_ADCStep(mv)
 Step value (in mV) following given mv.

Enumerations

enum  eADCidx { ADC_MAX }
 ADC peripheral instance indexes. More...

Functions

uint16_t ADC_GetRawVal (const eAnalogInput input)
 Get ADC channel raw value.
float ADC_GetConvertedVal (const eAnalogInput input)
 Get ADC channel converted value.
FctERR ADC_Start (void)
 Start ADC acquisitions.
FctERR ADC_Stop (void)
 Stop ADC acquisitions.
void ADC_handler (void)
 ADC_ex handler.
void ADC_SetPeriod (const uint32_t period)
 Set ADC Sampling or Conversion period.

Detailed Description

Simple extension for ADCs.

Author
SMFSW

ADC_ex is meant to automate ADC conversions using DMA.

  • DMA must be configured for ADC peripherals:
    • Peripheral to Memory
    • Circular Mode
    • Increment Memory
    • Data width Word for both peripheral and memory
  • ADC configuration (no need to active ADC global interrupt, DMA will handle conversion complete callback):
    • Scan conversion mode across channels enabled
    • Continuous conversion is optional (as DMA continuous request handles the behavior)
    • DMA continuous request when available (if disabled, user has to start conversions manually when needed)
    • Interrupt generated at end of sequence of conversion
      Note
      Define USE_ADC_EX symbol at project level to use ADC_ex functionalities
      Configuration done including ADC_cfg.h file

Macro Definition Documentation

◆ ADC_RESOLUTION

#define ADC_RESOLUTION   12U

ADC resolution in bits (defaults to 12 if not set).

◆ Def_ADCStep

#define Def_ADCStep ( mv)
Value:
((mv) / (float) (DefRangeADC * 1000U))
#define DefRangeADC
ADC digital range.
Definition ADC_ex.h:61

Step value (in mV) following given mv.

◆ Def_VAlim

#define Def_VAlim   VDD_VALUE

< Alias for legacy code using TEMP_CALC_V25 or TEMP_CALC_V30

Def_VAlim needs to be defined (in mV) if special power supply voltage used (eg. U5 variable power supply range)

◆ DefRangeADC

#define DefRangeADC   (LSHIFT(1U, ADC_RESOLUTION) - 1U)

ADC digital range.

Enumeration Type Documentation

◆ eADCidx

enum eADCidx

ADC peripheral instance indexes.

Enumerator
ADC_MAX 

Adc MAX index.

Function Documentation

◆ ADC_GetConvertedVal()

float ADC_GetConvertedVal ( const eAnalogInput input)

Get ADC channel converted value.

Parameters
[in]input- Input index
Returns
Channel converted value

◆ ADC_GetRawVal()

uint16_t ADC_GetRawVal ( const eAnalogInput input)

Get ADC channel raw value.

Parameters
[in]input- Input index
Returns
Channel raw value

◆ ADC_handler()

void ADC_handler ( void )

ADC_ex handler.

Note
If ADC_CONTINUOUS_SAMPLING is defined and ADC_AUTO_RAW_VAL_CONV is not defined, ADC_handler is useless
Here is the call graph for this function:

◆ ADC_SetPeriod()

void ADC_SetPeriod ( const uint32_t period)

Set ADC Sampling or Conversion period.

Parameters
[in]period- Sampling or Conversion period (in ms)

◆ ADC_Start()

FctERR ADC_Start ( void )

Start ADC acquisitions.

Returns
FctERR - Error code
Here is the caller graph for this function:

◆ ADC_Stop()

FctERR ADC_Stop ( void )

Stop ADC acquisitions.

Returns
FctERR - Error code
Here is the caller graph for this function: