Analog to Digital Converter#

Introduction#

The Analog-to-Digital Converter (ADC) is a crucial peripheral in microcontrollers, enabling the conversion of analog signals (continuous voltage levels) into digital data (discrete binary values). This conversion allows microcontrollers to interface with analog sensors, such as temperature sensors, light sensors, or joysticks, effectively translating real-world analog signals into data that can be processed by digital systems.

ADC Block DiagramADC Block Diagram

ADCs are essential in a wide range of applications, including:

  1. Sensor Data Acquisition: Converting sensor outputs into digital form for processing.

  2. Audio Processing: Digitizing analog audio signals for further manipulation.

  3. Instrumentation and Measurement: Precise measurement of analog signals.

  4. Motor Control: Monitoring and controlling motor performance.

  5. Battery Monitoring and Management: Ensuring optimal battery usage.

  6. Feedback Control Systems: Providing digital feedback for control systems.

Configuration#

Configuring the ADC involves several key steps to ensure accurate and efficient operation. These steps vary based on the specific hardware and application requirements. Below are some essential configuration tasks:

  • Channel and Mode Configuration: Set the number of ADC channels and the operating mode by configuring the sl_adc_config_t structure. Use this structure with the API sl_si91x_adc_set_channel_configuration() to apply the settings.

  • Channel-Specific Settings: Define input type, sample count (1-1023), and sampling rate (1-2,500,000 samples per second) in the sl_adc_channel_config_t structure. After configuring this structure, call sl_si91x_adc_set_channel_configuration() to set the channel parameters.

For more detailed configuration information, see the specific peripheral example README documents.

Usage#

After defining the ADC configuration structures, use the following functions to initialize and control the ADC module:

  1. Configure Clock: sl_si91x_adc_configure_clock

  2. Initialize ADC: sl_si91x_adc_init

  3. Set Channel Configuration: sl_si91x_adc_set_channel_configuration

  4. Register Event Callback: sl_si91x_adc_register_event_callback

  5. Start ADC: sl_si91x_adc_start

  6. Read Data: sl_si91x_adc_read_data

  7. Deinitialize ADC: sl_si91x_adc_deinit

Modules#

sl_adc_threshold_config_t

sl_adc_fifo_thrld_config_t

sl_adc_clock_config_t

sl_adc_version_t

Enumerations#

enum
SL_ADC_SINGLE_ENDED
SL_ADC_DIFFERENTIAL
SL_ADC_INPUT_TYPE_LAST
}

Enumeration for ADC input types.

enum
SL_ADC_FIFO_MODE = ADC_FIFOMODE_ENABLE
SL_ADC_STATIC_MODE = ADC_STATICMODE_ENABLE
SL_ADC_OPERATION_MODE_LAST
}

Enumeration for ADC operation mode.

enum
SL_ADC_INTERNAL_DMA = INTERNAL_DMA_EN
SL_ADC_EXTERNAL_DMA = EXTERNAL_DMA_EN
SL_ADC_DMA_TYPE_LAST
}

Enumeration for ADC DMA type.

enum
SL_ADC_SINGLE_CHNL = DYNAMIC_MODE_DI
SL_ADC_MULTI_CHNL = DYNAMIC_MODE_EN
SL_ADC_CHANNEL_TYPE_LAST
}

Enumeration for ADC channel selection modes.

enum
SL_ADC_CHANNEL_1
SL_ADC_CHANNEL_2
SL_ADC_CHANNEL_3
SL_ADC_CHANNEL_4
SL_ADC_CHANNEL_5
SL_ADC_CHANNEL_6
SL_ADC_CHANNEL_7
SL_ADC_CHANNEL_8
SL_ADC_CHANNEL_9
SL_ADC_CHANNEL_10
SL_ADC_CHANNEL_11
SL_ADC_CHANNEL_12
SL_ADC_CHANNEL_13
SL_ADC_CHANNEL_14
SL_ADC_CHANNEL_15
SL_ADC_CHANNEL_16
}

Enumeration for ADC channels.

Typedefs#

typedef adc_ch_config_t

Renamed ADC channel configuration structure.

typedef adc_config_t

Renamed ADC configuration structure.

typedef adc_inter_config_t

Renamed ADC internal configuration structure.

typedef void(*
sl_adc_callback_t)(uint8_t channel, uint8_t event)

Typedef for a user-provided callback function that is invoked upon the completion of an ADC sample.

