Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM Sigma-Delta Analog-to-Digital Converter (SDADC) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's SDADC functionality.

Support and FAQ: visit Microchip Support

The following peripheral is used by this module:

The following devices can use this module:

The outline of this documentation is as follows:

Prerequisites

There are no prerequisites for this module.

Module Overview

The Sigma-Delta Analog-to-Digital Converter (SDADC) converts analog signals to digital values. The sigma-delta architecture of the SDADC implies a filtering and a decimation of the bitstream at the output of the SDADC. The input selection is up to three input analog channels.

The SDADC provides up to 16-bit resolution at about 1000 samples per second (1KSPS) and sized 24 bits signed result to handle filtering and gain correction without overflow. The SDADC measurements can be started by either application software or an incoming event from another peripheral in the device.

The conversion is performed on a full range between 0V and the reference voltage. Both internal and external reference voltages can be selected. The reference range must be set to match the voltage of the reference used. Analog inputs between these voltages convert to values based on a linear conversion.

Sample Clock

A generic clock (GCLK_SDADC) is required to generate the CLK_SDADC to the SDADC module. The SDADC features a prescaler, which enables conversion at lower clock rates than the input Generic Clock to the SDADC module.

The SDADC data sampling frequency (CLK_SDADC_FS) in the SDADC module is the CLK_SDADC/4, the reduction comes from the phase generator between the prescaler and the SDADC.

OSR is the Over Sampling Ratio, which can be modified to change the output data rate. The conversion time depends on the selected OSR and the sampling frequency of the SDADC. The conversion time can be described with:

\[ t_{SAMPLE} = \frac {22 + 3 \times OSR} {CLK \_ SDADC \_ FS} \]

  1. Initialization of the SDADC (22 sigma-delta samples).
  2. Filling of the decimation filter (3*OSR sigma-delta samples).

Gain and Offset Correction

A specific offset, gain, and shift can be applied to each source of the SDADC by performing the following operation:

\[ Data = (Data_{0} + OFFSET) \times \frac {GAIN}{2^{SHIFT}} \]

Window Monitor

The SDADC module window monitor function can be used to automatically compare the conversion result against a predefined pair of upper and lower threshold values.

Events

Event generation and event actions are configurable in the SDADC.

The SDADC has two actions that can be triggered upon event reception:

The SDADC can generate two kinds of events:

If the event actions are enabled in the configuration, any incoming event will trigger the action.

If the window monitor event is enabled, an event will be generated when the configured window condition is detected.

If the result ready event is enabled, an event will be generated when a conversion is completed.

Special Considerations

There are no special considerations for this module.

Extra Information

For extra information see Extra Information for SDADC Driver. This includes:

Examples

For a list of examples related to this driver, see Examples for SDADC Driver.

API Overview

Data Structures

struct  sdadc_config
 SDADC configuration structure. More...
 
struct  sdadc_correction_config
 SDADC correction configuration structure. More...
 
struct  sdadc_events
 SDADC event enable/disable structure. More...
 
struct  sdadc_module
 SDADC software device instance structure. More...
 
struct  sdadc_reference
 Reference configuration structure. More...
 
struct  sdadc_window_config
 Window monitor configuration structure. More...
 

Typedefs

typedef void(* sdadc_callback_t )(const struct sdadc_module *const module)
 Type of the callback functions. More...
 

Enumerations

enum  sdadc_callback {
  SDADC_CALLBACK_READ_BUFFER,
  SDADC_CALLBACK_WINDOW,
  SDADC_CALLBACK_ERROR
}
 SDADC Callback enum. More...
 
enum  sdadc_event_action {
  SDADC_EVENT_ACTION_DISABLED = 0,
  SDADC_EVENT_ACTION_FLUSH_START_CONV = SDADC_EVCTRL_FLUSHEI,
  SDADC_EVENT_ACTION_START_CONV = SDADC_EVCTRL_STARTEI
}
 SDADC event action enum. More...
 
enum  sdadc_interrupt_flag {
  SDADC_INTERRUPT_RESULT_READY = SDADC_INTFLAG_RESRDY,
  SDADC_INTERRUPT_OVERRUN = SDADC_INTFLAG_OVERRUN,
  SDADC_INTERRUPT_WINDOW = SDADC_INTFLAG_WINMON
}
 Enum for the possible SDADC interrupt flags. More...
 
