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.


ADCs are essential in a wide range of applications, including:
Sensor Data Acquisition: Converting sensor outputs into digital form for processing.
Audio Processing: Digitizing analog audio signals for further manipulation.
Instrumentation and Measurement: Precise measurement of analog signals.
Motor Control: Monitoring and controlling motor performance.
Battery Monitoring and Management: Ensuring optimal battery usage.
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_tstructure. Use this structure with the APIsl_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_tstructure. After configuring this structure, callsl_si91x_adc_set_channel_configuration()to set the channel parameters.
For more detailed configuration information, see the specific peripheral example README documents.
After defining the ADC configuration structures, use the following functions to initialize and control the ADC module:
Static Mode (non-DMA) typical sequence:
Initialize ADC: sl_si91x_adc_init
Set Channel Configuration: sl_si91x_adc_set_channel_configuration
Register Event Callback: sl_si91x_adc_register_event_callback
Start ADC: sl_si91x_adc_start
Read Data: sl_si91x_adc_read_data_static
Deinitialize ADC: sl_si91x_adc_deinit
FIFO Mode with DMA typical sequence:
Initialize ADC: sl_si91x_adc_init
Set Channel Configuration: sl_si91x_adc_set_channel_configuration
Configure Ping/Pong Memory: sl_si91x_adc_configure_ping_pong_memory_address
Enable Ping/Pong: sl_si91x_adc_enable_ping_pong
Enable Channel: sl_si91x_adc_channel_enable
Enable Internal DMA: sl_si91x_adc_internal_per_channel_dma_enable
Configure FIFO Mode: sl_si91x_adc_configure_fifo_mode
Register Event Callback: sl_si91x_adc_register_event_callback
Start ADC: sl_si91x_adc_start
Read Data: sl_si91x_adc_read_data
Deinitialize ADC: sl_si91x_adc_deinit
Ping/Pong Buffer Configuration for FIFO Mode#
When using FIFO mode with internal DMA, you must configure Ping/Pong buffers for dual-buffer cyclic operation:
Structure fields for Ping/Pong addresses:
sl_adc_channel_config_t (used during channel configuration):
chnl_ping_address[channel]: DMA Ping buffer base addresschnl_pong_address[channel]: DMA Pong buffer base addressrx_buf[channel]: CPU-accessible buffer for reading samples
sl_adc_internal_config_t (used with configure_ping_pong_memory_address API):
ping_addr[channel]: Ping buffer base addresspong_addr[channel]: Pong buffer base addressping_length[channel]: Ping buffer length in samplespong_length[channel]: Pong buffer length in samplesinput_type[channel]: Input type (single-ended/differential)num_of_samples[channel]: Number of samples per conversion
Configuration Methods:
Method 1 (Recommended): Use the dedicated ping/pong configuration API:
sl_adc_internal_config_t internal_config = {0};
uint8_t channel = 0;
Configure ping/pong parameters
internal_config.ping_addr[channel] = 0x24060000;
internal_config.pong_addr[channel] = 0x24060400;
internal_config.ping_length[channel] = 256;
internal_config.pong_length[channel] = 256;
internal_config.input_type[channel] = SL_ADC_SINGLE_ENDED;
internal_config.num_of_samples[channel] = 256;
sl_si91x_adc_configure_ping_pong_memory_address(internal_config, channel);
sl_si91x_adc_enable_ping_pong(channel);
Method 2: Pre-populate channel config before set_channel_configuration:
sl_adc_channel_config_t channel_config = {0};
uint8_t channel = 0;
Pre-populate ping/pong addresses
channel_config.chnl_ping_address[channel] = 0x24060000;
channel_config.chnl_pong_address[channel] = 0x24060400;
channel_config.rx_buf[channel] = my_cpu_buffer;
sl_si91x_adc_set_channel_configuration(channel_config, adc_config);
sl_si91x_adc_enable_ping_pong(channel);
Important Notes:
Ping/Pong buffers are NOT used in Static mode (non-DMA operation)
Address ranges must be valid ULP SRAM locations (typically 0x24060000 - 0x24061B00)
Buffer sizes should accommodate the expected number of samples per channel
Always enable ping/pong mode after configuring the addresses
Usage#
After defining the ADC configuration structures, use the following functions to initialize and control the ADC module:
Initialize ADC: sl_si91x_adc_init
Set Channel Configuration: sl_si91x_adc_set_channel_configuration
Register Event Callback: sl_si91x_adc_register_event_callback
Start ADC: sl_si91x_adc_start
Read Data: sl_si91x_adc_read_data
Deinitialize ADC: sl_si91x_adc_deinit
Modules#
Enumerations#
Enumeration for ADC input types.
Enumeration for ADC operation mode.
Enumeration for ADC DMA type.
Enumeration for ADC channel selection modes.
Enumeration for ADC channels.
Typedefs#
Renamed ADC channel configuration.
Renamed ADC configuration.
Renamed ADC internal configuration.
Typedef for a user-provided callback function that is invoked upon the completion of an ADC sample.
Functions#
To set the ADC peripheral clock and configure the PLL clock based on user-specified values in the clock configuration structure.
To initialize the ADC peripheral.
To configure the ADC channel parameters.
To register the user callback function.
To unregister the user callback function.
To configure the ADC sampling rate for the ADC channels.
To configure the ADC ping and pong memory location and length.
To enable ping-pong for the corresponding ADC channels.
To disable ping-pong for the corresponding ADC channels.
To enable DMA for the corresponding ADC channels.
To disable DMA for the corresponding ADC channels.
To configure the ADC in Static Mode.
To configure the ADC in FIFO Mode.
To enable the ADC channel.
To disable the ADC channel.
To power on or off the ADC.
To enable or disable the noise averaging mode for ADC.
To enable the temperature sensor.
To configure ADC FIFO Threshold.
To configure the ADC threshold to compare threshold value with ADC data.
To read the ADC sample data for FIFO mode of operation.
To read the ADC sampled data for static mode of operation.
To get the channel sampling rate value configured to ADC.
To deinitialize the ADC.
To start the ADC operation.
To stop the ADC operation.
To get the ADC version.
To get chip operating voltage (VBATT).
Macros#
Internal DMA event.
Static mode event.
Sign/magnitude bit.
To check condition in config file, this macro value '1' should constant.
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. |
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. |
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. |
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. |
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. |
Typedef Documentation#
sl_adc_channel_config_t#
typedef adc_ch_config_t sl_adc_channel_config_t
Renamed ADC channel configuration.
This contains channel-specific configuration parameters including Ping/Pong DMA buffer addresses for FIFO mode operation. Key fields for FIFO + DMA:
chnl_ping_address[channel] : Ping buffer base address for DMA
chnl_pong_address[channel] : Pong buffer base address for DMA
rx_buf[channel] : CPU-accessible buffer pointer
num_of_samples[channel] : Number of samples per conversion
sampling_rate[channel] : Sampling rate for the channel
input_type[channel] : Input type (single-ended/differential)
sl_adc_config_t#
typedef adc_config_t sl_adc_config_t
Renamed ADC configuration.
This contains global ADC operation parameters:
operation_mode : Static mode or FIFO mode
num_of_channel_enable : Number of channels to enable
sl_adc_internal_config_t#
typedef adc_inter_config_t sl_adc_internal_config_t
Renamed ADC internal configuration.
This is used specifically with sl_si91x_adc_configure_ping_pong_memory_address() for detailed Ping/Pong buffer configuration in FIFO mode. Key fields:
ping_addr[channel] : Ping buffer base address
pong_addr[channel] : Pong buffer base address
ping_length[channel] : Ping buffer length in samples
pong_length[channel] : Pong buffer length in samples
input_type[channel] : Input type for the channel
num_of_samples[channel]: Number of samples per conversion
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| [in] | channel | ADC channel number sl_adc_channel_id_t. | |
| [in] | event | ADC event for different interrupts. |
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_clock_config_t * | [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 to 180 MHz)soc_pll_reference_clock(Frequency range from 15 to 65 MHz)division_factor(0 to 1023)
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured the clock.
SL_STATUS_FAIL - Function failed.
SL_STATUS_NOT_INITIALIZED - Clock is not initialized.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_NULL_POINTER - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_channel_config_t | [in] | adc_channel_config | ADC channels configuration structure variable, see sl_adc_channel_config_t. |
| sl_adc_config_t | [in] | adc_config | ADC operation configuration structure variable, see sl_adc_config_t. |
| float | [in] | vref_value | Reference voltage (range from 1.8 to 3.6 V). |
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.
Note
For FIFO mode with DMA, Ping/Pong buffer addresses are NOT configured by this function. Configure them separately using sl_si91x_adc_configure_ping_pong_memory_address() after initialization, or pre-populate the sl_adc_channel_config_t.chnl_ping_address[] and sl_adc_channel_config_t.chnl_pong_address[] fields before calling sl_si91x_adc_set_channel_configuration().
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully initialized the ADC.
SL_STATUS_BUSY - The function is already active.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_NULL_POINTER - The parameter is a null pointer.
SL_STATUS_INVALID_RANGE - Mismatch range.
SL_STATUS_INVALID_COUNT - Mismatch count.
SL_STATUS_INVALID_CONFIGURATION - Invalid configuration.(please refer below note)
SL_STATUS_NOT_INITIALIZED - Module is not initialized.
Note
- Add UC channels sequentially starting from 1, and ensure that the number of instances added matches the number of channels configured in the UC. Otherwise, it will return the error code SL_STATUS_INVALID_CONFIGURATION.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_channel_config_t | [in] | adc_channel_config | ADC channels configuration structure variable, see sl_adc_channel_config_t. |
| sl_adc_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))
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured the ADC channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_NULL_POINTER - The parameter is a null pointer.
SL_STATUS_INVALID_RANGE - Mismatch range.
For more information on status codes, see SL STATUS DOCUMENTATION.
Note
If Static mode is configured, the sample length should be '1'.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_callback_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully registered the callback.
SL_STATUS_BUSY - Driver is busy.
SL_STATUS_NULL_POINTER - 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.
sl_si91x_adc_unregister_event_callback#
void sl_si91x_adc_unregister_event_callback (void )
To unregister the user callback function.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | 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.
Pre-condition:
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_internal_config_t | [in] | adc_internal_config | ADC internal configuration structure for setting the sampling rate, see sl_adc_internal_config_t. |
| uint8_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'.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured the sampling rate.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_internal_config_t | [in] | adc_internal_config | ADC internal trigger configuration sl_adc_internal_config_t structure variable. |
| uint8_t | [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.
Required fields in sl_adc_internal_config_t structure (for channel index 'channel_num'):
ping_addr[channel_num] : Ping buffer base address (ULP SRAM absolute or offset address)
pong_addr[channel_num] : Pong buffer base address (same addressing scheme as ping_addr)
ping_length[channel_num] : Ping buffer length in samples
pong_length[channel_num] : Pong buffer length in samples
input_type[channel_num] : Input type for the channel (single-ended/differential)
num_of_samples[channel_num] : Number of samples per conversion
Address ranges:
Absolute ULP SRAM addresses must lie within [0x24060000 .. 0x24061B00]
If using relative/offset addressing, offsets must not exceed the valid range limits
Pre-conditions:
Typical usage sequence after this function:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured ping and pong memory address and length.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully enabled ping-pong for the given channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully disabled the ping-pong for the given channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | channel_num | Channel number. |
This API enables DMA for the specified ADC channel. This is applicable only for FIFO mode of ADC operation.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully enabled DMA for the given channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | channel_num | Channel number. |
This API disables DMA for the specified ADC channel. This is applicable only for FIFO mode of ADC operation.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully disabled DMA for the given channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_channel_config_t | [in] | adc_channel_config | ADC channels configuration structure variable, see sl_adc_channel_config_t. |
| uint8_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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured to static mode.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_INVALID_RANGE - Mismatch range.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_channel_config_t | [in] | adc_channel_config | ADC channels configuration structure variable, see sl_adc_channel_config_t. |
| uint8_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.
Pre-conditions:
Configure Ping/Pong DMA buffers using EITHER:
Method 1 (Recommended): sl_si91x_adc_configure_ping_pong_memory_address() followed by sl_si91x_adc_enable_ping_pong(), OR
Method 2: Pre-populate sl_adc_channel_config_t.chnl_ping_address[] and sl_adc_channel_config_t.chnl_pong_address[] before calling sl_si91x_adc_set_channel_configuration() followed by sl_si91x_adc_enable_ping_pong()
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured to FIFO mode.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_INVALID_RANGE - Mismatch range.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_adc_channel_enable#
sl_status_t sl_si91x_adc_channel_enable (uint8_t channel_num)
To enable the ADC channel.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully enabled the given channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_adc_channel_disable#
sl_status_t sl_si91x_adc_channel_disable (uint8_t channel_num)
To disable the ADC channel.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | channel_num | Channel number. |
This API stops data sampling when the corresponding channel is disabled.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully disabled the given channel.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| POWER_STATE | [in] | state | POWER_STATE type indicating whether to power on or off the ADC.
|
This API powers up or powers down the ADC power gates based on the provided state.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully set the power mode.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| boolean_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Success.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_adc_temperature_sensor_enable#
sl_status_t sl_si91x_adc_temperature_sensor_enable (void )
To enable the temperature sensor.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | 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'.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully enabled the ADC temperature sensor.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_config_t | [in] | adc_config | ADC operation configuration structure variable, see sl_adc_config_t. |
| sl_adc_fifo_thrld_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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured FIFO threshold.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_INVALID_RANGE - Mismatch range.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_threshold_config_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully configured ADC threshold.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_channel_config_t | [in] | adcchconfig | ADC channels configuration structure variable, see sl_adc_channel_config_t. |
| uint8_t | [in] | channel_num | Channel number. |
This API reads the ADC sample data when the ADC is configured in FIFO mode.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully read the data.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_INVALID_RANGE - Mismatch range.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_channel_config_t | [in] | adc_channel_config | ADC channels configuration structure variable, see sl_adc_channel_config_t. |
| sl_adc_config_t | [in] | adc_config | ADC operation configuration structure variable, see sl_adc_config_t. |
| uint16_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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully read the data.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
SL_STATUS_INVALID_RANGE - Mismatch range.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [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.
sl_si91x_adc_deinit#
sl_status_t sl_si91x_adc_deinit (sl_adc_config_t adc_config)
To deinitialize the ADC.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_config_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully deinitialized the ADC.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_adc_start#
sl_status_t sl_si91x_adc_start (sl_adc_config_t adc_config)
To start the ADC operation.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_config_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully started the ADC.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_adc_stop#
sl_status_t sl_si91x_adc_stop (sl_adc_config_t adc_config)
To stop the ADC operation.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_adc_config_t | [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.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK - Successfully stopped the ADC operation.
SL_STATUS_INVALID_PARAMETER - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_adc_get_version#
sl_adc_version_t sl_si91x_adc_get_version (void )
To get the ADC version.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
This API returns the release, major, and minor version of the ADC.
Note
Returns the API version of the ADC.
Returns
sl_adc_version_t Structure containing the version information, see sl_adc_version_t.
sl_si91x_adc_get_chip_voltage#
float sl_si91x_adc_get_chip_voltage (void )
To get chip operating voltage (VBATT).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
This API reads the operating voltage of chip i.e vbatt voltage.
If the operating voltage is less than 2.4V then this api switches the input voltage supply from SCDC to HPLDO.
then returns the chip operating voltage (VBATT) in volts.
Returns
chip operating voltage(VBATT) in volts.