Analog-to-Digital Converter (ADC/ADC12B) driver for SAM.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include "adc.h"
Functions | |
void | adc12b_configure_power_save (Adc12b *p_adc, const uint8_t uc_sleep, uint8_t uc_offmode) |
Configure ADC power saving mode. More... | |
void | adc12b_configure_timing (Adc12b *p_adc, const uint32_t ul_sh) |
Configure ADC timing. More... | |
void | adc12b_configure_trigger (Adc12b *p_adc, const enum adc12b_trigger_t trigger) |
Configure conversion trigger and free run mode. More... | |
void | adc12b_disable_all_channel (Adc12b *p_adc) |
Disable all ADC channel. More... | |
void | adc12b_disable_channel (Adc12b *p_adc, const enum adc_channel_num_t adc_ch) |
Disable the specified ADC channel. More... | |
void | adc12b_disable_differential_input (Adc12b *p_adc) |
Disable differential input for the specified channel. More... | |
void | adc12b_disable_input_offset (Adc12b *p_adc) |
Disable analog signal offset for the specified channel. More... | |
void | adc12b_disable_interrupt (Adc12b *p_adc, const uint32_t ul_source) |
Disable ADC interrupts. More... | |
void | adc12b_enable_all_channel (Adc12b *p_adc) |
Enable all ADC channels. More... | |
void | adc12b_enable_channel (Adc12b *p_adc, const enum adc_channel_num_t adc_ch) |
Enable the specified ADC channel. More... | |
void | adc12b_enable_differential_input (Adc12b *p_adc) |
Enable differential input for all channels. More... | |
void | adc12b_enable_input_offset (Adc12b *p_adc) |
Enable analog signal offset for the specified channel. More... | |
void | adc12b_enable_interrupt (Adc12b *p_adc, const uint32_t ul_source) |
Enable ADC interrupts. More... | |
uint32_t | adc12b_get_actual_adc_clock (const Adc12b *p_adc, const uint32_t ul_mck) |
Return the actual ADC clock. More... | |
uint32_t | adc12b_get_channel_status (const Adc12b *p_adc, const enum adc_channel_num_t adc_ch) |
Read the ADC channel status. More... | |
uint32_t | adc12b_get_channel_value (const Adc12b *p_adc, const enum adc_channel_num_t adc_ch) |
Read the ADC result data of the specified channel. More... | |
uint32_t | adc12b_get_interrupt_mask (const Adc12b *p_adc) |
Read ADC interrupt mask. More... | |
uint32_t | adc12b_get_latest_value (const Adc12b *p_adc) |
Read the last ADC result data. More... | |
Pdc * | adc12b_get_pdc_base (const Adc12b *p_adc) |
Get PDC registers base address. More... | |
uint32_t | adc12b_get_status (const Adc12b *p_adc) |
Read ADC interrupt status. More... | |
uint32_t | adc12b_init (Adc12b *p_adc, const uint32_t ul_mck, const uint32_t ul_adc_clock, const uint32_t ul_startuptime, const uint32_t ul_offmode_startuptime) |
Initialize the given ADC with the specified ADC clock and startup time. More... | |
void | adc12b_reset (Adc12b *p_adc) |
Reset ADC. More... | |
void | adc12b_set_bias_current (Adc12b *p_adc, const uint8_t uc_ibctl) |
Adapt performance versus power consumption. More... | |
void | adc12b_set_input_gain (Adc12b *p_adc, const enum adc_gainvalue_t gain) |
Configure input gain for the specified channel. More... | |
void | adc12b_set_resolution (Adc12b *p_adc, const enum adc_resolution_t resolution) |
Configure conversion resolution. More... | |
void | adc12b_start (Adc12b *p_adc) |
Start ADC conversion. More... | |
void adc12b_configure_power_save | ( | Adc12b * | p_adc, |
const uint8_t | uc_sleep, | ||
uint8_t | uc_offmode | ||
) |
Configure 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_offmode | 0 Standby Mode (if Sleep Bit = 1), 1 Off Mode. |
void adc12b_configure_timing | ( | Adc12b * | p_adc, |
const uint32_t | ul_sh | ||
) |
Configure ADC timing.
p_adc | Pointer to an ADC instance. |
ul_sh | ADC sample and hold time = uc_sh / ADC clock. |
void adc12b_configure_trigger | ( | Adc12b * | p_adc, |
const enum adc12b_trigger_t | trigger | ||
) |
Configure conversion trigger and free run mode.
p_adc | Pointer to an ADC instance. |
trigger | Conversion trigger. |
void adc12b_disable_all_channel | ( | Adc12b * | p_adc | ) |
Disable all ADC channel.
p_adc | Pointer to an ADC instance. |
void adc12b_disable_channel | ( | Adc12b * | 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 adc12b_disable_differential_input | ( | Adc12b * | p_adc | ) |
Disable differential input for the specified channel.
p_adc | Pointer to an ADC instance. |
void adc12b_disable_input_offset | ( | Adc12b * | p_adc | ) |
Disable analog signal offset for the specified channel.
p_adc | Pointer to an ADC instance. |
void adc12b_disable_interrupt | ( | Adc12b * | p_adc, |
const uint32_t | ul_source | ||
) |
Disable ADC interrupts.
p_adc | Pointer to an ADC instance. |
ul_source | Interrupts to be disabled. |
void adc12b_enable_all_channel | ( | Adc12b * | p_adc | ) |
Enable all ADC channels.
p_adc | Pointer to an ADC instance. |
void adc12b_enable_channel | ( | Adc12b * | 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. |
void adc12b_enable_differential_input | ( | Adc12b * | p_adc | ) |
Enable differential input for all channels.
p_adc | Pointer to an ADC instance. |
void adc12b_enable_input_offset | ( | Adc12b * | p_adc | ) |
Enable analog signal offset for the specified channel.
p_adc | Pointer to an ADC instance. |
void adc12b_enable_interrupt | ( | Adc12b * | p_adc, |
const uint32_t | ul_source | ||
) |
Enable ADC interrupts.
p_adc | Pointer to an ADC instance. |
ul_source | Interrupts to be enabled. |
uint32_t adc12b_get_actual_adc_clock | ( | const Adc12b * | 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). |
0 | The actual ADC clock (in Hz). |
uint32_t adc12b_get_channel_status | ( | const Adc12b * | 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 adc12b_get_channel_value | ( | const Adc12b * | 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. |
uint32_t adc12b_get_interrupt_mask | ( | const Adc12b * | p_adc | ) |
Read ADC interrupt mask.
p_adc | Pointer to an ADC instance. |
uint32_t adc12b_get_latest_value | ( | const Adc12b * | p_adc | ) |
Read the last ADC result data.
p_adc | Pointer to an ADC instance. |
Pdc* adc12b_get_pdc_base | ( | const Adc12b * | p_adc | ) |
Get PDC registers base address.
p_adc | Pointer to an ADC instance. |
References UNUSED.
uint32_t adc12b_get_status | ( | const Adc12b * | p_adc | ) |
Read ADC interrupt status.
p_adc | Pointer to an ADC instance. |
ADC | interrupt status. |
uint32_t adc12b_init | ( | Adc12b * | p_adc, |
const uint32_t | ul_mck, | ||
const uint32_t | ul_adc_clock, | ||
const uint32_t | ul_startuptime, | ||
const uint32_t | ul_offmode_startuptime | ||
) |
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 (in Hz). |
ul_adc_clock | Analog-to-Digital conversion clock (in Hz). |
ul_startuptime | ADC startup time value (value in us). Please refer to the product datasheet for more details. |
ul_offmode_startuptime | ADC off mode startup time value (value in us). Please refer to the product datasheet for more details. |
void adc12b_reset | ( | Adc12b * | p_adc | ) |
Reset ADC.
p_adc | Pointer to an ADC instance. |
void adc12b_set_bias_current | ( | Adc12b * | p_adc, |
const uint8_t | uc_ibctl | ||
) |
Adapt performance versus power consumption.
p_adc | Pointer to an ADC instance. |
uc_ibctl | ADC Bias current control. |
void adc12b_set_input_gain | ( | Adc12b * | p_adc, |
const enum adc_gainvalue_t | gain | ||
) |
Configure input gain for the specified channel.
p_adc | Pointer to an ADC instance. |
gain | Gain value for the input. |
void adc12b_set_resolution | ( | Adc12b * | p_adc, |
const enum adc_resolution_t | resolution | ||
) |
Configure conversion resolution.
p_adc | Pointer to an ADC instance. |
resolution | ADC resolution. |
void adc12b_start | ( | Adc12b * | p_adc | ) |
Start ADC conversion.
p_adc | Pointer to an ADC instance. |