IADC - Incremental ADC

Description

Incremental Analog to Digital Converter (IADC) Peripheral API.

This module contains functions to control the IADC peripheral of Silicon Labs 32-bit MCUs and SoCs. The IADC is used to convert analog signals into a digital representation.

Data Structures

struct IADC_Init_t
IADC init structure, common for single conversion and scan sequence.
struct IADC_Config_t
IADC config structure.
struct IADC_AllConfigs_t
Structure for all IADC configs.
struct IADC_InitScan_t
IADC scan init structure.
struct IADC_InitSingle_t
IADC single init structure.
struct IADC_SingleInput_t
IADC single input selection structure.
struct IADC_ScanTableEntry_t
IADC scan table entry structure.
struct IADC_ScanTable_t
Structure for IADC scan table.
struct IADC_Result_t
Structure holding IADC result, including data and ID.

Functions

void IADC_init (IADC_TypeDef *iadc, const IADC_Init_t *init, const IADC_AllConfigs_t *allConfigs)
Initialize IADC.
void IADC_initScan (IADC_TypeDef *iadc, const IADC_InitScan_t *init, const IADC_ScanTable_t *scanTable)
Initialize IADC scan sequence.
void IADC_initSingle (IADC_TypeDef *iadc, const IADC_InitSingle_t *init, const IADC_SingleInput_t *input)
Initialize single IADC conversion.
void IADC_updateSingleInput (IADC_TypeDef *iadc, const IADC_SingleInput_t *input)
Update IADC single input selection.
void IADC_setScanMask (IADC_TypeDef *iadc, uint32_t mask)
Set mask of IADC scan table entries to include in scan.
void IADC_updateScanEntry (IADC_TypeDef *iadc, uint8_t id, IADC_ScanTableEntry_t *entry)
Add/update entry in scan table.
void IADC_reset (IADC_TypeDef *iadc)
Reset IADC to same state as after a HW reset.
uint8_t IADC_calcTimebase (IADC_TypeDef *iadc, uint32_t cmuClkFreq)
Calculate timebase value in order to get a timebase providing at least 1us.
uint8_t IADC_calcSrcClkPrescale (IADC_TypeDef *iadc, uint32_t srcClkFreq, uint32_t cmuClkFreq)
Calculate prescaler for CLK_SRC_ADC high speed clock.
uint32_t IADC_calcAdcClkPrescale (IADC_TypeDef *iadc, uint32_t adcClkFreq, uint32_t cmuClkFreq, IADC_CfgAdcMode_t adcMode, uint8_t srcClkPrescaler)
Calculate prescaler for ADC_CLK clock.
IADC_Result_t IADC_pullSingleFifoResult (IADC_TypeDef *iadc)
Pull result from single data FIFO.
IADC_Result_t IADC_readSingleResult (IADC_TypeDef *iadc)
Read most recent single conversion result.
IADC_Result_t IADC_pullScanFifoResult (IADC_TypeDef *iadc)
Pull result from scan data FIFO.
IADC_Result_t IADC_readScanResult (IADC_TypeDef *iadc)
Read most recent scan conversion result.
uint32_t IADC_pullSingleFifoData (IADC_TypeDef *iadc)
Pull data from single data FIFO.
uint32_t IADC_readSingleData (IADC_TypeDef *iadc)
Read most recent single conversion data.
uint32_t IADC_pullScanFifoData (IADC_TypeDef *iadc)
Pull data from scan data FIFO.
uint32_t IADC_readScanData (IADC_TypeDef *iadc)
Read most recent scan conversion data.
void IADC_clearInt (IADC_TypeDef *iadc, uint32_t flags)
Clear one or more pending IADC interrupts.
void IADC_disableInt (IADC_TypeDef *iadc, uint32_t flags)
Disable one or more IADC interrupts.
void IADC_enableInt (IADC_TypeDef *iadc, uint32_t flags)
Enable one or more IADC interrupts.
uint32_t IADC_getInt (IADC_TypeDef *iadc)
Get pending IADC interrupt flags.
uint32_t IADC_getEnabledInt (IADC_TypeDef *iadc)
Get enabled and pending IADC interrupt flags.
void IADC_setInt (IADC_TypeDef *iadc, uint32_t flags)
Set one or more pending IADC interrupts from SW.
void IADC_command (IADC_TypeDef *iadc, IADC_Cmd_t cmd)
Start/stop scan sequence, single conversion and/or timer.
uint32_t IADC_getScanMask (IADC_TypeDef *iadc)
Get the scan mask currently used in the IADC.
uint32_t IADC_getStatus (IADC_TypeDef *iadc)
Get status bits of IADC.
uint8_t IADC_getSingleFifoCnt (IADC_TypeDef *iadc)
Get number of elements in the IADC single FIFO.
uint8_t IADC_getScanFifoCnt (IADC_TypeDef *iadc)
Get number of elements in the IADC scan FIFO.
IADC_NegInput_t IADC_portPinToNegInput ( GPIO_Port_TypeDef port, uint8_t pin)
Convert GPIO port/pin to IADC negative input selection.
IADC_PosInput_t IADC_portPinToPosInput ( GPIO_Port_TypeDef port, uint8_t pin)
Convert GPIO port/pin to IADC positive input selection.