enum  sdadc_job_type { SDADC_JOB_READ_BUFFER }
 Enum for the possible types of SDADC asynchronous jobs that may be issued to the driver. More...
 
enum  sdadc_mux_input {
  SDADC_MUX_INPUT_AIN0 = SDADC_INPUTCTRL_MUXSEL_AIN0,
  SDADC_MUX_INPUT_AIN1 = SDADC_INPUTCTRL_MUXSEL_AIN1,
  SDADC_MUX_INPUT_AIN2 = SDADC_INPUTCTRL_MUXSEL_AIN2
}
 SDADC MUX input selection enum. More...
 
enum  sdadc_over_sampling_ratio {
  SDADC_OVER_SAMPLING_RATIO64 = SDADC_CTRLB_OSR(0),
  SDADC_OVER_SAMPLING_RATIO128 = SDADC_CTRLB_OSR(1),
  SDADC_OVER_SAMPLING_RATIO256 = SDADC_CTRLB_OSR(2),
  SDADC_OVER_SAMPLING_RATIO512 = SDADC_CTRLB_OSR(3),
  SDADC_OVER_SAMPLING_RATIO1024 = SDADC_CTRLB_OSR(4)
}
 SDADC over sampling ratio enum. More...
 
enum  sdadc_reference_range {
  SDADC_REFRANGE_0 = SDADC_REFCTRL_REFRANGE(0),
  SDADC_REFRANGE_1 = SDADC_REFCTRL_REFRANGE(1),
  SDADC_REFRANGE_2 = SDADC_REFCTRL_REFRANGE(2),
  SDADC_REFRANGE_3 = SDADC_REFCTRL_REFRANGE(3)
}
 SDADC reference range enum. More...
 
enum  sdadc_reference_select {
  SDADC_REFERENCE_INTREF = SDADC_REFCTRL_REFSEL(0),
  SDADC_REFERENCE_AREFB = SDADC_REFCTRL_REFSEL(1),
  SDADC_REFERENCE_DACOUT = SDADC_REFCTRL_REFSEL(2),
  SDADC_REFERENCE_INTVCC = SDADC_REFCTRL_REFSEL(3)
}
 SDADC reference voltage enum. More...
 
enum  sdadc_window_mode {
  SDADC_WINDOW_MODE_DISABLE = SDADC_WINCTRL_WINMODE(0),
  SDADC_WINDOW_MODE_ABOVE = SDADC_WINCTRL_WINMODE(1),
  SDADC_WINDOW_MODE_BELOW = SDADC_WINCTRL_WINMODE(2),
  SDADC_WINDOW_MODE_INSIDE = SDADC_WINCTRL_WINMODE(3),
  SDADC_WINDOW_MODE_OUTSIDE = SDADC_WINCTRL_WINMODE(4)
}
 SDADC window monitor mode enum. More...
 

Module Status Flags

SDADC status flags, returned by sdadc_get_status() and cleared by sdadc_clear_status().

#define SDADC_STATUS_RESULT_READY   (1UL << 0)
 SDADC result ready. More...
 
#define SDADC_STATUS_OVERRUN   (1UL << 1)
 SDADC result overwritten before read. More...
 
#define SDADC_STATUS_WINDOW   (1UL << 2)
 Window monitor match. More...
 

Driver Initialization and Configuration

enum status_code sdadc_init (struct sdadc_module *const module_inst, Sdadc *hw, struct sdadc_config *config)
 Initializes the SDADC. More...
 
static void sdadc_get_config_defaults (struct sdadc_config *const config)
 Initializes an SDADC configuration structure to defaults. More...
 

Status Management

static uint32_t sdadc_get_status (struct sdadc_module *const module_inst)
 Retrieves the current module status. More...
 
static void sdadc_clear_status (struct sdadc_module *const module_inst, const uint32_t status_flags)
 Clears a module status flag. More...
 
static bool sdadc_get_sequence_status (struct sdadc_module *const module_inst, uint8_t *seq_state)
 Get a module sequence flag. More...
 

Enable, Disable, and Reset SDADC Module, Start Conversion and Read Result

static bool sdadc_is_syncing (struct sdadc_module *const module_inst)
 Determines if the hardware module(s) are currently synchronizing to the bus. More...
 
