Analog Peripherals API Reference#

This reference summarizes the analog-to-digital converter (ADC) and digital-to-analog converter (DAC) application programming interfaces (APIs) available on the SiWx917 through the WiSeConnect software development kit (SDK).

Public APIs#

These APIs support initialization, configuration, data acquisition, waveform generation, power management, and callback-based event handling.

For complete definitions, enumerations, and examples, see the following documentation:

Callback and Notification APIs#

The callback and notification APIs enable applications to handle ADC and DAC events asynchronously. These mechanisms improve efficiency by allowing the system to process other tasks while peripheral operations complete in the background.

ADC Callback System#

The ADC driver supports event-driven operation through a registered callback function that is invoked when conversion-related events occur.

Callback type definition:

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

Description:

Defines the function prototype used by the ADC driver to notify the application of ADC-related events.

Parameters:

  • channel (uint8_t, in): The ADC channel that generated the event.

  • event (uint8_t, in): The event code that identifies the ADC event type.

Registering and unregistering the callback:

sl_status_t sl_si91x_adc_register_event_callback(sl_adc_callback_t callback_event);
void sl_si91x_adc_unregister_event_callback(void);

Example:

void adc_event_handler(uint8_t channel, uint8_t event) {
  if (event == SL_ADC_STATIC_MODE_EVENT) {
    // Handle static mode conversion complete
  } else if (event == SL_INTERNAL_DMA) {
    // Handle FIFO mode DMA complete
  }
}

// Register callback
sl_si91x_adc_register_event_callback(adc_event_handler);

DAC Callback System#

The DAC driver also uses callback functions to notify the application when DAC events occur and enables responsive and efficient data handling.

Callback type definition:

typedef void (*sl_dac_callback_t)(uint8_t event);

Description:

Defines the callback function prototype used by the DAC driver to report DAC-specific events.

Parameters:

  • event(uint8_t, in) The DAC event type identifier.

Registering and unregistering the callback:

sl_status_t sl_si91x_dac_register_event_callback(sl_dac_callback_t callback_event);
sl_status_t sl_si91x_dac_unregister_event_callback(void);

Example:

void dac_event_handler(uint8_t event) {
  if (event == SL_DAC_STATIC_MODE_EVENT) {
    // Handle static mode event
  } else if (event == SL_DAC_FIFO_MODE_EVENT) {
    // Handle FIFO mode event
  }
}

// Register callback
sl_si91x_dac_register_event_callback(dac_event_handler);

Core API Functions#

The following sections summarize key APIs for initialization, configuration, operation, and data management for ADC and DAC peripherals.

ADC Core APIs#

The ADC API set provides functions for initialization, clock configuration, data conversion, and channel management.

Clock Configuration#

sl_status_t sl_si91x_adc_configure_clock(sl_adc_clock_config_t *clock_configuration);

Initialization and Configuration#

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

sl_status_t sl_si91x_adc_set_channel_configuration(sl_adc_channel_config_t adc_channel_config,
                                                   sl_adc_config_t adc_config);

Operation Control#

sl_status_t sl_si91x_adc_start(sl_adc_config_t adc_config);
sl_status_t sl_si91x_adc_stop(sl_adc_config_t adc_config);
sl_status_t sl_si91x_adc_deinit(sl_adc_config_t adc_config);

Data Reading#

sl_status_t sl_si91x_adc_read_data(sl_adc_channel_config_t adcchconfig, uint8_t channel_num);
sl_status_t sl_si91x_adc_read_data_static(sl_adc_channel_config_t adc_channel_config,
                                          uint8_t channel_num,
                                          uint16_t *adc_value);

Channel Control#

sl_status_t sl_si91x_adc_channel_enable(uint8_t channel_num);
sl_status_t sl_si91x_adc_channel_disable(uint8_t channel_num);

DAC Core APIs#

The DAC API set provides initialization, configuration, and runtime control functions for analog signal output.

Initialization and Configuration#

sl_status_t sl_si91x_dac_init(sl_dac_clock_config_t *dac_clock);
sl_status_t sl_si91x_dac_set_configuration(sl_dac_config_t dac_config, float vref_value);

Operation Control#

sl_status_t sl_si91x_dac_start(void);
sl_status_t sl_si91x_dac_stop(void);
sl_status_t sl_si91x_dac_deinit(void);

Data Writing#

sl_status_t sl_si91x_dac_write_data(int16_t *data, uint16_t length);
sl_status_t sl_si91x_dac_rewrite_data(int16_t *data, uint16_t length);

Data Reading#

sl_status_t sl_si91x_dac_read_data(uint16_t *dac_output_data);

Utility Functions#

sl_status_t sl_si91x_dac_get_achieved_sample_clock(uint32_t sample_rate, uint32_t *sample_clock);
sl_dac_version_t sl_si91x_dac_get_version(void);