Analog to Digital Converter#


Introduction#

ADC stands for Analog-to-Digital Converter. An ADC is a peripheral or component of a controller that transforms analog signals (continuous voltage levels) into digital data (discrete binary values) that the controller can handle.

  • This translation allows the controller to communicate with analog sensors or signals, such as temperature sensors, light sensors, or analog joysticks, in digital systems or apps.

  • Analog-to-Digital Converters (ADCs) are integral components in controllers across various applications. Here are some common use cases:

  1. Sensor Data Acquisition

  2. Audio Processing

  3. Instrumentation and Measurement

  4. Motor Control

  5. Battery Monitoring and Management

  6. Feedback Control Systems etc.,


Configuration#

Configuring an Analog-to-Digital Converter (ADC) typically involves several parameters and settings to ensure proper operation and accurate conversion of analog signals into digital data. The specific configuration details may vary depending on the ADC hardware and the requirements of your application, but here are some few configurable items:

  • For more information on configuring available parameters refer to the respective peripheral example readme document.


Usage#

The common ADC functions can be used after the ADC Structures are specified, passing an instance of sl_adc_config_t and sl_adc_channel_config_t. These functions will initiate and configure the ADC below, which is the flow for implementation.

  1. sl_si91x_adc_configure_clock

  2. sl_si91x_adc_init

  3. sl_si91x_adc_set_channel_configuration

  4. sl_si91x_adc_register_event_callback

  5. sl_si91x_adc_start

  6. sl_si91x_adc_read_data

  7. 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 type.

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 multiple channel selection.

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 channel.

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 user supplied callback function, which is called when ADC sample completes.

Variables#

uint16_t

Threshold_1.

uint16_t

Threshold_2.

uint8_t *

Threshold_1 condition like Equal, Grater, Lesser.

uint8_t *

Threshold_2 condition like Equal, Grater, Lesser.

uint8_t
uint8_t

Number of channel enable.

uint8_t

AEMPTY Threshold.

uint8_t

AFULL Threshold.

uint8_t

Internal or External DMA.

uint16_t

Division Factor.

uint32_t

SoC PLL clock frequency.

uint32_t

SoC PLL reference clock frequency.

uint8_t

Release version number.

uint8_t

sqa version number

uint8_t

dev version number

Functions#

sl_status_t
sl_si91x_adc_configure_clock(sl_adc_clock_config_t *clock_configuration)

Set the clock for the ADC peripheral and configure the PLL clock to the value specified by the user 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)

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)

Configures the ADC channel parameters.

sl_status_t
sl_si91x_adc_register_event_callback(sl_adc_callback_t callback_event)

Register the user callback function.

void

Un-register 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)

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)

Configure the ADC ping and pong memory location and length.

sl_status_t
sl_si91x_adc_enable_ping_pong(uint8_t channel_num)

Enable ping pong for the corresponding ADC channels.

sl_status_t
sl_si91x_adc_disable_ping_pong(uint8_t channel_num)

Disable ping pong for the corresponding ADC channels.

sl_status_t

Enable DMA for the corresponding ADC channels.

sl_status_t

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)

This API will 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)

Configure the ADC in FIFO Mode.

sl_status_t
sl_si91x_adc_channel_enable(uint8_t channel_num)

This API will enables the ADC channel.

sl_status_t
sl_si91x_adc_channel_disable(uint8_t channel_num)

Disable the ADC channel.

sl_status_t
sl_si91x_adc_set_power_mode(POWER_STATE state)

This API will Power On and off for ADC.

sl_status_t

Enable or Disable the Noise averaging mode to ADC.

sl_status_t

This API will 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)

Configuring ADC fifo threshold.

sl_status_t
sl_si91x_adc_threshold_configuration(sl_adc_threshold_config_t adc_threshold)

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)

Read the ADC samples 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)

This API will 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 which is configured to ADC.

sl_status_t
sl_si91x_adc_deinit(sl_adc_config_t adc_config)

Uninitialize the ADC.

sl_status_t
sl_si91x_adc_start(sl_adc_config_t adc_config)

Enable the signal to ADC controller and enable the dynamic mode for FIFO mode of ADC operation.

sl_status_t
sl_si91x_adc_stop(sl_adc_config_t adc_config)

Stop the signal for ADC controller and disable the dynamic mode if FIFO mode of ADC operation.

Get the ADC version.

Macros#

#define
SL_INTERNAL_DMA INTERNAL_DMA
#define
SL_ADC_STATIC_MODE_EVENT ADC_STATIC_MODE_CALLBACK
#define
SIGN_BIT BIT(11)

Enumeration Documentation#

sl_adc_input_type_typedef_t#

sl_adc_input_type_typedef_t

Enumeration for ADC input type.

Enumerator
SL_ADC_SINGLE_ENDED

Input type single ended.

SL_ADC_DIFFERENTIAL

Input type differential.

SL_ADC_INPUT_TYPE_LAST

Last member of enum for validation.


Definition at line 67 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 74 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 81 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 multiple channel selection.