static enum status_code sdadc_enable (struct sdadc_module *const module_inst)
 Enables the SDADC module. More...
 
static enum status_code sdadc_disable (struct sdadc_module *const module_inst)
 Disables the SDADC module. More...
 
static enum status_code sdadc_reset (struct sdadc_module *const module_inst)
 Resets the SDADC module. More...
 
static void sdadc_enable_events (struct sdadc_module *const module_inst, struct sdadc_events *const events)
 Enables an SDADC event input or output. More...
 
static void sdadc_disable_events (struct sdadc_module *const module_inst, struct sdadc_events *const events)
 Disables an SDADC event input or output. More...
 
static void sdadc_start_conversion (struct sdadc_module *const module_inst)
 Starts an SDADC conversion. More...
 
static enum status_code sdadc_read (struct sdadc_module *const module_inst, int32_t *result)
 Reads the SDADC result. More...
 

Runtime Changes of SDADC Module

static void sdadc_flush (struct sdadc_module *const module_inst)
 Flushes the SDADC pipeline. More...
 
static void sdadc_set_window_mode (struct sdadc_module *const module_inst, const enum sdadc_window_mode window_mode, const int16_t window_lower_value, const int16_t window_upper_value)
 Sets the SDADC window mode. More...
 
static void sdadc_set_mux_input (struct sdadc_module *const module_inst, const enum sdadc_mux_input mux_input)
 Sets MUX SDADC input pin. More...
 

Enable and Disable Interrupts

static void sdadc_enable_interrupt (struct sdadc_module *const module_inst, enum sdadc_interrupt_flag interrupt)
 Enable interrupt. More...
 
static void sdadc_disable_interrupt (struct sdadc_module *const module_inst, enum sdadc_interrupt_flag interrupt)
 Disable interrupt. More...
 

Callback Management

void sdadc_register_callback (struct sdadc_module *const module, sdadc_callback_t callback_func, enum sdadc_callback callback_type)
 Registers a callback. More...
 
void sdadc_unregister_callback (struct sdadc_module *module, enum sdadc_callback callback_type)
 Unregisters a callback. More...
 
static void sdadc_enable_callback (struct sdadc_module *const module, enum sdadc_callback callback_type)
 Enables callback. More...
 
static void sdadc_disable_callback (struct sdadc_module *const module, enum sdadc_callback callback_type)
 Disables callback. More...
 

Job Management

enum status_code sdadc_read_buffer_job (struct sdadc_module *const module_inst, int32_t *buffer, uint16_t samples)
 Read multiple samples from SDADC. More...
 
enum status_code sdadc_get_job_status (struct sdadc_module *module_inst, enum sdadc_job_type type)
 Gets the status of a job. More...
 
void sdadc_abort_job (struct sdadc_module *module_inst, enum sdadc_job_type type)
 Aborts an ongoing job. More...
 

#define SDADC_STATUS_OVERRUN   (1UL << 1)

SDADC result overwritten before read.

Referenced by sdadc_clear_status(), sdadc_get_status(), and sdadc_read().

#define SDADC_STATUS_RESULT_READY   (1UL << 0)

SDADC result ready.

Referenced by sdadc_clear_status(), sdadc_get_status(), and sdadc_read().

#define SDADC_STATUS_WINDOW   (1UL << 2)

Window monitor match.

Referenced by sdadc_clear_status(), and sdadc_get_status().

typedef void(* sdadc_callback_t)(const struct sdadc_module *const module)

Type of the callback functions.

SDADC Callback enum.

Callback types for SDADC callback driver.

Enumerator
SDADC_CALLBACK_READ_BUFFER 

Callback for buffer received.

SDADC_CALLBACK_WINDOW 

Callback when window is hit.

SDADC_CALLBACK_ERROR 

Callback for error.

SDADC event action enum.

Enum for the possible actions to take on an incoming event.

Enumerator
SDADC_EVENT_ACTION_DISABLED 

Event action disabled.

SDADC_EVENT_ACTION_FLUSH_START_CONV 

Flush SDADC and start conversion.

SDADC_EVENT_ACTION_START_CONV 

Start conversion.

Enum for the possible SDADC interrupt flags.

