Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Analog-to-digital Converter (ADC)

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.

Functions

void adc_disable_all_channel (Adc *p_adc)
 Disable all ADC channel. 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_interrupt (Adc *p_adc, const uint32_t ul_source)
 Disable ADC interrupts. More...
 
void adc_enable_all_channel (Adc *p_adc)
 Enable all ADC channels. 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_interrupt (Adc *p_adc, const uint32_t ul_source)
 Enable ADC interrupts. 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_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...
 
Pdc * adc_get_pdc_base (const Adc *p_adc)
 Get PDC registers base address. More...
 
void adc_reset (Adc *p_adc)
 Reset ADC. More...
 
void adc_set_resolution (Adc *p_adc, const enum adc_resolution_t resolution)
 Configure the conversion resolution. More...
 
void adc_start (Adc *p_adc)
 Start analog-to-digital conversion. More...
 

void adc_disable_all_channel ( Adc *  p_adc)

Disable all ADC channel.

Parameters
p_adcPointer to an ADC instance.
void adc_disable_channel ( Adc *  p_adc,
const enum adc_channel_num_t  adc_ch 
)

Disable the specified ADC channel.

Parameters
p_adcPointer to an ADC instance.
adc_chADC channel number.
void adc_disable_interrupt ( Adc *  p_adc,
const uint32_t  ul_source 
)

Disable ADC interrupts.

Parameters
p_adcPointer to an ADC instance.
ul_sourceInterrupts to be disabled.
void adc_enable_all_channel ( Adc *  p_adc)

Enable all ADC channels.

Parameters
p_adcPointer to an ADC instance.
void adc_enable_channel ( Adc *  p_adc,
const enum adc_channel_num_t  adc_ch 
)

Enable the specified ADC channel.

Parameters
p_adcPointer to an ADC instance.
adc_chADC channel number.

Referenced by init_specific_board().

void adc_enable_interrupt ( Adc *  p_adc,
const uint32_t  ul_source 
)

Enable ADC interrupts.

Parameters
p_adcPointer to an ADC instance.
ul_sourceInterrupts to be enabled.
uint32_t adc_get_actual_adc_clock ( const Adc *  p_adc,
const uint32_t  ul_mck 
)

Return the actual ADC clock.

Parameters
p_adcPointer to an ADC instance.
ul_mckMain clock of the device (in Hz).
Returns
The actual ADC clock (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.

Parameters
p_adcPointer to an ADC instance.
adc_chADC channel number.
Return values
1if channel is enabled.
0if 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.

Parameters
p_adcPointer to an ADC instance.
adc_chADC channel number.
Returns
ADC value of the specified channel.
uint32_t adc_get_interrupt_mask ( const Adc *  p_adc)

Read ADC interrupt mask.

Parameters
p_adcPointer to an ADC instance.
Returns
The interrupt mask value.
uint32_t adc_get_latest_value ( const Adc *  p_adc)

Read the last ADC result data.

Parameters
p_adcPointer to an ADC instance.
Returns
ADC latest value.
Pdc* adc_get_pdc_base ( const Adc *  p_adc)

Get PDC registers base address.

Parameters
p_adcPointer to an ADC instance.
Returns
ADC PDC register base address.

References UNUSED.

void adc_reset ( Adc *  p_adc)

Reset ADC.

Parameters
p_adcPointer to an ADC instance.
void adc_set_resolution ( Adc *  p_adc,
const enum adc_resolution_t  resolution 
)

Configure the conversion resolution.

Parameters
p_adcPointer to an ADC instance.
resolutionADC resolution.

References ADC_10_BITS, and ADC_12_BITS.

void adc_start ( Adc *  p_adc)

Start analog-to-digital conversion.

Note
If one of the hardware event is selected as ADC trigger, this function can NOT start analog to digital conversion.
Parameters
p_adcPointer to an ADC instance.