Macros

#define IADC_INIT_DEFAULT
Default config for IADC init structure.
#define IADC_CONFIG_DEFAULT
Default IADC config structure.
#define IADC_ALLCONFIGS_DEFAULT
Default IADC sructure for all configs.
#define IADC_INITSCAN_DEFAULT
Default config for IADC scan init structure.
#define IADC_INITSINGLE_DEFAULT
Default config for IADC single init structure.
#define IADC_SINGLEINPUT_DEFAULT
Default config for IADC single input structure.
#define IADC_SCANTABLEENTRY_DEFAULT
Default config for IADC scan table entry structure.
#define IADC_SCANTABLE_DEFAULT
Default IADC sructure for scan table.

Enumerations

enum IADC_Warmup_t {
iadcWarmupNormal = _IADC_CTRL_WARMUPMODE_NORMAL,
iadcWarmupKeepInStandby = _IADC_CTRL_WARMUPMODE_KEEPINSTANDBY,
iadcWarmupKeepWarm = _IADC_CTRL_WARMUPMODE_KEEPWARM
}
Warm-up mode.
enum IADC_Alignment_t {
iadcAlignRight12 = _IADC_SCANFIFOCFG_ALIGNMENT_RIGHT12,
iadcAlignLeft12 = _IADC_SCANFIFOCFG_ALIGNMENT_LEFT12
}
IADC result alignment.
enum IADC_NegInput_t {
iadcNegInputGnd ,
iadcNegInputPortAPin0 = (_IADC_SCAN_PORTNEG_PORTA << (_IADC_SCAN_PORTNEG_SHIFT - _IADC_SCAN_PINNEG_SHIFT)),
iadcNegInputPortAPin1 ,
iadcNegInputPortAPin2 ,
iadcNegInputPortAPin3 ,
iadcNegInputPortAPin4 ,
iadcNegInputPortAPin5 ,
iadcNegInputPortAPin6 ,
iadcNegInputPortAPin7 ,
iadcNegInputPortAPin8 ,
iadcNegInputPortAPin9 ,
iadcNegInputPortAPin10 ,
iadcNegInputPortAPin11 ,
iadcNegInputPortAPin12 ,
iadcNegInputPortAPin13 ,
iadcNegInputPortAPin14 ,
iadcNegInputPortAPin15 ,
iadcNegInputPortBPin0 ,
iadcNegInputPortBPin1 ,
iadcNegInputPortBPin2 ,
iadcNegInputPortBPin3 ,
iadcNegInputPortBPin4 ,
iadcNegInputPortBPin5 ,
iadcNegInputPortBPin6 ,
iadcNegInputPortBPin7 ,
iadcNegInputPortBPin8 ,
iadcNegInputPortBPin9 ,
iadcNegInputPortBPin10 ,
iadcNegInputPortBPin11 ,
iadcNegInputPortBPin12 ,
iadcNegInputPortBPin13 ,
iadcNegInputPortBPin14 ,
iadcNegInputPortBPin15 ,
iadcNegInputPortCPin0 ,
iadcNegInputPortCPin1 ,
iadcNegInputPortCPin2 ,
iadcNegInputPortCPin3 ,
iadcNegInputPortCPin4 ,
iadcNegInputPortCPin5 ,
iadcNegInputPortCPin6 ,
iadcNegInputPortCPin7 ,
iadcNegInputPortCPin8 ,
iadcNegInputPortCPin9 ,
iadcNegInputPortCPin10 ,
iadcNegInputPortCPin11 ,
iadcNegInputPortCPin12 ,
iadcNegInputPortCPin13 ,
iadcNegInputPortCPin14 ,
iadcNegInputPortCPin15 ,
iadcNegInputPortDPin0 ,
iadcNegInputPortDPin1 ,
iadcNegInputPortDPin2 ,
iadcNegInputPortDPin3 ,
iadcNegInputPortDPin4 ,
iadcNegInputPortDPin5 ,
iadcNegInputPortDPin6 ,
iadcNegInputPortDPin7 ,
iadcNegInputPortDPin8 ,
iadcNegInputPortDPin9 ,
iadcNegInputPortDPin10 ,
iadcNegInputPortDPin11 ,
iadcNegInputPortDPin12 ,
iadcNegInputPortDPin13 ,
iadcNegInputPortDPin14 ,
iadcNegInputPortDPin15
}
IADC negative input selection.
enum IADC_PosInput_t {
iadcPosInputGnd = (_IADC_SCAN_PORTPOS_GND << (_IADC_SCAN_PORTPOS_SHIFT - _IADC_SCAN_PINPOS_SHIFT)),
iadcPosInputAvdd ,
iadcPosInputVddio ,
iadcPosInputVss ,
iadcPosInputVssaux ,
iadcPosInputDvdd ,
iadcPosInputDecouple ,
iadcPosInputPortAPin0 = (_IADC_SCAN_PORTPOS_PORTA << (_IADC_SCAN_PORTPOS_SHIFT - _IADC_SCAN_PINPOS_SHIFT)),
iadcPosInputPortAPin1 ,
iadcPosInputPortAPin2 ,
iadcPosInputPortAPin3 ,
iadcPosInputPortAPin4 ,
iadcPosInputPortAPin5 ,
iadcPosInputPortAPin6 ,
iadcPosInputPortAPin7 ,
iadcPosInputPortAPin8 ,
iadcPosInputPortAPin9 ,
iadcPosInputPortAPin10 ,
iadcPosInputPortAPin11 ,
iadcPosInputPortAPin12 ,
iadcPosInputPortAPin13 ,
iadcPosInputPortAPin14 ,
iadcPosInputPortAPin15 ,
iadcPosInputPortBPin0 ,
iadcPosInputPortBPin1 ,
iadcPosInputPortBPin2 ,
iadcPosInputPortBPin3 ,
iadcPosInputPortBPin4 ,
iadcPosInputPortBPin5 ,
iadcPosInputPortBPin6 ,
iadcPosInputPortBPin7 ,
iadcPosInputPortBPin8 ,
iadcPosInputPortBPin9 ,
iadcPosInputPortBPin10 ,
iadcPosInputPortBPin11 ,
iadcPosInputPortBPin12 ,
iadcPosInputPortBPin13 ,
iadcPosInputPortBPin14 ,
iadcPosInputPortBPin15 ,
iadcPosInputPortCPin0 ,
iadcPosInputPortCPin1 ,
iadcPosInputPortCPin2 ,
iadcPosInputPortCPin3 ,
iadcPosInputPortCPin4 ,
iadcPosInputPortCPin5 ,
iadcPosInputPortCPin6 ,
iadcPosInputPortCPin7 ,
iadcPosInputPortCPin8 ,
iadcPosInputPortCPin9 ,
iadcPosInputPortCPin10 ,
iadcPosInputPortCPin11 ,
iadcPosInputPortCPin12 ,
iadcPosInputPortCPin13 ,
iadcPosInputPortCPin14 ,
iadcPosInputPortCPin15 ,
iadcPosInputPortDPin0 ,
iadcPosInputPortDPin1 ,
iadcPosInputPortDPin2 ,
iadcPosInputPortDPin3 ,
iadcPosInputPortDPin4 ,
iadcPosInputPortDPin5 ,
iadcPosInputPortDPin6 ,
iadcPosInputPortDPin7 ,
iadcPosInputPortDPin8 ,
iadcPosInputPortDPin9 ,
iadcPosInputPortDPin10 ,
iadcPosInputPortDPin11 ,
iadcPosInputPortDPin12 ,
iadcPosInputPortDPin13 ,
iadcPosInputPortDPin14 ,
iadcPosInputPortDPin15
}
IADC positive port selection.
enum IADC_Cmd_t {
iadcCmdStartSingle = IADC_CMD_SINGLESTART,
iadcCmdStopSingle = IADC_CMD_SINGLESTOP,
iadcCmdStartScan = IADC_CMD_SCANSTART,
iadcCmdStopScan = IADC_CMD_SCANSTOP,
iadcCmdEnableTimer = IADC_CMD_TIMEREN,
iadcCmdDisableTimer = IADC_CMD_TIMERDIS
}
IADC Commands.
enum IADC_CfgAdcMode_t { iadcCfgModeNormal = _IADC_CFG_ADCMODE_NORMAL }
IADC Configuration.
enum IADC_CfgOsrHighSpeed_t {
iadcCfgOsrHighSpeed2x = _IADC_CFG_OSRHS_HISPD2,
iadcCfgOsrHighSpeed4x = _IADC_CFG_OSRHS_HISPD4,
iadcCfgOsrHighSpeed8x = _IADC_CFG_OSRHS_HISPD8,
iadcCfgOsrHighSpeed16x = _IADC_CFG_OSRHS_HISPD16,
iadcCfgOsrHighSpeed32x = _IADC_CFG_OSRHS_HISPD32,
iadcCfgOsrHighSpeed64x = _IADC_CFG_OSRHS_HISPD64
}
IADC Over sampling rate for high speed.
enum IADC_CfgAnalogGain_t {
iadcCfgAnalogGain0P5x = _IADC_CFG_ANALOGGAIN_ANAGAIN0P5,
iadcCfgAnalogGain1x = _IADC_CFG_ANALOGGAIN_ANAGAIN1,
iadcCfgAnalogGain2x = _IADC_CFG_ANALOGGAIN_ANAGAIN2,
iadcCfgAnalogGain3x = _IADC_CFG_ANALOGGAIN_ANAGAIN3,
iadcCfgAnalogGain4x = _IADC_CFG_ANALOGGAIN_ANAGAIN4
}
IADC Analog Gain.
enum IADC_CfgReference_t {
iadcCfgReferenceInt1V2 = _IADC_CFG_REFSEL_VBGR,
iadcCfgReferenceExt1V25 = _IADC_CFG_REFSEL_VREF,
iadcCfgReferenceVddx = _IADC_CFG_REFSEL_VDDX,
iadcCfgReferenceVddX0P8Buf = _IADC_CFG_REFSEL_VDDX0P8BUF
}
IADC Reference.
enum IADC_CfgTwosComp_t {
iadcCfgTwosCompAuto = _IADC_CFG_TWOSCOMPL_AUTO,
iadcCfgTwosCompUnipolar = _IADC_CFG_TWOSCOMPL_FORCEUNIPOLAR,
iadcCfgTwosCompBipolar = _IADC_CFG_TWOSCOMPL_FORCEBIPOLAR
}
IADC Two's complement results.
enum IADC_TriggerSel_t {
iadcTriggerSelImmediate = _IADC_TRIGGER_SCANTRIGSEL_IMMEDIATE,
iadcTriggerSelTimer = _IADC_TRIGGER_SCANTRIGSEL_TIMER,
iadcTriggerSelPrs0SameClk = _IADC_TRIGGER_SCANTRIGSEL_PRSCLKGRP,
iadcTriggerSelPrs0PosEdge = _IADC_TRIGGER_SCANTRIGSEL_PRSPOS,
iadcTriggerSelPrs0NegEdge = _IADC_TRIGGER_SCANTRIGSEL_PRSNEG
}
IADC trigger action.
enum IADC_TriggerAction_t {
iadcTriggerActionOnce = _IADC_TRIGGER_SCANTRIGACTION_ONCE,
iadcTriggerActionContinuous = _IADC_TRIGGER_SCANTRIGACTION_CONTINUOUS
}
IADC trigger action.
enum IADC_FifoCfgDvl_t {
iadcFifoCfgDvl1 = _IADC_SCANFIFOCFG_DVL_VALID1,
iadcFifoCfgDvl2 = _IADC_SCANFIFOCFG_DVL_VALID2,
iadcFifoCfgDvl3 = _IADC_SCANFIFOCFG_DVL_VALID3,
iadcFifoCfgDvl4 = _IADC_SCANFIFOCFG_DVL_VALID4
}
IADC data valid level before requesting DMA transfer.