Enumerator
SL_ADC_SINGLE_CHNL

Dynamic mode disable.

SL_ADC_MULTI_CHNL

Dynamic mode enable.

SL_ADC_CHANNEL_TYPE_LAST

Last member of enum for validation.


Definition at line 88 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 channel.

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 95 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 48 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 49 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 50 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 user supplied callback function, which is called when ADC sample completes.

Parameters
[in]channel

ADC channel number

[in]event

ADC event for different interrupt.


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

Variable Documentation#

threshold1#

uint16_t sl_adc_threshold_config_t::threshold1

Threshold_1.


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

threshold2#

uint16_t sl_adc_threshold_config_t::threshold2

Threshold_2.


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

threshold1_cond#

uint8_t* sl_adc_threshold_config_t::threshold1_cond

Threshold_1 condition like Equal, Grater, Lesser.


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

threshold2_cond#

uint8_t* sl_adc_threshold_config_t::threshold2_cond

Threshold_2 condition like Equal, Grater, Lesser.


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

range#

uint8_t sl_adc_threshold_config_t::range

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

num_of_channel_en#

uint8_t sl_adc_fifo_thrld_config_t::num_of_channel_en

Number of channel enable.


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

a_empty_threshold#

uint8_t sl_adc_fifo_thrld_config_t::a_empty_threshold

AEMPTY Threshold.


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

a_full_threshold#

uint8_t sl_adc_fifo_thrld_config_t::a_full_threshold

AFULL Threshold.


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

dma_type#

uint8_t sl_adc_fifo_thrld_config_t::dma_type

Internal or External DMA.


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

division_factor#

uint16_t sl_adc_clock_config_t::division_factor

Division Factor.


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

soc_pll_clock#

uint32_t sl_adc_clock_config_t::soc_pll_clock

SoC PLL clock frequency.


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

soc_pll_reference_clock#

uint32_t sl_adc_clock_config_t::soc_pll_reference_clock

SoC PLL reference clock frequency.


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

release#

uint8_t sl_adc_version_t::release

Release version number.


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

major#

uint8_t sl_adc_version_t::major

sqa version number


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

minor#

uint8_t sl_adc_version_t::minor

dev version number


Definition at line 142 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)

Set the clock for the ADC peripheral and configure the PLL clock to the value specified by the user in the clock configuration structure.

Parameters
[in]clock_configuration

: clock structure variables ( sl_adc_clock_config_t)

This API will set the clock for ADC controller.

  • The ADC clock configurations are listed below:

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

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

    • division_factor (0 to 63). Returns

      • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

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

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

    • SL_STATUS_FAIL (0x0001) - The function is failed

    • SL_STATUS_NOT_INITIALIZED (0x0011) - Clock is not initialized


Definition at line 164 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)

Initialize the ADC peripheral.

Parameters
[in]adc_channel_config

: ADC channels configuration structure variable

[in]adc_config

: ADC operation configuration structure variable

[in]vref_value

: Reference voltage(reange from 1.8v to 3.6v)

The ADC clock source sets and passes the Vref value to set the reference voltage for the ADC, based on the sampling rate. Power on the ADC block and calibrate the ADC offset and gain.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

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

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

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

    • SL_STATUS_INVALID_COUNT (0x002B) - Mismatch count

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range


Definition at line 183 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)

Configures the ADC channel parameters.

Parameters
[in]adc_channel_config

: ADC channels configuration structure variable.

[in]adc_config

: ADC operation configuration structure variable.

  • The configurations are listed below:

    • Number of channel

    • ADC operation mode (Static mode/FIFO mode)

    • Sample Length

    • Input Type (Single ended/ differential type)

    • Sampling Rate (1 - 2.5 Ms/Sec).

      • Pre-conditions:

sl_si91x_adc_configure_clock

  • sl_si91x_adc_initReturns

    • status 0 if successful, else error code as follow

      • SL_STATUS_OK (0x0000) - Success

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

      • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

      • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range

    Note

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


Definition at line 206 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)

Register the user callback function.

Parameters
[in]callback_event

Pointer to the function which needs to be called at the time of interrupt

When an event occurs, the function with the specified parameter is invoked. To unregister the callback, use the sl_si91x_adc_unregister_event_callback function before invoking this function again; otherwise, the error code SL_STATUS_BUSY will be returned.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

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

    • SL_STATUS_BUSY (0x0004) - Driver is busy


Definition at line 224 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 )

Un-register the user callback function.

Parameters
N/A

It is mandatory to call this function before registering the callback again.

Returns

  • none


Definition at line 234 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)

Configure the ADC sampling rate for the ADC channels.

Parameters
[in]adc_internal_config

: Channel offset and frequency for each channel to set sampling rate.

[in]channel_num

: Channel number

It adjusts the channel offset and frequency for each channel to determine the sample rate. To meet the Nyquist sampling rate criteria, the channel swallow factor must be not less than '3'.

Returns

  • sl_status_t : Returns 'SL_STATUS_OK' on successful execution.


Definition at line 248 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)

Configure the ADC ping and pong memory location and length.