Functions#

sl_status_t
sl_si91x_adc_configure_clock(sl_adc_clock_config_t *clock_configuration)

To set the ADC peripheral clock and configure the PLL clock based on user-specified values in the clock configuration structure.

sl_status_t
sl_si91x_adc_init(sl_adc_channel_config_t adc_channel_config, sl_adc_config_t adc_config, float vref_value)

To initialize the ADC peripheral.

sl_status_t
sl_si91x_adc_set_channel_configuration(sl_adc_channel_config_t adc_channel_config, sl_adc_config_t adc_config)

To configure the ADC channel parameters.

sl_status_t
sl_si91x_adc_register_event_callback(sl_adc_callback_t callback_event)

To register the user callback function.

void

To unregister the user callback function.

sl_status_t
sl_si91x_adc_configure_channel_sampling_rate(sl_adc_internal_config_t adc_internal_config, uint8_t channel_num)

To configure the ADC sampling rate for the ADC channels.

sl_status_t
sl_si91x_adc_configure_ping_pong_memory_address(sl_adc_internal_config_t adc_internal_config, uint8_t channel_num)

To configure the ADC ping and pong memory location and length.

sl_status_t
sl_si91x_adc_enable_ping_pong(uint8_t channel_num)

To enable ping-pong for the corresponding ADC channels.

sl_status_t
sl_si91x_adc_disable_ping_pong(uint8_t channel_num)

To disable ping-pong for the corresponding ADC channels.

sl_status_t

To enable DMA for the corresponding ADC channels.

sl_status_t

To disable DMA for the corresponding ADC channels.

sl_status_t
sl_si91x_adc_configure_static_mode(sl_adc_channel_config_t adc_channel_config, uint8_t channel_num)

To configure the ADC in Static Mode.

sl_status_t
sl_si91x_adc_configure_fifo_mode(sl_adc_channel_config_t adc_channel_config, uint8_t channel_num)

To configure the ADC in FIFO Mode.

sl_status_t
sl_si91x_adc_channel_enable(uint8_t channel_num)

To enable the ADC channel.

sl_status_t
sl_si91x_adc_channel_disable(uint8_t channel_num)

To disable the ADC channel.

sl_status_t
sl_si91x_adc_set_power_mode(POWER_STATE state)

To power on or off the ADC.

sl_status_t

To enable or disable the noise averaging mode for ADC.

sl_status_t

To enable the temperature sensor.

sl_status_t
sl_si91x_adc_fifo_threshold_configuration(sl_adc_config_t adc_config, sl_adc_fifo_thrld_config_t adc_fifo_threshold)

To configure ADC FIFO Threshold.

sl_status_t
sl_si91x_adc_threshold_configuration(sl_adc_threshold_config_t adc_threshold)

To configure the ADC threshold to compare threshold value with ADC data.

sl_status_t
sl_si91x_adc_read_data(sl_adc_channel_config_t adcchconfig, uint8_t channel_num)

To read the ADC sample data for FIFO mode of operation.

sl_status_t
sl_si91x_adc_read_data_static(sl_adc_channel_config_t adc_channel_config, sl_adc_config_t adc_config, uint16_t *adc_value)

To read the ADC sampled data for static mode of operation.

uint32_t
sl_si91x_adc_get_sampling_rate(uint8_t channel_num)

To get the channel sampling rate value configured to ADC.

sl_status_t
sl_si91x_adc_deinit(sl_adc_config_t adc_config)

To deinitialize the ADC.

sl_status_t
sl_si91x_adc_start(sl_adc_config_t adc_config)

To start the ADC operation.

sl_status_t
sl_si91x_adc_stop(sl_adc_config_t adc_config)

To stop the ADC operation.

To get the ADC version.

Macros#

#define
SL_INTERNAL_DMA INTERNAL_DMA

Internal DMA event.

#define
SL_ADC_STATIC_MODE_EVENT ADC_STATIC_MODE_CALLBACK

Static mode event.

#define
SIGN_BIT BIT(11)

Sign/magnitude bit.

Enumeration Documentation#

sl_adc_input_type_typedef_t#

sl_adc_input_type_typedef_t

Enumeration for ADC input types.

Enumerator
SL_ADC_SINGLE_ENDED

Single-ended input: measures the voltage between the input and ground.

SL_ADC_DIFFERENTIAL