Function Documentation

IADC_init()

void IADC_init ( IADC_TypeDef * iadc,
const IADC_Init_t * init,
const IADC_AllConfigs_t * allConfigs
)

Initialize IADC.

Initializes common parts for both single conversion and scan sequence. In addition, single and/or scan control configuration must be done, please refer to IADC_initSingle() and IADC_initScan() respectively.

Note
This function will stop any ongoing conversions.
Parameters
[in] iadc Pointer to IADC peripheral register block.
[in] init Pointer to IADC initialization structure.
[in] allConfigs Pointer to structure holding all configs.

IADC_initScan()

void IADC_initScan ( IADC_TypeDef * iadc,
const IADC_InitScan_t * init,
const IADC_ScanTable_t * scanTable
)

Initialize IADC scan sequence.

This function will configure scan mode and set up entries in the scan table. The scan table mask can be updated by calling IADC_updateScanMask.

Note
This function will stop any ongoing conversions.
If an even numbered pin is selected for the positive input, the negative input must use an odd numbered pin and vice versa.
Parameters
[in] iadc Pointer to IADC peripheral register block.
[in] init Pointer to IADC initialization structure.
[in] scanTable Pointer to IADC scan table structure.

IADC_initSingle()

void IADC_initSingle ( IADC_TypeDef * iadc,
const IADC_InitSingle_t * init,
const IADC_SingleInput_t * input
)