Enumerator
SDADC_INTERRUPT_RESULT_READY 

SDADC result ready.

SDADC_INTERRUPT_OVERRUN 

SDADC result overwritten before read.

SDADC_INTERRUPT_WINDOW 

Window monitor match.

Enum for the possible types of SDADC asynchronous jobs that may be issued to the driver.

Enumerator
SDADC_JOB_READ_BUFFER 

Asynchronous SDADC read into a user provided buffer.

SDADC MUX input selection enum.

Enum for the possible MUX input selections for the SDADC.

Enumerator
SDADC_MUX_INPUT_AIN0 

Select SDADC AINN0 and AINP0 pins.

SDADC_MUX_INPUT_AIN1 

Select SDADC AINN1 and AINP1 pins.

SDADC_MUX_INPUT_AIN2 

Select SDADC AINN2 and AINP2 pins.

SDADC over sampling ratio enum.

Enum for the over sampling ratio, which change the output data rate.

Enumerator
SDADC_OVER_SAMPLING_RATIO64 

SDADC over Sampling Ratio is 64.

SDADC_OVER_SAMPLING_RATIO128 

SDADC over Sampling Ratio is 128.

SDADC_OVER_SAMPLING_RATIO256 

SDADC over Sampling Ratio is 256.

SDADC_OVER_SAMPLING_RATIO512 

SDADC over Sampling Ratio is 512.

SDADC_OVER_SAMPLING_RATIO1024 

SDADC over Sampling Ratio is 1024.

SDADC reference range enum.

Enum for the matched voltage range of the SDADC reference used.

Enumerator
SDADC_REFRANGE_0 

Vref < 1.4V.

SDADC_REFRANGE_1 

1.4V < Vref < 2.4V

SDADC_REFRANGE_2 

2.4V < Vref < 3.6V

SDADC_REFRANGE_3 

Vref > 3.6V.

SDADC reference voltage enum.

Enum for the possible reference voltages for the SDADC.

Enumerator
SDADC_REFERENCE_INTREF 

Internal Bandgap Reference.

SDADC_REFERENCE_AREFB 

External reference B.

SDADC_REFERENCE_DACOUT 

DACOUT.

SDADC_REFERENCE_INTVCC 

VDDANA.

SDADC window monitor mode enum.

Enum for the possible window monitor modes for the SDADC.

Enumerator
SDADC_WINDOW_MODE_DISABLE 

No window mode.

SDADC_WINDOW_MODE_ABOVE 

RESULT > WINLT.

SDADC_WINDOW_MODE_BELOW 

RESULT < WINUT.

SDADC_WINDOW_MODE_INSIDE 

WINLT < RESULT < WINUT.

SDADC_WINDOW_MODE_OUTSIDE 

!(WINLT < RESULT < WINUT)

void sdadc_abort_job ( struct sdadc_module module_inst,
enum sdadc_job_type  type 
)

Aborts an ongoing job.

Aborts an ongoing job with given type.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]typeType of job to abort

References Assert, sdadc_disable_interrupt(), SDADC_INTERRUPT_RESULT_READY, SDADC_JOB_READ_BUFFER, and STATUS_ABORTED.

static void sdadc_clear_status ( struct sdadc_module *const  module_inst,
const uint32_t  status_flags 
)
inlinestatic

Clears a module status flag.

Clears the given status flag of the module.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]status_flagsBitmask of SDADC_STATUS_* flags to clear

References Assert, SDADC_STATUS_OVERRUN, SDADC_STATUS_RESULT_READY, and SDADC_STATUS_WINDOW.

Referenced by sdadc_read().

static enum status_code sdadc_disable ( struct sdadc_module *const  module_inst)
inlinestatic

Disables the SDADC module.

Disables an SDADC module that was previously enabled.

Parameters
[in]module_instPointer to the SDADC software instance struct

References Assert, sdadc_is_syncing(), STATUS_OK, and system_interrupt_disable().

Referenced by sdadc_reset().

static void sdadc_disable_callback ( struct sdadc_module *const  module,
enum sdadc_callback  callback_type 
)
inlinestatic

Disables callback.

Disables the callback function registered by the sdadc_register_callback.