Differential input: measures the voltage difference between two inputs.

SL_ADC_INPUT_TYPE_LAST

Marks the last enumeration value for validation checks.


Definition at line 83 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_operation_mode_typedef_t#

sl_adc_operation_mode_typedef_t

Enumeration for ADC operation mode.

Enumerator
SL_ADC_FIFO_MODE

Operation mode as FIFO mode.

SL_ADC_STATIC_MODE

Operation mode as static mode.

SL_ADC_OPERATION_MODE_LAST

Last member of enum for validation.


Definition at line 92 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_dma_type_typedef_t#

sl_adc_dma_type_typedef_t

Enumeration for ADC DMA type.

Enumerator
SL_ADC_INTERNAL_DMA

Internal DMA type.

SL_ADC_EXTERNAL_DMA

External DMA type.

SL_ADC_DMA_TYPE_LAST

Last member of enum for validation.


Definition at line 101 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_channel_type_typedef_t#

sl_adc_channel_type_typedef_t

Enumeration for ADC channel selection modes.

Enumerator
SL_ADC_SINGLE_CHNL

Selects a single ADC channel (dynamic mode disabled).

SL_ADC_MULTI_CHNL

Selects multiple ADC channels (dynamic mode enabled).

SL_ADC_CHANNEL_TYPE_LAST

Last member of enum for validation.


Definition at line 110 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_channel_id_t#

sl_adc_channel_id_t

Enumeration for ADC channels.

Enumerator
SL_ADC_CHANNEL_1

ADC channel 1.

SL_ADC_CHANNEL_2

ADC channel 2.

SL_ADC_CHANNEL_3

ADC channel 3.

SL_ADC_CHANNEL_4

ADC channel 4.

SL_ADC_CHANNEL_5

ADC channel 5.

SL_ADC_CHANNEL_6

ADC channel 6.

SL_ADC_CHANNEL_7

ADC channel 7.

SL_ADC_CHANNEL_8

ADC channel 8.

SL_ADC_CHANNEL_9

ADC channel 9.

SL_ADC_CHANNEL_10

ADC channel 10.

SL_ADC_CHANNEL_11

ADC channel 11.

SL_ADC_CHANNEL_12

ADC channel 12.

SL_ADC_CHANNEL_13

ADC channel 13.

SL_ADC_CHANNEL_14

ADC channel 14.

SL_ADC_CHANNEL_15

ADC channel 15.

SL_ADC_CHANNEL_16

ADC channel 16.


Definition at line 119 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

Typedef Documentation#

sl_adc_channel_config_t#

typedef adc_ch_config_t sl_adc_channel_config_t

Renamed ADC channel configuration structure.


Definition at line 53 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_config_t#

typedef adc_config_t sl_adc_config_t

Renamed ADC configuration structure.


Definition at line 58 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_internal_config_t#

typedef adc_inter_config_t sl_adc_internal_config_t

Renamed ADC internal configuration structure.


Definition at line 63 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_adc_callback_t#

typedef void(* sl_adc_callback_t) (uint8_t channel, uint8_t event) )(uint8_t channel, uint8_t event)

Typedef for a user-provided callback function that is invoked upon the completion of an ADC sample.

Parameters
[in]channel

ADC channel number sl_adc_channel_id_t.

[in]event

ADC event for different interrupts.


Definition at line 72 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

Function Documentation#

sl_si91x_adc_configure_clock#

sl_status_t sl_si91x_adc_configure_clock (sl_adc_clock_config_t * clock_configuration)

To set the ADC peripheral clock and configure the PLL clock based on user-specified values in the clock configuration structure.

Parameters
[in]clock_configuration

Pointer to the clock structure variables ( sl_adc_clock_config_t)

This API configures the ADC clock. The ADC clock configurations include:

  • soc_pll_clock (Frequency range from 1 MHz to 180 MHz)

  • soc_pll_reference_clock (Frequency range from 15 MHz to 65 MHz)

  • division_factor (0 to 1023)

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured the clock.

    • SL_STATUS_FAIL (0x0001) - Function failed.

    • SL_STATUS_NOT_INITIALIZED (0x0011) - Clock is not initialized.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 202 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_init#

sl_status_t sl_si91x_adc_init (sl_adc_channel_config_t adc_channel_config, sl_adc_config_t adc_config, float vref_value)

To initialize the ADC peripheral.

Parameters
[in]adc_channel_config

