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   12
 ADC resolution in bits (defaults to 12 if not set)
 
#define DefRangeADC   (LSHIFT(1U, ADC_RESOLUTION) - 1)
 ADC digital range.
 
#define Def_ADCStep(mv)   ((mv) / (float) (DefRangeADC * 1000))
 Step value (in mV) following given v.
 

Typedefs

typedef enum eADCidx eADCidx
 
typedef struct ADC_Cfg ADC_Cfg
 

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 conversions.
 
FctERR ADC_Stop (void)
 Stop ADC conversions.
 

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:
    • Scan conversion mode across channels enabled
    • Continuous conversion is optional (if disabled, user has to start conversions manually when needed)
    • DMA continuous request when available
    • Interrupt generated at end of conversion
      Note
      Define USE_ADC_EX symbol at project level to use ADC_ex functionalities
      Configuration done calling ADC_cfg.h file

Macro Definition Documentation

◆ ADC_RESOLUTION

#define ADC_RESOLUTION   12

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

◆ Def_ADCStep

#define Def_ADCStep ( mv)    ((mv) / (float) (DefRangeADC * 1000))

Step value (in mV) following given v.

◆ 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) - 1)

ADC digital range.

Typedef Documentation

◆ ADC_Cfg

typedef struct ADC_Cfg ADC_Cfg

◆ eADCidx

typedef enum eADCidx eADCidx

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
Here is the call graph for this function:

◆ ADC_GetRawVal()

uint16_t ADC_GetRawVal ( const eAnalogInput input)

Get ADC channel raw value.

Parameters
[in]input- Input index
Returns
Channel raw value
Here is the caller graph for this function:

◆ ADC_Start()

FctERR ADC_Start ( void )

Start ADC conversions.

Returns
FctERR - Error code

◆ ADC_Stop()

FctERR ADC_Stop ( void )

Stop ADC conversions.

Returns
FctERR - Error code