Parameters
[in]modulePointer to SDADC software instance struct
[in]callback_typeCallback type given by an enum
Returns
Status of the operation.
Return values
STATUS_OKIf operation was completed
STATUS_ERR_INVALIDIf operation was not completed, due to invalid callback_type

References Assert, SDADC_CALLBACK_ERROR, SDADC_CALLBACK_WINDOW, sdadc_disable_interrupt(), SDADC_INTERRUPT_OVERRUN, and SDADC_INTERRUPT_WINDOW.

static void sdadc_disable_events ( struct sdadc_module *const  module_inst,
struct sdadc_events *const  events 
)
inlinestatic

Disables an SDADC event input or output.

Disables one or more input or output events to or from the SDADC module. See sdadc_events for a list of events this module supports.

Note
Events cannot be altered while the module is enabled.
Parameters
[in]module_instSoftware instance for the SDADC peripheral
[in]eventsStruct containing flags of events to disable

References Assert, sdadc_events::generate_event_on_conversion_done, and sdadc_events::generate_event_on_window_monitor.

static void sdadc_disable_interrupt ( struct sdadc_module *const  module_inst,
enum sdadc_interrupt_flag  interrupt 
)
inlinestatic

Disable interrupt.

Disable the given interrupt request from the SDADC module.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]interruptInterrupt to disable

References Assert.

Referenced by _sdadc_interrupt_handler(), sdadc_abort_job(), and sdadc_disable_callback().

static enum status_code sdadc_enable ( struct sdadc_module *const  module_inst)
inlinestatic

Enables the SDADC module.

Enables an SDADC module that has previously been configured. If any internal reference is selected it will be enabled.

Parameters
[in]module_instPointer to the SDADC software instance struct

References Assert, sdadc_is_syncing(), STATUS_OK, and system_interrupt_enable().

static void sdadc_enable_callback ( struct sdadc_module *const  module,
enum sdadc_callback  callback_type 
)
inlinestatic

Enables callback.

Enables the callback function registered by sdadc_register_callback. The callback function will be called from the interrupt handler when the conditions for the callback type are met.

Parameters
[in]modulePointer to SDADC software instance struct
[in]callback_typeCallback type given by an enum
Returns
Status of the operation.
Return values
STATUS_OKIf operation was completed
STATUS_ERR_INVALIDIf operation was not completed, due to invalid callback_type

References Assert, SDADC_CALLBACK_ERROR, SDADC_CALLBACK_WINDOW, sdadc_enable_interrupt(), SDADC_INTERRUPT_OVERRUN, and SDADC_INTERRUPT_WINDOW.

static void sdadc_enable_events ( struct sdadc_module *const  module_inst,
struct sdadc_events *const  events 
)
inlinestatic

Enables an SDADC event input or output.

Enables one or more input or output events to or from the SDADC module. See sdadc_events for a list of events this module supports.

Note
Events cannot be altered while the module is enabled.
Parameters
[in]module_instSoftware instance for the SDADC peripheral
[in]eventsStruct containing flags of events to enable

References Assert, sdadc_events::generate_event_on_conversion_done, and sdadc_events::generate_event_on_window_monitor.

static void sdadc_enable_interrupt ( struct sdadc_module *const  module_inst,
enum sdadc_interrupt_flag  interrupt 
)
inlinestatic

Enable interrupt.

Enable the given interrupt request from the SDADC module.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]interruptInterrupt to enable

References Assert.

Referenced by sdadc_enable_callback(), and sdadc_read_buffer_job().

static void sdadc_flush ( struct sdadc_module *const  module_inst)
inlinestatic

Flushes the SDADC pipeline.

Flushes the pipeline and restart the SDADC clock on the next peripheral clock edge. All conversions in progress will be lost. When flush is complete, the module will resume where it left off.

Parameters
[in]module_instPointer to the SDADC software instance struct

References Assert, and sdadc_is_syncing().

static void sdadc_get_config_defaults ( struct sdadc_config *const  config)
inlinestatic

Initializes an SDADC configuration structure to defaults.

Initializes a given SDADC configuration struct to a set of known default values. This function should be called on any new instance of the configuration struct before being modified by the user application.