ADC channels configuration structure variable, see sl_adc_channel_config_t.

[in]adc_config

ADC operation configuration structure variable, see sl_adc_config_t.

[in]vref_value

Reference voltage (range from 1.8V to 3.6V).

This API initializes the ADC by:

  • Setting the clock source.

  • Configuring the reference voltage.

  • Powering on the ADC block.

  • Calibrating the ADC offset and gain.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully initialized the ADC.

    • SL_STATUS_BUSY (0x0004) - The function is already active.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

    • SL_STATUS_INVALID_COUNT (0x002B) - Mismatch count.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 232 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_set_channel_configuration#

sl_status_t sl_si91x_adc_set_channel_configuration (sl_adc_channel_config_t adc_channel_config, sl_adc_config_t adc_config)

To configure the ADC channel parameters.

Parameters
[in]adc_channel_config

ADC channels configuration structure variable, see sl_adc_channel_config_t.

[in]adc_config

ADC configuration structure variable, see sl_adc_config_t.

This API configures the following parameters:

  • Number of channels

  • ADC operation mode (Static mode/FIFO mode)

  • Sample length

  • Input type (Single-ended/differential type)

  • Sampling rate (1 - 2.5 Msps (megasamples per second))

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured the ADC channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

For more information on status codes, see SL STATUS DOCUMENTATION.

Note

  • If Static mode is configured, the sample length should be '1'.


Definition at line 263 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_register_event_callback#

sl_status_t sl_si91x_adc_register_event_callback (sl_adc_callback_t callback_event)

To register the user callback function.

Parameters
[in]callback_event

Pointer to the function that should be called during an interrupt event, see sl_adc_callback_t.

This API registers a user-provided callback function that is invoked when an event occurs.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully registered the callback.

    • SL_STATUS_BUSY (0x0004) - Driver is busy.

    • SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.

For more information on status codes, see SL STATUS DOCUMENTATION.

Note

  • Before calling this function again, it is mandatory to call the sl_si91x_adc_unregister_event_callback function to unregister the callback; otherwise, it returns the SL_STATUS_BUSY error code.


Definition at line 290 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_unregister_event_callback#

void sl_si91x_adc_unregister_event_callback (void )

To unregister the user callback function.

Parameters
N/A

This API unregisters the callback function registered using sl_si91x_adc_register_event_callback. This function must be called before registering the callback again.


Definition at line 302 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_configure_channel_sampling_rate#

sl_status_t sl_si91x_adc_configure_channel_sampling_rate (sl_adc_internal_config_t adc_internal_config, uint8_t channel_num)

To configure the ADC sampling rate for the ADC channels.

Parameters
[in]adc_internal_config

ADC internal configuration structure for setting the sampling rate, see sl_adc_internal_config_t.

[in]channel_num

Channel number.

This API adjusts the channel offset and frequency for each channel to determine the sample rate. This API ensures that the Nyquist sampling rate criteria are met by setting the channel swallow factor to no less than '3'.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured the sampling rate.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 325 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_configure_ping_pong_memory_address#

sl_status_t sl_si91x_adc_configure_ping_pong_memory_address (sl_adc_internal_config_t adc_internal_config, uint8_t channel_num)

To configure the ADC ping and pong memory location and length.

Parameters
[in]adc_internal_config

ADC internal trigger configuration sl_adc_internal_config_t structure variable.

[in]channel_num

Channel number.

This API configures the ping and pong memory locations, as well as the ping and pong memory lengths. Applicable only for FIFO mode of ADC operation. FIFO mode has a dual-buffer cyclic mode that prevents data loss when the buffer is full. In dual-buffer cyclic mode, if the Ping buffer for a given channel is full, incoming sampled data is written into the Pong buffer, allowing the controller to read back samples from the Ping buffer during this period.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured ping and pong memory address and length.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 354 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_enable_ping_pong#

sl_status_t sl_si91x_adc_enable_ping_pong (uint8_t channel_num)

To enable ping-pong for the corresponding ADC channels.

Parameters
[in]channel_num

Channel number.

This API enables the ping-pong mode for the specified ADC channel. Ping-pong mode is applicable only for FIFO mode of ADC operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully enabled ping-pong for the given channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 379 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_disable_ping_pong#

sl_status_t sl_si91x_adc_disable_ping_pong (uint8_t channel_num)

