Microchip® Advanced Software Framework

adc.h File Reference

SAM Peripheral Analog-to-Digital Converter Driver.

Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>
#include <system.h>
#include <adc_feature.h>

Macros

Module Status Flags

ADC status flags, returned by adc_get_status() and cleared by adc_clear_status().

#define ADC_STATUS_RESULT_READY   (1UL << 0)
 ADC result ready. More...
 
#define ADC_STATUS_WINDOW   (1UL << 1)
 Window monitor match. More...
 
#define ADC_STATUS_OVERRUN   (1UL << 2)
 ADC result overwritten before read. More...
 

Functions

Driver Initialization and Configuration
enum status_code adc_init (struct adc_module *const module_inst, Adc *hw, struct adc_config *config)
 
void adc_get_config_defaults (struct adc_config *const config)
 
Status Management
static uint32_t adc_get_status (struct adc_module *const module_inst)
 Retrieves the current module status. More...
 
static void adc_clear_status (struct adc_module *const module_inst, const uint32_t status_flags)
 Clears a module status flag. More...
 
Enable, Disable, and Reset ADC Module, Start Conversion and Read Result
static enum status_code adc_enable (struct adc_module *const module_inst)
 Enables the ADC module. More...
 
static enum status_code adc_disable (struct adc_module *const module_inst)
 Disables the ADC module. More...
 
static enum status_code adc_reset (struct adc_module *const module_inst)
 Resets the ADC module. More...
 
static void adc_enable_events (struct adc_module *const module_inst, struct adc_events *const events)
 Enables an ADC event input or output. More...
 
static void adc_disable_events (struct adc_module *const module_inst, struct adc_events *const events)
 Disables an ADC event input or output. More...
 
static void adc_start_conversion (struct adc_module *const module_inst)
 Starts an ADC conversion. More...
 
static enum status_code adc_read (struct adc_module *const module_inst, uint16_t *result)
 Reads the ADC result. More...
 
Runtime Changes of ADC Module
static void adc_flush (struct adc_module *const module_inst)
 Flushes the ADC pipeline. More...
 
void adc_set_window_mode (struct adc_module *const module_inst, const enum adc_window_mode window_mode, const int16_t window_lower_value, const int16_t window_upper_value)
 
static void adc_set_positive_input (struct adc_module *const module_inst, const enum adc_positive_input positive_input)
 Sets positive ADC input pin. More...
 
static void adc_set_negative_input (struct adc_module *const module_inst, const enum adc_negative_input negative_input)
 Sets negative ADC input pin for differential mode. More...
 
Enable and Disable Interrupts
static void adc_enable_interrupt (struct adc_module *const module_inst, enum adc_interrupt_flag interrupt)
 Enable interrupt. More...
 
static void adc_disable_interrupt (struct adc_module *const module_inst, enum adc_interrupt_flag interrupt)
 Disable interrupt. More...