Parameters
[in]adc_internal_config

: ADC internal trigger configuration structure variable.

[in]channel_num

: Channel number

Configure the ping and pong memory locations, as well as the ping and pong memory lengths. It is only applicable for the 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. This explains why each channel has two start addresses, two buffer lengths, and two valid signals.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 270 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)

Enable ping pong for the corresponding ADC channels.

Parameters
[in]channel_num

: Channel number

Note

  • This will be applicable only for FIFO mode of ADC operation.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 286 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)

Disable ping pong for the corresponding ADC channels.

Parameters
[in]channel_num

: Channel number

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 302 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)

Enable DMA for the corresponding ADC channels.

Parameters
[in]channel_num

: Channel number

Note

  • This will be applicable only for FIFO mode of ADC operation.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 316 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)

Disable DMA for the corresponding ADC channels.

Parameters
[in]channel_num

: Channel number

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 332 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)

This API will configure the ADC in Static Mode.

Parameters
[in]adc_channel_config

: ADC channels configuration structure variable.

[in]channel_num

: Channel number

It could be configured to choose positive and negative input channels, as well as input type. Note

  • This will be applicable only for static mode of ADC operation.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range


Definition at line 349 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)

Configure the ADC in FIFO Mode.

Parameters
[in]adc_channel_config

: ADC channels configuration structure variable.

[in]channel_num

: Channel number

ADC data input will be sampled and written to the ADC FIFO in this mode. Note

  • This will be applicable only for FIFO mode of ADC operation.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range


Definition at line 370 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)

This API will enables the ADC channel.

Parameters
[in]channel_num

: Channel number

Data will be sampled from ADC only when corresponding channel is enabled.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 384 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)

Disable the ADC channel.

Parameters
[in]channel_num

: Channel number

Data sampling will be stoped when corresponding channel is disabled.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 400 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)

This API will Power On and off for ADC.

Parameters
[in]state

: ADC_POWER_ON - To powerup adc powergates, ADC_POWER_OFF - To powerdown adc powergates ( POWER_STATE )

Returns

  • status 0 if successful,

    • SL_STATUS_OK (0x0000) - Success


Definition at line 413 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)

Enable or Disable the Noise averaging mode to ADC.

Parameters
[in]state

: 1 - To enable bypass the noise averaging mode, 0 - To disable bypass the noise averaging mode

If bypass noise averaging is enabled, the sampled data will be more accurate. If bypass the noise averaging disable would cause '1' additional clock cycle Latency.

Returns

  • Returns 'SL_STATUS_OK' on successful execution.


Definition at line 427 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 )

This API will enable the temperature sensor.

Parameters
N/A

Enable BJT based Temperature sensor as an input to ADC. Note

  • - Operation mode of 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

  • Returns 'SL_STATUS_OK' on successful execution.


Definition at line 441 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)

Configuring ADC fifo threshold.

Parameters
[in]adc_config

: ADC operation configuration structure variable.

[in]adc_fifo_threshold

: ADC fifo structure variable like an empty fifo, a full fifo threshold level. ( sl_adc_fifo_thrld_config_t )

The maximum FIFO depth is 16, and the threshold value may be configured.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range


Definition at line 458 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)

Configure the ADC threshold to compare threshold value with ADC data.

Parameters
[in]adc_threshold

: ADC threshold configuration structure variables.

Note

  • This API applies when the ADC mode of operation is static.

Returns

  • Returns 'SL_STATUS_OK' on successful execution.


Definition at line 471 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)

Read the ADC samples data for FIFO mode of operation.

Parameters
[in]adcchconfig

: ADC channels configuration structure variable.

[in]channel_num

: Channel number

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range


Definition at line 488 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)

This API will read the ADC sampled data for static mode of operation.

Parameters
[in]adc_channel_config

: ADC channels configuration structure variable.

[in]adc_config

: ADC operation configuration structure variable.

[out]adc_value

: Store the reading data on adc_value.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid

    • SL_STATUS_INVALID_RANGE (0x0028) - Mismatch Range


Definition at line 506 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 which is configured to ADC.

Parameters
[in]channel_num

: Channel number

Returns

  • Returns sampling rate what it get from register


Definition at line 520 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)

Uninitialize the ADC.

Parameters
[in]adc_config

: ADC operation configuration structure variable.

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

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 535 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)

Enable the signal to ADC controller and enable the dynamic mode for FIFO mode of ADC operation.

Parameters
[in]adc_config

: ADC operation configuration structure variable.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 550 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)

Stop the signal for ADC controller and disable the dynamic mode if FIFO mode of ADC operation.

Parameters
[in]adc_config

: ADC operation configuration structure variable.

Returns

  • status 0 if successful, else error code as follow

    • SL_STATUS_OK (0x0000) - Success

    • SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid


Definition at line 566 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 )

Get the ADC version.

Parameters
N/A

Note

  • It returns the API version of ADC.

Returns


Definition at line 574 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

Definition at line 62 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

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

SIGN_BIT#

#define SIGN_BIT
Value:
BIT(11)

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