See Quickstart guide for SAM ADC driver.
Driver for the Analog-to-digital Converter. This driver provides access to the main features of the ADC controller.
Macros | |
#define | ADC_WPMR_WPKEY_PASSWD ADC_WPMR_WPKEY(0x414443u) |
Functions | |
void | adc_check (Adc *p_adc, const uint32_t ul_mck) |
Check ADC configurations. More... | |
void | adc_configure_power_save (Adc *p_adc, const uint8_t uc_sleep, const uint8_t uc_fwup) |
Configures ADC power saving mode. More... | |
void | adc_configure_sequence (Adc *p_adc, const enum adc_channel_num_t ch_list[], uint8_t uc_num) |
Configure conversion sequence. More... | |
void | adc_configure_timing (Adc *p_adc, const uint8_t uc_tracking, const enum adc_settling_time_t settling, const uint8_t uc_transfer) |
Configure ADC timing. More... | |
void | adc_configure_trigger (Adc *p_adc, const enum adc_trigger_t trigger, uint8_t uc_freerun) |
Configure conversion trigger and free run mode. More... | |
void | adc_configure_ts_comparison (Adc *p_adc, enum adc_temp_cmp_mode mode, uint16_t low_threshold, uint16_t high_threshold) |
Configure temperature sensor comparison. More... | |
void | adc_disable_all_channel (Adc *p_adc) |
Disable all ADC channel. More... | |
void | adc_disable_anch (Adc *p_adc) |
Disable analog change. More... | |
void | adc_disable_channel (Adc *p_adc, const enum adc_channel_num_t adc_ch) |
Disable the specified ADC channel. More... | |
void | adc_disable_channel_differential_input (Adc *p_adc, const enum adc_channel_num_t channel) |
Disable differential input for the specified channel. More... | |
void | adc_disable_channel_input_offset (Adc *p_adc, const enum adc_channel_num_t channel) |
Disable analog signal offset for the specified channel. More... | |
void | adc_disable_interrupt (Adc *p_adc, const uint32_t ul_source) |
Disable ADC interrupts. More... | |
void | adc_disable_tag (Adc *p_adc) |
Disable TAG option. More... | |
void | adc_disable_ts (Adc *p_adc) |
Turn off temperature sensor. More... | |
void | adc_enable_all_channel (Adc *p_adc) |
Enable all ADC channels. More... | |
void | adc_enable_anch (Adc *p_adc) |
Enable analog change. More... | |
void | adc_enable_channel (Adc *p_adc, const enum adc_channel_num_t adc_ch) |
Enable the specified ADC channel. More... | |
void | adc_enable_channel_differential_input (Adc *p_adc, const enum adc_channel_num_t channel) |
Enable differential input for the specified channel. More... | |
void | adc_enable_channel_input_offset (Adc *p_adc, const enum adc_channel_num_t channel) |
Enable analog signal offset for the specified channel. More... | |
void | adc_enable_interrupt (Adc *p_adc, const uint32_t ul_source) |
Enable ADC interrupts. More... | |
void | adc_enable_tag (Adc *p_adc) |
Enable TAG option so that the number of the last converted channel can be indicated. More... | |
void | adc_enable_ts (Adc *p_adc) |
Turn on temperature sensor. More... | |
uint32_t | adc_get_actual_adc_clock (const Adc *p_adc, const uint32_t ul_mck) |
Return the actual ADC clock. More... | |
uint32_t | adc_get_channel_status (const Adc *p_adc, const enum adc_channel_num_t adc_ch) |
Read the ADC channel status. More... | |
uint32_t | adc_get_channel_value (const Adc *p_adc, const enum adc_channel_num_t adc_ch) |
Read the ADC result data of the specified channel. More... | |
uint32_t | adc_get_comparison_mode (const Adc *p_adc) |
Get comparison mode. More... | |
uint32_t | adc_get_interrupt_mask (const Adc *p_adc) |
Read ADC interrupt mask. More... | |
uint32_t | adc_get_latest_value (const Adc *p_adc) |
Read the last ADC result data. More... | |
uint32_t | adc_get_overrun_status (const Adc *p_adc) |
Get ADC interrupt and overrun error status. More... | |
Pdc * | adc_get_pdc_base (const Adc *p_adc) |
Get PDC registers base address. More... | |
uint32_t | adc_get_status (const Adc *p_adc) |
Get ADC interrupt and overrun error status. More... | |
enum adc_channel_num_t | adc_get_tag (const Adc *p_adc) |
Indicate the last converted channel. More... | |
uint32_t | adc_get_writeprotect_status (const Adc *p_adc) |
Indicate write protect status. More... | |
uint32_t | adc_init (Adc *p_adc, const uint32_t ul_mck, const uint32_t ul_adc_clock, const enum adc_startup_time startup) |
Initialize the given ADC with the specified ADC clock and startup time. More... | |
void | adc_reset (Adc *p_adc) |
Reset ADC. More... | |
void | adc_set_averaging_trigger (Adc *p_adc, bool multi) |
Set digital averaging trigger. More... | |
void | adc_set_bias_current (Adc *p_adc, const uint8_t uc_ibctl) |
Adapt performance versus power consumption. More... | |
void | adc_set_calibmode (Adc *p_adc) |
Set ADC auto calibration mode. More... | |
void | adc_set_channel_input_gain (Adc *p_adc, const enum adc_channel_num_t channel, const enum adc_gainvalue_t gain) |
Configure input gain for the specified channel. More... | |
void | adc_set_comparison_channel (Adc *p_adc, const enum adc_channel_num_t channel) |
Configure comparison selected channel. More... | |
void | adc_set_comparison_filter (Adc *p_adc, uint8_t filter) |
Set comparison filter. More... | |
void | adc_set_comparison_mode (Adc *p_adc, const uint8_t uc_mode) |
Configure comparison mode. More... | |
void | adc_set_comparison_window (Adc *p_adc, const uint16_t us_low_threshold, const uint16_t us_high_threshold) |
Configure ADC compare window. More... | |
enum status_code | adc_set_internal_reference_voltage (Adc *p_adc, struct adc_internal_ref *ref) |
Set ADC analog control(internal reference voltage). More... | |
void | adc_set_resolution (Adc *p_adc, const enum adc_resolution_t resolution) |
Configure the conversion resolution. More... | |
void | adc_set_writeprotect (Adc *p_adc, const uint32_t ul_enable) |
Enable or disable write protection of ADC registers. More... | |
void | adc_start (Adc *p_adc) |
Start analog-to-digital conversion. More... | |
void | adc_start_sequencer (Adc *p_adc) |
Enable conversion sequencer. More... | |
void | adc_stop_sequencer (Adc *p_adc) |
Disable conversion sequencer. More... | |
static uint32_t | calcul_startup (const uint32_t ul_startup) |
calcul_startup More... | |
#define ADC_WPMR_WPKEY_PASSWD ADC_WPMR_WPKEY(0x414443u) |
Referenced by adc_set_writeprotect().
void adc_check | ( | Adc * | p_adc, |
const uint32_t | ul_mck | ||
) |
Check ADC configurations.
p_adc | Pointer to an ADC instance. |
ul_mck | Main clock of the device (in Hz). |
References ADC_FREQ_MAX, ADC_FREQ_MIN, ADC_STARTUP_FAST, ADC_STARTUP_NORM, and calcul_startup().
Referenced by main().
void adc_configure_power_save | ( | Adc * | p_adc, |
const uint8_t | uc_sleep, | ||
const uint8_t | uc_fwup | ||
) |
Configures ADC power saving mode.
p_adc | Pointer to an ADC instance. |
uc_sleep | ADC_MR_SLEEP_NORMAL keeps the ADC Core and reference voltage circuitry ON between conversions. ADC_MR_SLEEP_SLEEP keeps the ADC Core and reference voltage circuitry OFF between conversions. |
uc_fwup | ADC_MR_FWUP_OFF configures sleep mode as uc_sleep setting, ADC_MR_FWUP_ON keeps voltage reference ON and ADC Core OFF between conversions. |
void adc_configure_sequence | ( | Adc * | p_adc, |
const enum adc_channel_num_t | ch_list[], | ||
uint8_t | uc_num | ||
) |
Configure conversion sequence.
p_adc | Pointer to an ADC instance. |
ch_list | Channel sequence list. |
number | Number of channels in the list. |
void adc_configure_timing | ( | Adc * | p_adc, |
const uint8_t | uc_tracking, | ||
const enum adc_settling_time_t | settling, | ||
const uint8_t | uc_transfer | ||
) |
Configure ADC timing.
p_adc | Pointer to an ADC instance. |
uc_tracking | ADC tracking time = uc_tracking / ADC clock. |
uc_settling | Analog settling time = (uc_settling + 1) / ADC clock. |
uc_transfer | Data transfer time = (uc_transfer * 2 + 3) / ADC clock. |
Referenced by main().
void adc_configure_trigger | ( | Adc * | p_adc, |
const enum adc_trigger_t | trigger, | ||
uint8_t | uc_freerun | ||
) |
Configure conversion trigger and free run mode.
p_adc | Pointer to an ADC instance. |
trigger | Conversion trigger. |
uc_freerun | ADC_MR_FREERUN_ON enables freerun mode, ADC_MR_FREERUN_OFF disables freerun mode. |
Referenced by main().
void adc_configure_ts_comparison | ( | Adc * | p_adc, |
enum adc_temp_cmp_mode | mode, | ||
uint16_t | low_threshold, | ||
uint16_t | high_threshold | ||
) |
Configure temperature sensor comparison.
p_adc | Pointer to an ADC instance. |
mode | Temperature comparison mode. |
low_threshold | Temperature low threshold. |
high_threshold | Temperature high threshold. |
void adc_disable_all_channel | ( | Adc * | p_adc | ) |
Disable all ADC channel.
p_adc | Pointer to an ADC instance. |
void adc_disable_anch | ( | Adc * | p_adc | ) |
Disable analog change.
p_Adc | Pointer to an ADC instance. |
void adc_disable_channel | ( | Adc * | p_adc, |
const enum adc_channel_num_t | adc_ch | ||
) |
Disable the specified ADC channel.
p_adc | Pointer to an ADC instance. |
adc_ch | ADC channel number. |
void adc_disable_channel_differential_input | ( | Adc * | p_adc, |
const enum adc_channel_num_t | channel | ||
) |
Disable differential input for the specified channel.
p_adc | Pointer to an ADC instance. |
channel | ADC channel number. |
void adc_disable_channel_input_offset | ( | Adc * | p_adc, |
const enum adc_channel_num_t | channel | ||
) |
Disable analog signal offset for the specified channel.
p_adc | Pointer to an ADC instance. |
channel | ADC channel number. |
void adc_disable_interrupt | ( | Adc * | p_adc, |
const uint32_t | ul_source | ||
) |
Disable ADC interrupts.
p_adc | Pointer to an ADC instance. |
ul_source | Interrupts to be disabled. |
Referenced by ADC_Handler().
void adc_disable_tag | ( | Adc * | p_adc | ) |
Disable TAG option.
p_adc | Pointer to an ADC instance. |
void adc_disable_ts | ( | Adc * | p_adc | ) |
Turn off temperature sensor.
p_adc | Pointer to an ADC instance. |
void adc_enable_all_channel | ( | Adc * | p_adc | ) |
Enable all ADC channels.
p_adc | Pointer to an ADC instance. |
void adc_enable_anch | ( | Adc * | p_adc | ) |
Enable analog change.
p_Adc | Pointer to an ADC instance. |
void adc_enable_channel | ( | Adc * | p_adc, |
const enum adc_channel_num_t | adc_ch | ||
) |
Enable the specified ADC channel.
p_adc | Pointer to an ADC instance. |
adc_ch | ADC channel number. |
Referenced by main().
void adc_enable_channel_differential_input | ( | Adc * | p_adc, |
const enum adc_channel_num_t | channel | ||
) |
Enable differential input for the specified channel.
p_adc | Pointer to an ADC instance. |
channel | ADC channel number. |
void adc_enable_channel_input_offset | ( | Adc * | p_adc, |
const enum adc_channel_num_t | channel | ||
) |
Enable analog signal offset for the specified channel.
p_adc | Pointer to an ADC instance. |
channel | ADC channel number. |
void adc_enable_interrupt | ( | Adc * | p_adc, |
const uint32_t | ul_source | ||
) |
Enable ADC interrupts.
p_adc | Pointer to an ADC instance. |
ul_source | Interrupts to be enabled. |
Referenced by enter_asleep().
void adc_enable_tag | ( | Adc * | p_adc | ) |
Enable TAG option so that the number of the last converted channel can be indicated.
p_adc | Pointer to an ADC instance. |
void adc_enable_ts | ( | Adc * | p_adc | ) |
Turn on temperature sensor.
p_adc | Pointer to an ADC instance. |
uint32_t adc_get_actual_adc_clock | ( | const Adc * | p_adc, |
const uint32_t | ul_mck | ||
) |
Return the actual ADC clock.
p_adc | Pointer to an ADC instance. |
ul_mck | Main clock of the device (in Hz). |
uint32_t adc_get_channel_status | ( | const Adc * | p_adc, |
const enum adc_channel_num_t | adc_ch | ||
) |
Read the ADC channel status.
p_adc | Pointer to an ADC instance. |
adc_ch | ADC channel number. |
1 | if channel is enabled. |
0 | if channel is disabled. |
uint32_t adc_get_channel_value | ( | const Adc * | p_adc, |
const enum adc_channel_num_t | adc_ch | ||
) |
Read the ADC result data of the specified channel.
p_adc | Pointer to an ADC instance. |
adc_ch | ADC channel number. |
Referenced by ADC_Handler(), display_info(), and main().
uint32_t adc_get_comparison_mode | ( | const Adc * | p_adc | ) |
Get comparison mode.
p_adc | Pointer to an ADC instance. |
Compare | mode value. |
Referenced by ADC_Handler(), and get_comparison_mode().
uint32_t adc_get_interrupt_mask | ( | const Adc * | p_adc | ) |
Read ADC interrupt mask.
p_adc | Pointer to an ADC instance. |
uint32_t adc_get_latest_value | ( | const Adc * | p_adc | ) |
Read the last ADC result data.
p_adc | Pointer to an ADC instance. |
uint32_t adc_get_overrun_status | ( | const Adc * | p_adc | ) |
Get ADC interrupt and overrun error status.
p_adc | Pointer to an ADC instance. |
Pdc* adc_get_pdc_base | ( | const Adc * | p_adc | ) |
Get PDC registers base address.
p_adc | Pointer to an ADC instance. |
References UNUSED.
uint32_t adc_get_status | ( | const Adc * | p_adc | ) |
Get ADC interrupt and overrun error status.
p_adc | Pointer to an ADC instance. |
Referenced by ADC_Handler(), and enter_asleep().
enum adc_channel_num_t adc_get_tag | ( | const Adc * | p_adc | ) |
Indicate the last converted channel.
p_adc | Pointer to an ADC instance. |
uint32_t adc_get_writeprotect_status | ( | const Adc * | p_adc | ) |
Indicate write protect status.
p_adc | Pointer to an ADC instance. |
uint32_t adc_init | ( | Adc * | p_adc, |
const uint32_t | ul_mck, | ||
const uint32_t | ul_adc_clock, | ||
const enum adc_startup_time | startup | ||
) |
Initialize the given ADC with the specified ADC clock and startup time.
p_adc | Pointer to an ADC instance. |
ul_mck | Main clock of the device (value in Hz). |
ul_adc_clock | Analog-to-Digital conversion clock (value in Hz). |
uc_startup | ADC start up time. Please refer to the product datasheet for details. |
Referenced by main().
void adc_reset | ( | Adc * | p_adc | ) |
Reset ADC.
p_adc | Pointer to an ADC instance. |
void adc_set_averaging_trigger | ( | Adc * | p_adc, |
bool | multi | ||
) |
Set digital averaging trigger.
p_adc | Pointer to an ADC instance. |
multi | The average requests several trigger events if true. The average requests only one trigger event. |
void adc_set_bias_current | ( | Adc * | p_adc, |
const uint8_t | uc_ibctl | ||
) |
Adapt performance versus power consumption.
p_adc | Pointer to an ADC instance. |
ibctl | ADC Bias current control. |
void adc_set_calibmode | ( | Adc * | p_adc | ) |
Set ADC auto calibration mode.
p_adc | Pointer to an ADC instance. |
void adc_set_channel_input_gain | ( | Adc * | p_adc, |
const enum adc_channel_num_t | channel, | ||
const enum adc_gainvalue_t | gain | ||
) |
Configure input gain for the specified channel.
p_adc | Pointer to an ADC instance. |
channel | ADC channel number. |
gain | Gain value for the input. |
void adc_set_comparison_channel | ( | Adc * | p_adc, |
const enum adc_channel_num_t | channel | ||
) |
Configure comparison selected channel.
p_adc | Pointer to an ADC instance. |
channel | ADC channel number. |
Referenced by main().
void adc_set_comparison_filter | ( | Adc * | p_adc, |
uint8_t | filter | ||
) |
Set comparison filter.
p_adc | Pointer to an ADC instance. |
filter | Number of consecutive compare events necessary to raise the flag = filter + 1. |
void adc_set_comparison_mode | ( | Adc * | p_adc, |
const uint8_t | uc_mode | ||
) |
Configure comparison mode.
p_adc | Pointer to an ADC instance. |
uc_mode | ADC comparison mode. |
Referenced by main().
void adc_set_comparison_window | ( | Adc * | p_adc, |
const uint16_t | us_low_threshold, | ||
const uint16_t | us_high_threshold | ||
) |
Configure ADC compare window.
p_adc | Pointer to an ADC instance. |
w_low_threshold | Low threshold of compare window. |
w_high_threshold | High threshold of compare window. |
Referenced by main().
enum status_code adc_set_internal_reference_voltage | ( | Adc * | p_adc, |
struct adc_internal_ref * | ref | ||
) |
Set ADC analog control(internal reference voltage).
p_adc | Pointer to an ADC instance. |
ref | Pointer to an ADC internal reference voltage setup. |
References adc_internal_ref::adc_force_internal_ref, adc_internal_ref::adc_internal_ref_change_enable, adc_internal_ref::adc_internal_ref_on, ERR_INVALID_ARG, STATUS_OK, and adc_internal_ref::volt.
void adc_set_resolution | ( | Adc * | p_adc, |
const enum adc_resolution_t | resolution | ||
) |
Configure the conversion resolution.
p_adc | Pointer to an ADC instance. |
resolution | ADC resolution. |
References ADC_10_BITS, and ADC_12_BITS.
void adc_set_writeprotect | ( | Adc * | p_adc, |
const uint32_t | ul_enable | ||
) |
Enable or disable write protection of ADC registers.
p_adc | Pointer to an ADC instance. |
ul_enable | 1 to enable, 0 to disable. |
References ADC_WPMR_WPKEY_PASSWD.
void adc_start | ( | Adc * | p_adc | ) |
Start analog-to-digital conversion.
p_adc | Pointer to an ADC instance. |
void adc_start_sequencer | ( | Adc * | p_adc | ) |
Enable conversion sequencer.
p_adc | Pointer to an ADC instance. |
void adc_stop_sequencer | ( | Adc * | p_adc | ) |
Disable conversion sequencer.
p_adc | Pointer to an ADC instance. |
|
static |
calcul_startup
Referenced by adc_check().