IADC - Incremental ADC#
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.
Introduction#
The IADC provides high-accuracy analog-to-digital conversion with incremental/sigma-delta operation for improved resolution. It's designed for precision measurements and offers various operating modes.
Example#
IADC Basic example:
{
// Initialize IADC
sl_hal_iadc_init_t init = {
.iadc_clk_suspend0 = false,
.iadc_clk_suspend1 = false,
.debug_halt = false,
.warmup = SL_HAL_IADC_WARMUP_NORMAL,
.timebase = 0, // Will be calculated automatically
.src_clk_prescale = 0,
.timer_cycles = 1000 // Timer period in ADC_CLK cycles
};
// IADC scan configuration
sl_hal_iadc_init_scan_t scan_init = {
.alignment = SL_HAL_IADC_ALIGNMENT_RIGHT_12,
.show_id = true,
.data_valid_level = SL_HAL_IADC_DATA_VALID_1,
.fifo_dma_wakeup = false,
.trigger_select = SL_HAL_IADC_TRIGGER_IMMEDIATE,
.trigger_action = SL_HAL_IADC_TRIGGER_ACTION_ONCE
};
// IADC default configuration
sl_hal_iadc_config_t iadc_config = {
.adc_mode = SL_HAL_IADC_CFG_ADC_MODE_NORMAL,
.osr_high_speed = SL_HAL_IADC_OSR_HIGH_SPEED_16X,
.analog_gain = SL_HAL_IADC_ANALOG_GAIN_1,
.reference = SL_HAL_IADC_REFERENCE_VREFINT_1V2,
.twos_complement = SL_HAL_IADC_TWOS_COMP_AUTO,
.adc_clk_prescale = 0,
.vref = SL_HAL_IADC_DEFAULT_VREF
};
// Assign config to the init structure
init.configs[0] = iadc_config;
// Configure scan table entry
sl_hal_iadc_scan_table_entry_t entry = {
.negative_port = SL_HAL_IADC_NEG_PORT_INPUT_GND,
.negative_pin = 0,
.positive_port = SL_HAL_IADC_POS_PORT_INPUT_PORT_A,
.positive_pin = 0,
.config_id = 0,
.compare = false,
.include_in_scan = true
};
// Set the scan table entry
sl_hal_iadc_scan_table_t scan_table = SL_HAL_IADC_SCANTABLE_DEFAULT;
scan_table.entries[0] = entry;
// Initialize hardware
sl_hal_iadc_init(IADC0, &init);
sl_hal_iadc_init_scan(IADC0, &scan_init);
sl_hal_iadc_set_scan_table(IADC0, &scan_table);
// Enable IADC
sl_hal_iadc_enable(IADC0);
// Start conversion
sl_hal_iadc_cmd(IADC0, SL_HAL_IADC_CMD_START_SCAN);
// Wait for conversion to complete
while ((IADC0->STATUS & IADC_STATUS_SCANFIFODV) == 0) {
// Wait for data valid flag
}
// Read result
sl_hal_iadc_result_t result = sl_hal_iadc_scan_read_fifo(IADC0);
// Use result.data and result.id here
}
Modules#
sl_hal_iadc_scan_table_entry_t
Enumerations#
Warm-up mode.
IADC result alignment.
IADC Reference.
IADC negative input ground pin selection.
IADC positive input supply pin selection.
IADC negative input port selection.
IADC positive input port selection.
IADC pin input for GPIO port.
Channel identifier.
IADC Commands.
IADC Configuration.
IADC Over sampling rate for high speed.
IADC Over sampling rate for high accuracy.
IADC Analog Gain.
IADC Two's complement results.
IADC trigger.
IADC trigger action.
IADC data valid level before requesting DMA transfer.
IADC digital averaging function.
Functions#
Initialize IADC.
Calculate gain and offset.
Reset IADC to same state as after a HW reset.
Initialize IADC scan sequence.
Add/update entry in scan table.
Set mask of IADC scan table entries to include in scan using scan mask.
Set mask of IADC scan table entries to include in scan using scan table.
Initialize single IADC conversion.
Update IADC single input selection.
Calculate prescaler for CLK_SRC_ADC high speed clock.
Calculate prescaler for ADC_CLK clock.
Calculate timebase value in order to get a timebase providing at least 1us.
Read most recent single conversion result.
Pull result from single data FIFO.
Read most recent scan conversion result.
Pull result from scan data FIFO.
Get reference voltage selection.
Enable the IADC.
Wait for ongoing sync of register(s) to the low-frequency domain to complete.
Wait for disabling to finish.
Disable the IADC.
Start the IADC scan queue.
Stop the IADC scan queue.
Start the IADC single queue.
Stop the IADC single queue.
Enable the IADC's local timer.
Disable the IADC's local timer and resets the counter.
Get status bits of IADC.
Clear one or more pending IADC interrupts.
Disable one or more IADC interrupts.
Enable one or more IADC interrupts.
Get pending IADC interrupt flags.
Get enabled and pending IADC interrupt flags.
Set one or more pending IADC interrupts from SW.
Pull data from single data FIFO.
Read most recent single conversion data.
Pull data from scan data FIFO.
Read most recent scan conversion data.
Start/stop scan sequence, single conversion and/or timer.
Get the scan mask currently used in the IADC.
Get the number of elements in the IADC single FIFO.
Get the number of elements in the IADC scan FIFO.
Convert the GPIO port/pin to IADC negative port input selection.
Convert the GPIO port/pin to IADC positive port input selection.
Macros#
Validation of IADC register block pointer reference for assert statements.
IADC default reference voltage in mV.
Default config for IADC scan table entry structure.
Default IADC sructure for all configs.
Default config for IADC init structure.
Default IADC config structure.
Default config for IADC scan init structure.
Default config for IADC single init structure.
Default config for IADC single input structure.
Enumeration Documentation#
sl_hal_iadc_warmup_t#
sl_hal_iadc_warmup_t
Warm-up mode.
Enumerator | |
---|---|
SL_HAL_IADC_WARMUP_NORMAL | IADC shutdown after each conversion. |
SL_HAL_IADC_WARMUP_KEEP_IN_STANDBY | IADC is kept in standby mode between conversion. |
SL_HAL_IADC_WARMUP_KEEP_WARM | IADC and reference selected for scan mode kept warmup, allowing continuous conversion. |
sl_hal_iadc_alignment_t#
sl_hal_iadc_alignment_t
IADC result alignment.
Enumerator | |
---|---|
SL_HAL_IADC_ALIGNMENT_RIGHT_12 | IADC results 12-bit right aligned. |
SL_HAL_IADC_ALIGNMENT_LEFT_12 | IADC results 12-bit left aligned. |
SL_HAL_IADC_ALIGNMENT_RIGHT_16 | IADC results 16-bit right aligned. |
SL_HAL_IADC_ALIGNMENT_LEFT_16 | IADC results 16-bit left aligned. |
SL_HAL_IADC_ALIGNMENT_RIGHT_20 | IADC results 20-bit right aligned. |
SL_HAL_IADC_ALIGNMENT_LEFT_20 | IADC results 20-bit left aligned. |
sl_hal_iadc_voltage_reference_t#
sl_hal_iadc_voltage_reference_t
IADC Reference.
Enumerator | |
---|---|
SL_HAL_IADC_REFERENCE_VREFINT_1V2 | Internal 1.2V Band Gap Reference (buffered) to ground. |
SL_HAL_IADC_VREF_EXT_1V25 | External reference (unbuffered) VREFP to VREFN. |
SL_HAL_IADC_VREF_EXT_2V5 | External reference (unbuffered) VREFP to VREFN. Supports 2.5V in high accuracy mode. |
SL_HAL_IADC_VREF_VDDX | VDDX (unbuffered) to ground. |
SL_HAL_IADC_VREF_VDDX0P8BUF | 0.8 * VDDX (buffered) to ground. |
sl_hal_iadc_neg_input_port_gnd_pin_selection_t#
sl_hal_iadc_neg_input_port_gnd_pin_selection_t
IADC negative input ground pin selection.
Enumerator | |
---|---|
SL_HAL_IADC_NEG_PIN_INPUT_GND_AUX | GND auxiliary. |
SL_HAL_IADC_NEG_PIN_INPUT_GND | GND. |
sl_hal_iadc_pos_input_port_supply_pin_selection_t#
sl_hal_iadc_pos_input_port_supply_pin_selection_t
IADC positive input supply pin selection.
Enumerator | |
---|---|
SL_HAL_IADC_POS_PIN_INPUT_AVDD | AVDD / 4. |
SL_HAL_IADC_POS_PIN_INPUT_IOVDD | VDDIO / 4. |
SL_HAL_IADC_POS_PIN_INPUT_VSS | VSS. |
SL_HAL_IADC_POS_PIN_INPUT_VSS_AUX | VSS auxiliary. |
SL_HAL_IADC_POS_PIN_INPUT_DVDD | DVDD / 4. |
SL_HAL_IADC_POS_PIN_INPUT_DECOUPLE | DECOUPLE / 4. |
sl_hal_iadc_negative_port_input_t#
sl_hal_iadc_negative_port_input_t
IADC negative input port selection.
Enumerator | |
---|---|
SL_HAL_IADC_NEG_PORT_INPUT_GND | Ground. |
SL_HAL_IADC_NEG_PORT_INPUT_DAC_1 | Direct connection to DAC_1 input pin. |
SL_HAL_IADC_NEG_PORT_INPUT_PAD_ANA_1 | Direct connection to Pad_ana_1 input pin. |
SL_HAL_IADC_NEG_PORT_INPUT_PORT_A | GPIO port A. |
SL_HAL_IADC_NEG_PORT_INPUT_PORT_B | GPIO port B. |
SL_HAL_IADC_NEG_PORT_INPUT_PORT_C | GPIO port C. |
SL_HAL_IADC_NEG_PORT_INPUT_PORT_D | GPIO port D. |
sl_hal_iadc_positive_port_input_t#
sl_hal_iadc_positive_port_input_t
IADC positive input port selection.
Enumerator | |
---|---|
SL_HAL_IADC_POS_PORT_INPUT_GND | Ground. |
SL_HAL_IADC_POS_PORT_INPUT_SUPPLY | Supply. |
SL_HAL_IADC_POS_PORT_INPUT_DAC_0 | Direct connection to DAC_0 input pin. |
SL_HAL_IADC_POS_PORT_INPUT_PAD_ANA_0 | Direct connection to Pad_ana_0 input pin. |
SL_HAL_IADC_POS_PORT_INPUT_PORT_A | GPIO port A. |
SL_HAL_IADC_POS_PORT_INPUT_PORT_B | GPIO port B. |
SL_HAL_IADC_POS_PORT_INPUT_PORT_C | GPIO port C. |
SL_HAL_IADC_POS_PORT_INPUT_PORT_D | GPIO port D. |
sl_hal_iadc_gpio_port_input_pin_t#
sl_hal_iadc_gpio_port_input_pin_t
IADC pin input for GPIO port.
Enumerator | |
---|---|
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_0 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_1 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_2 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_3 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_4 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_5 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_6 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_7 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_8 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_9 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_10 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_11 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_12 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_13 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_14 | |
SL_HAL_IADC_GPIO_PORT_INPUT_PIN_15 |
sl_hal_iadc_channel_id_t#
sl_hal_iadc_channel_id_t
Channel identifier.
Enumerator | |
---|---|
SL_HAL_IADC_CHANNEL_ID_0 | |
SL_HAL_IADC_CHANNEL_ID_1 | |
SL_HAL_IADC_CHANNEL_ID_2 | |
SL_HAL_IADC_CHANNEL_ID_3 | |
SL_HAL_IADC_CHANNEL_ID_4 | |
SL_HAL_IADC_CHANNEL_ID_5 | |
SL_HAL_IADC_CHANNEL_ID_6 | |
SL_HAL_IADC_CHANNEL_ID_7 | |
SL_HAL_IADC_CHANNEL_ID_8 | |
SL_HAL_IADC_CHANNEL_ID_9 | |
SL_HAL_IADC_CHANNEL_ID_10 | |
SL_HAL_IADC_CHANNEL_ID_11 | |
SL_HAL_IADC_CHANNEL_ID_12 | |
SL_HAL_IADC_CHANNEL_ID_13 | |
SL_HAL_IADC_CHANNEL_ID_14 | |
SL_HAL_IADC_CHANNEL_ID_15 | |
SL_HAL_IADC_CHANNEL_ID_MAX |
sl_hal_iadc_cmd_t#
sl_hal_iadc_cmd_t
IADC Commands.
Enumerator | |
---|---|
SL_HAL_IADC_CMD_START_SINGLE | Start single queue. |
SL_HAL_IADC_CMD_STOP_SINGLE | Stop single queue. |
SL_HAL_IADC_CMD_START_SCAN | Start scan queue. |
SL_HAL_IADC_CMD_STOP_SCAN | Stop scan queue. |
SL_HAL_IADC_CMD_ENABLE_TIMER | Enable Timer. |
SL_HAL_IADC_CMD_DISABLE_TIMER | Disable Timer. |
sl_hal_iadc_config_adc_mode_t#
sl_hal_iadc_config_adc_mode_t
IADC Configuration.
Enumerator | |
---|---|
SL_HAL_IADC_CFG_ADC_MODE_NORMAL | Normal mode. |
SL_HAL_IADC_CFG_ADC_MODE_HIGH_SPEED | High Speed mode. |
SL_HAL_IADC_CFG_ADC_MODE_HIGH_ACCURACY | High Accuracy mode. |
sl_hal_iadc_config_osr_high_speed_t#
sl_hal_iadc_config_osr_high_speed_t
IADC Over sampling rate for high speed.
Enumerator | |
---|---|
SL_HAL_IADC_OSR_HIGH_SPEED_2X | High speed oversampling of 4x. |
SL_HAL_IADC_OSR_HIGH_SPEED_4X | High speed oversampling of 4x. |
SL_HAL_IADC_OSR_HIGH_SPEED_8X | High speed oversampling of 8x. |
SL_HAL_IADC_OSR_HIGH_SPEED_16X | High speed oversampling of 16x. |
SL_HAL_IADC_OSR_HIGH_SPEED_32X | High speed oversampling of 32x. |
SL_HAL_IADC_OSR_HIGH_SPEED_64X | High speed oversampling of 64x. |
sl_hal_iadc_config_osr_high_accuracy_t#
sl_hal_iadc_config_osr_high_accuracy_t
IADC Over sampling rate for high accuracy.
Enumerator | |
---|---|
SL_HAL_IADC_OSR_HIGH_ACCURACY_16X | High accuracy oversampling of 16x. |
SL_HAL_IADC_OSR_HIGH_ACCURACY_32X | High accuracy oversampling of 32x. |
SL_HAL_IADC_OSR_HIGH_ACCURACY_64X | High accuracy oversampling of 64x. |
SL_HAL_IADC_OSR_HIGH_ACCURACY_92X | High accuracy oversampling of 92x. |
SL_HAL_IADC_OSR_HIGH_ACCURACY_128X | High accuracy oversampling of 128x. |
SL_HAL_IADC_OSR_HIGH_ACCURACY_256X | High accuracy oversampling of 256x. |
sl_hal_iadc_analog_gain_t#
sl_hal_iadc_analog_gain_t
IADC Analog Gain.
Enumerator | |
---|---|
SL_HAL_IADC_ANALOG_GAIN_0P5 | Analog gain of 0.5x. |
SL_HAL_IADC_ANALOG_GAIN_1 | Analog gain of 1x. |
SL_HAL_IADC_ANALOG_GAIN_2 | Analog gain of 2x. |
SL_HAL_IADC_ANALOG_GAIN_3 | Analog gain of 3x. |
SL_HAL_IADC_ANALOG_GAIN_4 | Analog gain of 4x. |
sl_hal_iadc_config_twos_comp_t#
sl_hal_iadc_config_twos_comp_t
IADC Two's complement results.
Enumerator | |
---|---|
SL_HAL_IADC_TWOS_COMP_AUTO | Automatic. Single ended => Unipolar, Differential => Bipolar. |
SL_HAL_IADC_TWOS_COMP_UNIPOLAR | All results in unipolar format. Negative diff input gives 0 as result. |
SL_HAL_IADC_TWOS_COMP_BIPOLAR | All results in bipolar (2's complement) format. Half range for SE. |
sl_hal_iadc_trigger_t#
sl_hal_iadc_trigger_t
IADC trigger.
Enumerator | |
---|---|
SL_HAL_IADC_TRIGGER_IMMEDIATE | Start single/scan queue immediately. |
SL_HAL_IADC_TRIGGER_TIMER | Timer starts single/scan queue. |
SL_HAL_IADC_TRIGGER_PRSCLKGRP | PRS0 from timer in same clock group starts single/scan queue. |
SL_HAL_IADC_TRIGGER_PRSPOS | PRS0 positive edge starts single/scan queue. |
SL_HAL_IADC_TRIGGER_PRSNEG | PRS0 negative edge starts single/scan queue. |
SL_HAL_IADC_TRIGGER_LESENSE | LESENSE starts scan queue. |
sl_hal_iadc_trigger_action_t#
sl_hal_iadc_trigger_action_t
IADC trigger action.
Enumerator | |
---|---|
SL_HAL_IADC_TRIGGER_ACTION_ONCE | Convert single/scan queue once per trigger. |
SL_HAL_IADC_TRIGGER_ACTION_CONTINUOUS | Convert single/scan queue continuously. |
sl_hal_iadc_fifo_config_dvl_t#
sl_hal_iadc_fifo_config_dvl_t
IADC data valid level before requesting DMA transfer.
Enumerator | |
---|---|
SL_HAL_IADC_DATA_VALID_1 | Data valid level is 1 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_2 | Data valid level is 2 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_3 | Data valid level is 3 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_4 | Data valid level is 4 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_5 | Data valid level is 5 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_6 | Data valid level is 6 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_7 | Data valid level is 7 before requesting DMA transfer. |
SL_HAL_IADC_DATA_VALID_8 | Data valid level is 8 before requesting DMA transfer. |
sl_hal_iadc_digital_averaging_t#
sl_hal_iadc_digital_averaging_t
IADC digital averaging function.
Enumerator | |
---|---|
SL_HAL_IADC_AVERAGE_1 | Average over 1 sample (no averaging). |
SL_HAL_IADC_AVERAGE_2 | Average over 2 sample. |
SL_HAL_IADC_AVERAGE_4 | Average over 4 sample. |
SL_HAL_IADC_AVERAGE_8 | Average over 8 sample. |
SL_HAL_IADC_AVERAGE_16 | Average over 16 sample. |
Function Documentation#
sl_hal_iadc_init#
void sl_hal_iadc_init (IADC_TypeDef * iadc, const sl_hal_iadc_init_t * init, uint32_t src_clk_freq)
Initialize IADC.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
const sl_hal_iadc_init_t * | [in] | init | Pointer to IADC initialization structure. |
uint32_t | [in] | src_clk_freq | CLK_SRC_ADC frequency wanted. The frequency will automatically be adjusted to be within valid range according to reference manual. |
Initializes common parts for both single conversion and scan sequence. In addition, single and/or scan control configuration must be done, please refer to sl_hal_iadc_init_single() and sl_hal_iadc_init_scan() respectively.
Note
This function will stop any ongoing conversions.
sl_hal_iadc_calculate_gain_offset#
void sl_hal_iadc_calculate_gain_offset (IADC_TypeDef * iadc, const sl_hal_iadc_init_t * init, sl_hal_iadc_config_adc_mode_t adc_mode, uint8_t config, uint32_t adc_clk_prescale)
Calculate gain and offset.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
const sl_hal_iadc_init_t * | [in] | init | Pointer to IADC initialization structure. |
sl_hal_iadc_config_adc_mode_t | [in] | adc_mode | Mode for IADC config. |
uint8_t | [in] | config | IADC config number. |
uint32_t | [in] | adc_clk_prescale | IADC clock prescaler. |
This function calculates the gain and offset values for the IADC based on the provided configuration.
sl_hal_iadc_reset#
void sl_hal_iadc_reset (IADC_TypeDef * iadc)
Reset IADC to same state as after a HW reset.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
sl_hal_iadc_init_scan#
void sl_hal_iadc_init_scan (IADC_TypeDef * iadc, const sl_hal_iadc_init_scan_t * init, const sl_hal_iadc_scan_table_t * scan_table)
Initialize IADC scan sequence.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
const sl_hal_iadc_init_scan_t * | [in] | init | Pointer to IADC initialization structure. |
const sl_hal_iadc_scan_table_t * | [in] | scan_table | Pointer to IADC scan table structure. |
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.
sl_hal_iadc_update_scan_entry#
void sl_hal_iadc_update_scan_entry (IADC_TypeDef * iadc, uint8_t id, sl_hal_iadc_scan_table_entry_t * entry)
Add/update entry in scan table.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint8_t | [in] | id | ID of scan table entry to add. |
sl_hal_iadc_scan_table_entry_t * | [in] | entry | Pointer to scan table entry structure. |
This function will update or add an entry in the scan table with a specific ID.
Note
This function will stop any ongoing conversions.
sl_hal_iadc_set_scan_mask#
void sl_hal_iadc_set_scan_mask (IADC_TypeDef * iadc, uint32_t mask)
Set mask of IADC scan table entries to include in scan using scan mask.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | mask | Mask of 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.
sl_hal_iadc_set_scan_mask_multiple_entries#
void sl_hal_iadc_set_scan_mask_multiple_entries (IADC_TypeDef * iadc, const sl_hal_iadc_scan_table_t * scan_table)
Set mask of IADC scan table entries to include in scan using scan table.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
const sl_hal_iadc_scan_table_t * | [in] | scan_table | Pointer to IADC scan table structure. |
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.
sl_hal_iadc_init_single#
void sl_hal_iadc_init_single (IADC_TypeDef * iadc, const sl_hal_iadc_init_single_t * init, const sl_hal_iadc_single_input_t * input)
Initialize single IADC conversion.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
const sl_hal_iadc_init_single_t * | [in] | init | Pointer to IADC single initialization structure. |
const sl_hal_iadc_single_input_t * | [in] | input | Pointer to IADC single input selection initialization structure. |
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.
sl_hal_iadc_update_single_input#
void sl_hal_iadc_update_single_input (IADC_TypeDef * iadc, const sl_hal_iadc_single_input_t * input)
Update IADC single input selection.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
const sl_hal_iadc_single_input_t * | [in] | input | Pointer to single input selection structure. |
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.
sl_hal_iadc_calculate_src_clk_prescale#
uint8_t sl_hal_iadc_calculate_src_clk_prescale (IADC_TypeDef * iadc, uint32_t src_clk_freq, uint32_t cmu_clk_freq)
Calculate prescaler for CLK_SRC_ADC high speed clock.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | src_clk_freq | CLK_SRC_ADC frequency wanted. The frequency will automatically be adjusted to be within valid range according to reference manual. |
uint32_t | [in] | cmu_clk_freq | Frequency in Hz of reference CLK_CMU_ADC. |
The IADC high speed clock is given by: CLK_SRC_ADC / (scr_clk_prescaler + 1).
Returns
Divider value to use for IADC in order to achieve a high speed clock value.
sl_hal_iadc_calculate_adc_clk_prescale#
uint32_t sl_hal_iadc_calculate_adc_clk_prescale (IADC_TypeDef * iadc, uint32_t adc_clk_freq, uint32_t cmu_clk_freq, sl_hal_iadc_config_adc_mode_t adc_mode, uint8_t scr_clk_prescaler)
Calculate prescaler for ADC_CLK clock.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | adc_clk_freq | ADC_CLK frequency wanted. The frequency will automatically be adjusted to be within valid range according to reference manual. |
uint32_t | [in] | cmu_clk_freq | Frequency in Hz of CLK_CMU_ADC. |
sl_hal_iadc_config_adc_mode_t | [in] | adc_mode | Mode for IADC config. |
uint8_t | [in] | scr_clk_prescaler | Precaler setting for ADC_CLK. |
The ADC_CLK is given by: CLK_SRC_ADC / (adcClkprescale + 1).
Returns
Divider value to use for IADC in order to achieve a ADC_CLK frequency.
sl_hal_iadc_calculate_timebase#
uint8_t sl_hal_iadc_calculate_timebase (IADC_TypeDef * iadc, uint32_t src_clk_freq)
Calculate timebase value in order to get a timebase providing at least 1us.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | src_clk_freq | Frequency in Hz of reference CLK_SRC_ADC clock. |
Returns
Timebase value to use for IADC in order to achieve at least 1 us.
sl_hal_iadc_read_single_result#
sl_hal_iadc_result_t sl_hal_iadc_read_single_result (IADC_TypeDef * iadc)
Read most recent single conversion result.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
The result struct includes both the data and the ID (0x20) if show_id was set when initializing single mode. Calling this function will not affect the state of the single data FIFO.
Note
Check data valid flag before calling this function.
Returns
Single conversion result struct holding data and id.
sl_hal_iadc_read_single_fifo_result#
sl_hal_iadc_result_t sl_hal_iadc_read_single_fifo_result (IADC_TypeDef * iadc)
Pull result from single data FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
The result struct includes both the data and the ID (0x20) if show_id was set when initializing single mode.
Note
Check data valid flag before calling this function.
Returns
Single conversion result struct holding data and id.
sl_hal_iadc_read_scan_result#
sl_hal_iadc_result_t sl_hal_iadc_read_scan_result (IADC_TypeDef * iadc)
Read most recent scan conversion result.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
The result struct includes both the data and the ID (0x20) if show_id was set when initializing scan entry. Calling this function will not affect the state of the scan data FIFO.
Note
Check data valid flag before calling this function.
Returns
Scan conversion result struct holding data and id.
sl_hal_iadc_pull_scan_fifo_result#
sl_hal_iadc_result_t sl_hal_iadc_pull_scan_fifo_result (IADC_TypeDef * iadc)
Pull result from scan data FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
The result struct includes both the data and the ID (0x20) if show_id was set when initializing scan entry.
Note
Check data valid flag before calling this function.
Returns
Scan conversion result struct holding data and id.
sl_hal_iadc_get_reference_voltage#
uint32_t sl_hal_iadc_get_reference_voltage (sl_hal_iadc_voltage_reference_t reference)
Get reference voltage selection.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_hal_iadc_voltage_reference_t | [in] | reference | IADC Reference selection. |
Returns
IADC reference voltage in millivolts.
sl_hal_iadc_enable#
void sl_hal_iadc_enable (IADC_TypeDef * iadc)
Enable the IADC.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_wait_sync#
void sl_hal_iadc_wait_sync (IADC_TypeDef * iadc)
Wait for ongoing sync of register(s) to the low-frequency domain to complete.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_wait_ready#
void sl_hal_iadc_wait_ready (IADC_TypeDef * iadc)
Wait for disabling to finish.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the ADC peripheral register block. |
sl_hal_iadc_disable#
void sl_hal_iadc_disable (IADC_TypeDef * iadc)
Disable the IADC.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_start_scan#
void sl_hal_iadc_start_scan (IADC_TypeDef * iadc)
Start the IADC scan queue.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
Note
Enables The scan sequence and will start a scan if using the immediate trigger mode.
sl_hal_iadc_stop_scan#
void sl_hal_iadc_stop_scan (IADC_TypeDef * iadc)
Stop the IADC scan queue.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_start_single#
void sl_hal_iadc_start_single (IADC_TypeDef * iadc)
Start the IADC single queue.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
Note
Enables the scan sequence and will start a scan if using the immediate trigger mode.
sl_hal_iadc_stop_single#
void sl_hal_iadc_stop_single (IADC_TypeDef * iadc)
Stop the IADC single queue.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_enable_timer#
void sl_hal_iadc_enable_timer (IADC_TypeDef * iadc)
Enable the IADC's local timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_disable_timer#
void sl_hal_iadc_disable_timer (IADC_TypeDef * iadc)
Disable the IADC's local timer and resets the counter.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | A pointer to the IADC peripheral register block. |
sl_hal_iadc_get_status#
uint32_t sl_hal_iadc_get_status (IADC_TypeDef * iadc)
Get status bits of IADC.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
Returns
IADC status bits.
sl_hal_iadc_clear_interrupts#
void sl_hal_iadc_clear_interrupts (IADC_TypeDef * iadc, uint32_t flags)
Clear one or more pending IADC interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | flags | Pending IADC interrupt source to clear. Use a bitwise logic OR combination of valid interrupt flags for the IADC module (IADC_IF_nnn). |
sl_hal_iadc_disable_interrupts#
void sl_hal_iadc_disable_interrupts (IADC_TypeDef * iadc, uint32_t flags)
Disable one or more IADC interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | flags | IADC interrupt sources to disable. Use a bitwise logic OR combination of valid interrupt flags for the IADC module (IADC_IF_nnn). |
sl_hal_iadc_enable_interrupts#
void sl_hal_iadc_enable_interrupts (IADC_TypeDef * iadc, uint32_t flags)
Enable one or more IADC interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | flags | IADC interrupt sources to enable. Use a bitwise logic OR combination of valid interrupt flags for the IADC module (IADC_IF_nnn). |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using sl_hal_iadc_clear_interrupts() prior to enabling if such a pending interrupt should be ignored.
sl_hal_iadc_get_pending_interrupts#
uint32_t sl_hal_iadc_get_pending_interrupts (IADC_TypeDef * iadc)
Get pending IADC interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
Returns
IADC interrupt sources pending. A bitwise logic OR combination of valid interrupt flags for the IADC module (IADC_IF_nnn).
Note
The event bits are not cleared by the use of this function.
sl_hal_iadc_get_enable_pending_interrupts#
uint32_t sl_hal_iadc_get_enable_pending_interrupts (IADC_TypeDef * iadc)
Get enabled and pending IADC interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
Useful for handling more interrupt sources in the same interrupt handler.
Note
Interrupt flags are not cleared by the use of this function.
Returns
Pending and enabled IADC interrupt sources. The return value is the bitwise AND combination of
The OR combination of enabled interrupt sources in IADCx_IEN_nnn register (IADCx_IEN_nnn).
The OR combination of valid interrupt flags of the IADC module (IADCx_IF_nnn).
sl_hal_iadc_set_pending_interrupts#
void sl_hal_iadc_set_pending_interrupts (IADC_TypeDef * iadc, uint32_t flags)
Set one or more pending IADC interrupts from SW.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
uint32_t | [in] | flags | IADC interrupt sources to set to pending. Use a bitwise logic OR combination of valid interrupt flags for the IADC module (IADC_IF_nnn). |
sl_hal_iadc_pull_single_fifo_data#
uint32_t sl_hal_iadc_pull_single_fifo_data (IADC_TypeDef * iadc)
Pull data from single data FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
If show_id was set when initializing single mode, the results will contain the ID (0x20).
Note
Check data valid flag before calling this function.
Returns
Single conversion data.
sl_hal_iadc_read_single_data#
uint32_t sl_hal_iadc_read_single_data (IADC_TypeDef * iadc)
Read most recent single conversion data.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
If show_id was set when initializing single mode, the data will contain the ID (0x20). Calling this function will not affect the state of the single data FIFO.
Note
Check data valid flag before calling this function.
Returns
Single conversion data.
sl_hal_iadc_pull_scan_fifo_data#
uint32_t sl_hal_iadc_pull_scan_fifo_data (IADC_TypeDef * iadc)
Pull data from scan data FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
If show_id was set for the scan entry initialization, the data will contain the ID of the scan entry.
Note
Check data valid flag before calling this function.
Returns
Scan conversion data.
sl_hal_iadc_read_scan_data#
uint32_t sl_hal_iadc_read_scan_data (IADC_TypeDef * iadc)
Read most recent scan conversion data.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
If show_id was set for the scan entry initialization, the data will contain the ID of the scan entry. Calling this function will not affect the state of the scan data FIFO.
Note
Check data valid flag before calling this function.
Returns
Scan conversion data.
sl_hal_iadc_set_command#
void sl_hal_iadc_set_command (IADC_TypeDef * iadc, sl_hal_iadc_cmd_t cmd)
Start/stop scan sequence, single conversion and/or timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
sl_hal_iadc_cmd_t | [in] | cmd | Command to be performed. |
sl_hal_iadc_get_scan_mask#
uint32_t sl_hal_iadc_get_scan_mask (IADC_TypeDef * iadc)
Get the scan mask currently used in the IADC.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
Returns
Mask of scan table entries currently included in scan.
sl_hal_iadc_get_single_fifo_cnt#
uint8_t sl_hal_iadc_get_single_fifo_cnt (IADC_TypeDef * iadc)
Get the number of elements in the IADC single FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
Returns
Number of elements in single FIFO.
sl_hal_iadc_get_scan_fifo_cnt#
uint8_t sl_hal_iadc_get_scan_fifo_cnt (IADC_TypeDef * iadc)
Get the number of elements in the IADC scan FIFO.
Type | Direction | Argument Name | Description |
---|---|---|---|
IADC_TypeDef * | [in] | iadc | Pointer to IADC peripheral register block. |
Returns
Number of elements in scan FIFO.
sl_hal_iadc_port_pin_to_neg_port#
sl_hal_iadc_negative_port_input_t sl_hal_iadc_port_pin_to_neg_port (const sl_gpio_t * gpio, pin)
Convert the GPIO port/pin to IADC negative port input selection.
Type | Direction | Argument Name | Description |
---|---|---|---|
const sl_gpio_t * | [in] | gpio | GPIO port. |
[in] | pin | GPIO in. |
Returns
IADC negative port input selection.
sl_hal_iadc_port_pin_to_pos_port#
sl_hal_iadc_positive_port_input_t sl_hal_iadc_port_pin_to_pos_port (const sl_gpio_t * gpio, pin)
Convert the GPIO port/pin to IADC positive port input selection.
Type | Direction | Argument Name | Description |
---|---|---|---|
const sl_gpio_t * | [in] | gpio | GPIO port. |
[in] | pin | GPIO in. |
Returns
IADC positive port input selection.