To disable ping-pong for the corresponding ADC channels.

Parameters
[in]channel_num

Channel number.

This API disables the ping-pong mode for the specified ADC channel. Ping-pong mode is applicable only for FIFO mode of ADC operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully disabled the ping-pong for the given channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 405 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_internal_per_channel_dma_enable#

sl_status_t sl_si91x_adc_internal_per_channel_dma_enable (uint8_t channel_num)

To enable DMA for the corresponding ADC channels.

Parameters
[in]channel_num

Channel number.

This API enables DMA for the specified ADC channel. This is applicable only for FIFO mode of ADC operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully enabled DMA for the given channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 428 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_internal_per_channel_dma_disable#

sl_status_t sl_si91x_adc_internal_per_channel_dma_disable (uint8_t channel_num)

To disable DMA for the corresponding ADC channels.

Parameters
[in]channel_num

Channel number.

This API disables DMA for the specified ADC channel. This is applicable only for FIFO mode of ADC operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully disabled DMA for the given channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 454 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_configure_static_mode#

sl_status_t sl_si91x_adc_configure_static_mode (sl_adc_channel_config_t adc_channel_config, uint8_t channel_num)

To configure the ADC in Static Mode.

Parameters
[in]adc_channel_config

ADC channels configuration structure variable, see sl_adc_channel_config_t.

[in]channel_num

Channel number.

This API configures the ADC to static mode with the specified positive and negative input channels and input type.

Note

  • Applicable only for static mode of ADC operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured to static mode.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 480 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_configure_fifo_mode#

sl_status_t sl_si91x_adc_configure_fifo_mode (sl_adc_channel_config_t adc_channel_config, uint8_t channel_num)

To configure the ADC in FIFO Mode.

Parameters
[in]adc_channel_config

ADC channels configuration structure variable, see sl_adc_channel_config_t.

[in]channel_num

Channel number.

This API configures the ADC for FIFO mode, where it samples data from the ADC input and writes it to the FIFO buffer.

Note

  • Applicable only for FIFO mode of ADC operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured to FIFO mode.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 510 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_channel_enable#

sl_status_t sl_si91x_adc_channel_enable (uint8_t channel_num)

To enable the ADC channel.

Parameters
[in]channel_num

Channel number.

This API enables the ADC channel. Data will be sampled from the ADC only when the corresponding channel is enabled.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully enabled the given channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 532 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_channel_disable#

sl_status_t sl_si91x_adc_channel_disable (uint8_t channel_num)

To disable the ADC channel.

Parameters
[in]channel_num

Channel number.

This API stops data sampling when the corresponding channel is disabled.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully disabled the given channel.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 556 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_set_power_mode#

sl_status_t sl_si91x_adc_set_power_mode (POWER_STATE state)

To power on or off the ADC.

Parameters
[in]state

POWER_STATE type indicating whether to power on or off the ADC.

  • ADC_POWER_ON - Power up ADC power gates.

  • ADC_POWER_OFF - Power down ADC power gates.

This API powers up or powers down the ADC power gates based on the provided state.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully set the power mode.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 578 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_set_noise_average_mode#

sl_status_t sl_si91x_adc_set_noise_average_mode (boolean_t state)

To enable or disable the noise averaging mode for ADC.

Parameters
[in]state

1 - To enable bypass noise averaging mode, 0 - To disable bypass noise averaging mode.

This API enables or disables the noise averaging mode for the ADC. If bypass noise averaging is enabled, the sampled data will be more accurate. Disabling bypass noise averaging may cause an additional clock cycle latency.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Success.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 602 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_temperature_sensor_enable#

sl_status_t sl_si91x_adc_temperature_sensor_enable (void )

To enable the temperature sensor.

Parameters
N/A

This API enables the BJT-based temperature sensor as an input to the ADC.

Note

  • The operation mode of the ADC should be Static for this input selection. If the ADC input sample is obtained from a temperature sensor, the positive input selection value must be '23'.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully enabled the ADC temperature sensor.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 624 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_fifo_threshold_configuration#

sl_status_t sl_si91x_adc_fifo_threshold_configuration (sl_adc_config_t adc_config, sl_adc_fifo_thrld_config_t adc_fifo_threshold)

To configure ADC FIFO Threshold.

Parameters
[in]adc_config

ADC operation configuration structure variable, see sl_adc_config_t.