The default configuration is as follows:

  • GCLK generator 0 (GCLK main) clock source
  • Positive reference 1
  • Div 2 clock prescaler
  • Over Sampling Ratio is 64
  • Skip 0 samples
  • MUX input on SDADC AIN1
  • All events (input and generation) disabled
  • Free running disabled
  • Run in standby disabled
  • On command disabled
  • Disable all positive input in sequence
  • Window monitor disabled
  • No gain/offset/shift correction
Parameters
[out]configPointer to configuration struct to initialize to default values

References Assert, sdadc_config::clock_prescaler, sdadc_config::clock_source, sdadc_config::correction, sdadc_config::event_action, sdadc_config::freerunning, sdadc_correction_config::gain_correction, GCLK_GENERATOR_0, sdadc_config::mux_input, sdadc_correction_config::offset_correction, sdadc_config::on_command, sdadc_reference::on_ref_buffer, sdadc_config::osr, sdadc_reference::ref_range, sdadc_reference::ref_sel, sdadc_config::reference, sdadc_config::run_in_standby, SDADC_EVENT_ACTION_DISABLED, SDADC_MUX_INPUT_AIN1, SDADC_OVER_SAMPLING_RATIO64, SDADC_REFERENCE_INTREF, SDADC_REFRANGE_0, SDADC_WINDOW_MODE_DISABLE, sdadc_config::seq_enable, sdadc_correction_config::shift_correction, sdadc_config::skip_count, sdadc_config::window, sdadc_window_config::window_lower_value, sdadc_window_config::window_mode, and sdadc_window_config::window_upper_value.

enum status_code sdadc_get_job_status ( struct sdadc_module module_inst,
enum sdadc_job_type  type 
)

Gets the status of a job.

Gets the status of an ongoing or the last job.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]typeType of job to abort
Returns
Status of the job.

References Assert, SDADC_JOB_READ_BUFFER, and STATUS_ERR_INVALID_ARG.

static bool sdadc_get_sequence_status ( struct sdadc_module *const  module_inst,
uint8_t *  seq_state 
)
inlinestatic

Get a module sequence flag.

Get the given status flag of the module.

Parameters
[in]module_instPointer to the SDADC software instance struct
[out]seq_stateIdentifies the last conversion done in the sequence
Returns
Status of the SDADC sequence conversion.
Return values
trueWhen the sequence start
falseWhen the last conversion in a sequence is done

References Assert.

static uint32_t sdadc_get_status ( struct sdadc_module *const  module_inst)
inlinestatic

Retrieves the current module status.

Retrieves the status of the module, giving overall state information.

Parameters
[in]module_instPointer to the SDADC software instance struct
Returns
Bitmask of SDADC_STATUS_* flags.
Return values
SDADC_STATUS_RESULT_READYSDADC result is ready to be read
SDADC_STATUS_WINDOWSDADC has detected a value inside the set window range
SDADC_STATUS_OVERRUNSDADC result has overrun

References Assert, SDADC_STATUS_OVERRUN, SDADC_STATUS_RESULT_READY, and SDADC_STATUS_WINDOW.

Referenced by sdadc_read().

enum status_code sdadc_init ( struct sdadc_module *const  module_inst,
Sdadc *  hw,
struct sdadc_config config 
)

Initializes the SDADC.

Initializes the SDADC device struct and the hardware module based on the given configuration struct values.

Parameters
[out]module_instPointer to the SDADC software instance struct
[in]hwPointer to the SDADC module instance
[in]configPointer to the configuration struct
Returns
Status of the initialization procedure.
Return values
STATUS_OKThe initialization was successful
STATUS_ERR_INVALID_ARGInvalid argument(s) were provided
STATUS_BUSYThe module is busy with a reset operation
STATUS_ERR_DENIEDThe module is enabled

References _sdadc_instances, _sdadc_set_config(), Assert, sdadc_config::event_action, sdadc_config::freerunning, sdadc_config::reference, SDADC_EVENT_ACTION_DISABLED, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_OK, system_apb_clock_set_mask(), and SYSTEM_CLOCK_APB_APBC.

static bool sdadc_is_syncing ( struct sdadc_module *const  module_inst)
inlinestatic

Determines if the hardware module(s) are currently synchronizing to the bus.

Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus. This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application.

Parameters
[in]module_instPointer to the SDADC software instance struct
Returns
Synchronization status of the underlying hardware module(s).
Return values
trueIf the module synchronization is ongoing
falseIf the module has completed synchronization