Initialize single IADC conversion.

This function will initialize the single conversion and configure the single input selection.

Note
This function will stop any ongoing conversions.
If an even numbered pin is selected for the positive input, the negative input must use an odd numbered pin and vice versa.
Parameters
[in] iadc Pointer to IADC peripheral register block.
[in] init Pointer to IADC single initialization structure.
[in] input Pointer to IADC single input selection initialization structure.

IADC_updateSingleInput()

void IADC_updateSingleInput ( IADC_TypeDef * iadc,
const IADC_SingleInput_t * input
)

Update IADC single input selection.

This function updates the single input selection. The function can be called while single and/or scan conversions are ongoing and the new input configuration will take place on the next single conversion.

Note
If an even numbered pin is selected for the positive input, the negative input must use an odd numbered pin and vice versa.
Parameters
[in] iadc Pointer to IADC peripheral register block.
[in] input Pointer to single input selection structure.

IADC_setScanMask()

void IADC_setScanMask ( IADC_TypeDef * iadc,
uint32_t mask
)

Set mask of IADC scan table entries to include in scan.

Set mask of scan table entries to include in next scan. This function can be called while scan conversions are ongoing, but the new scan mask will take effect once the ongoing scan is completed.

Parameters
[in] iadc Pointer to IADC peripheral register block.
[in] mask Mask of scan table entries to include in scan.

IADC_updateScanEntry()

void IADC_updateScanEntry ( IADC_TypeDef * iadc,
uint8_t id,
IADC_ScanTableEntry_t * entry
)

Add/update entry in scan table.

This function will update or add an entry in the scan table with a specific ID.

Note
This function will stop any ongoing conversions.
Parameters
[in] iadc Pointer to IADC peripheral register block.
[in] id Id of scan table entry to add.
[in] entry Pointer to scan table entry structure.

IADC_reset()

void IADC_reset ( IADC_TypeDef * iadc