Astra MCU SDK Peripheral Driver Library
Loading...
Searching...
No Matches

Topics

 Enumerated Types
 Enumerated types for the ADC driver.
 Data Structures
 Data structures for ADC configuration and callbacks.
 General Functions
 General ADC control and conversion APIs.

Detailed Description

The ADC (Analog-to-Digital Converter) driver provides a complete interface to configure sampling behavior, trigger conversions, monitor status/interrupts, and read digitized conversion results.

The driver supports single, continuous, and window-comparison conversion flows, with callback-based event notification and optional BIST support for production or field diagnostics.

Features:

  • Single-shot, continuous, and window conversion modes
  • Configurable conversion cycle length and conversion type
  • Channel selection (ADC_CH_0 .. ADC_CH_7)
  • Interrupt control and status polling helpers
  • 12-bit conversion result readout
  • Callback registration for ADC events
  • Built-In Self-Test (BIST) configuration and status APIs

Configuration Considerations

Typical initialization and conversion flow:

  1. Call adc_init for the target instance.
  2. Fill adc_config_t with conversion mode/type and timing fields.
  3. Apply settings using adc_config.
  4. Select input source via adc_select_channel.
  5. Optionally configure callback and interrupt sources using adc_register_callback and adc_enable_interrupt.
  6. Enable ADC using adc_enable.
  7. Start conversion using adc_start_conversion and read result via adc_read.
  8. Disable and deinitialize using adc_disable and adc_deinit.
Note
Window mode thresholds (ulimit_value, llimit_value) are evaluated against 12-bit conversion data. Ensure threshold values are configured within 0..0xFFF and aligned to your expected sensor range.

Usage Examples

Single-Shot Conversion

adc_instance_en id = (adc_instance_en)0; /* platform instance */
adc_config_t cfg = {
.conv_mode = ADC_CONV_MODE_21CYCLE,
.conv_type = ADC_CONV_TYPE_SINGLE,
.bgclk_div = 9,
.cont_conv_intv = 0,
.con_data_lt = 0,
.ana_reg = 0,
.ulimit_value = 0x0FFF,
.llimit_value = 0
};
uint16_t sample = 0;
adc_init(id);
adc_config(id, &cfg);
adc_select_channel(id, ADC_CH_0);
adc_enable(id);
adc_start_conversion(id);
adc_read(id, &sample);
adc_disable(id);
adc_deinit(id);