References Assert.

Referenced by _sdadc_set_config(), sdadc_disable(), sdadc_enable(), sdadc_flush(), sdadc_reset(), sdadc_set_mux_input(), sdadc_set_window_mode(), and sdadc_start_conversion().

static enum status_code sdadc_read ( struct sdadc_module *const  module_inst,
int32_t *  result 
)
inlinestatic

Reads the SDADC result.

Reads the result from an SDADC conversion that was previously started.

Parameters
[in]module_instPointer to the SDADC software instance struct
[out]resultPointer to store the result value in
Returns
Status of the SDADC read request.
Return values
STATUS_OKThe result was retrieved successfully
STATUS_BUSYA conversion result was not ready
STATUS_ERR_OVERFLOWThe result register has been overwritten by the SDADC module before the result was read by the software

References Assert, sdadc_clear_status(), sdadc_get_status(), SDADC_STATUS_OVERRUN, SDADC_STATUS_RESULT_READY, STATUS_BUSY, STATUS_ERR_OVERFLOW, and STATUS_OK.

enum status_code sdadc_read_buffer_job ( struct sdadc_module *const  module_inst,
int32_t *  buffer,
uint16_t  samples 
)

Read multiple samples from SDADC.

Read samples from the SDADC into the buffer. If there is no hardware trigger defined (event action) the driver will retrigger the SDADC conversion whenever a conversion is complete until samples has been acquired. To avoid jitter in the sampling frequency using an event trigger is advised.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]samplesNumber of samples to acquire
[out]bufferBuffer to store the SDADC samples
Returns
Status of the job start.
Return values
STATUS_OKThe conversion job was started successfully and is in progress
STATUS_BUSYThe SDADC is already busy with another job

References Assert, sdadc_enable_interrupt(), SDADC_INTERRUPT_RESULT_READY, sdadc_start_conversion(), STATUS_BUSY, and STATUS_OK.

void sdadc_register_callback ( struct sdadc_module *const  module,
sdadc_callback_t  callback_func,
enum sdadc_callback  callback_type 
)

Registers a callback.

Registers a callback function which is implemented by the user.

Note
The callback must be enabled by for the interrupt handler to call it when the condition for the callback is met.
Parameters
[in]modulePointer to SDADC software instance struct
[in]callback_funcPointer to callback function
[in]callback_typeCallback type given by an enum

References Assert.

static enum status_code sdadc_reset ( struct sdadc_module *const  module_inst)
inlinestatic

Resets the SDADC module.

Resets an SDADC module, clearing all module state, and registers to their default values.

Parameters
[in]module_instPointer to the SDADC software instance struct

References Assert, sdadc_disable(), sdadc_is_syncing(), and STATUS_OK.

static void sdadc_set_mux_input ( struct sdadc_module *const  module_inst,
const enum sdadc_mux_input  mux_input 
)
inlinestatic

Sets MUX SDADC input pin.

Sets the MUX SDADC input pin selection.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]mux_inputMUX input pin

References Assert, and sdadc_is_syncing().

static void sdadc_set_window_mode ( struct sdadc_module *const  module_inst,
const enum sdadc_window_mode  window_mode,
const int16_t  window_lower_value,
const int16_t  window_upper_value 
)
inlinestatic

Sets the SDADC window mode.

Sets the SDADC window mode to a given mode and value range.

Parameters
[in]module_instPointer to the SDADC software instance struct
[in]window_modeWindow monitor mode to set
[in]window_lower_valueLower window monitor threshold value
[in]window_upper_valueUpper window monitor threshold value

References Assert, and sdadc_is_syncing().

static void sdadc_start_conversion ( struct sdadc_module *const  module_inst)
inlinestatic

Starts an SDADC conversion.

Starts a new SDADC conversion.

Parameters
[in]module_instPointer to the SDADC software instance struct

References Assert, and sdadc_is_syncing().

Referenced by _sdadc_interrupt_handler(), and sdadc_read_buffer_job().

void sdadc_unregister_callback ( struct sdadc_module *const  module,
enum sdadc_callback  callback_type 
)

Unregisters a callback.

Unregisters a callback function which is implemented by the user.

Parameters
[in]modulePointer to SDADC software instance struct
[in]callback_typeCallback type given by an enum

References Assert.