[in]adc_fifo_threshold

ADC FIFO structure variable like an empty FIFO, a full FIFO threshold level, see sl_adc_fifo_thrld_config_t.

This API configures the ADC FIFO threshold. The maximum FIFO depth is 16, and the threshold value can be configured to indicate when the FIFO is almost full or almost empty for ADC operations. This allows for setting either a "FIFO almost full" or "FIFO almost empty" threshold, depending on the specific requirements of ADC configuration.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured FIFO threshold.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 651 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_threshold_configuration#

sl_status_t sl_si91x_adc_threshold_configuration (sl_adc_threshold_config_t adc_threshold)

To configure the ADC threshold to compare threshold value with ADC data.

Parameters
[in]adc_threshold

ADC threshold configuration structure variable, see sl_adc_threshold_config_t.

This API configures the ADC threshold values for comparison with ADC data. This API applies when the ADC mode of operation is static.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully configured ADC threshold.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 674 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_read_data#

sl_status_t sl_si91x_adc_read_data (sl_adc_channel_config_t adcchconfig, uint8_t channel_num)

To read the ADC sample data for FIFO mode of operation.

Parameters
[in]adcchconfig

ADC channels configuration structure variable, see sl_adc_channel_config_t.

[in]channel_num

Channel number.

This API reads the ADC sample data when the ADC is configured in FIFO mode.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully read the data.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 700 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_read_data_static#

sl_status_t sl_si91x_adc_read_data_static (sl_adc_channel_config_t adc_channel_config, sl_adc_config_t adc_config, uint16_t * adc_value)

To read the ADC sampled data for static mode of operation.

Parameters
[in]adc_channel_config

ADC channels configuration structure variable, see sl_adc_channel_config_t.

[in]adc_config

ADC operation configuration structure variable, see sl_adc_config_t.

[out]adc_value

Store the reading data in adc_value.

This API reads the ADC sampled data when the ADC is configured in static mode.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully read the data.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch range.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 727 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_get_sampling_rate#

uint32_t sl_si91x_adc_get_sampling_rate (uint8_t channel_num)

To get the channel sampling rate value configured to ADC.

Parameters
[in]channel_num

Channel number.

This API retrieves the sampling rate value that is configured for the specified ADC channel.

Returns

  • uint32_t Sampling rate retrieved from the register.


Definition at line 747 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_deinit#

sl_status_t sl_si91x_adc_deinit (sl_adc_config_t adc_config)

To deinitialize the ADC.

Parameters
[in]adc_config

ADC operation configuration structure variable, see sl_adc_config_t.

This API deinitializes the ADC. If the DMA (Direct Memory Access) is enabled, it also deinitializes the DMA. It will power down the ADC block and disable the dynamic mode if FIFO mode of ADC operation is used.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully deinitialized the ADC.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 770 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_start#

sl_status_t sl_si91x_adc_start (sl_adc_config_t adc_config)

To start the ADC operation.

Parameters
[in]adc_config

ADC operation configuration structure variable, see sl_adc_config_t.

This API starts the signal to the ADC controller and enables dynamic mode if FIFO mode of ADC operation is configured.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully started the ADC.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 793 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_stop#

sl_status_t sl_si91x_adc_stop (sl_adc_config_t adc_config)

To stop the ADC operation.

Parameters
[in]adc_config

ADC operation configuration structure variable, see sl_adc_config_t.

This API stops the signal to the ADC controller and disables dynamic mode if FIFO mode of ADC operation is configured.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Successfully stopped the ADC operation.

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 818 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

sl_si91x_adc_get_version#

sl_adc_version_t sl_si91x_adc_get_version (void )

To get the ADC version.

Parameters
N/A

This API returns the release, major, and minor version of the ADC.

Note

  • Returns the API version of the ADC.

Returns


Definition at line 830 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

Macro Definition Documentation#

SL_INTERNAL_DMA#

#define SL_INTERNAL_DMA
Value:
INTERNAL_DMA

Internal DMA event.


Definition at line 76 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

SL_ADC_STATIC_MODE_EVENT#

#define SL_ADC_STATIC_MODE_EVENT
Value:
ADC_STATIC_MODE_CALLBACK

Static mode event.


Definition at line 77 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h

SIGN_BIT#

#define SIGN_BIT
Value:
BIT(11)

Sign/magnitude bit.


Definition at line 78 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_adc.h