30 #ifndef ADC_H_INCLUDED 31 #define ADC_H_INCLUDED 44 #define ADC_FREQ_MAX 20000000 46 #define ADC_FREQ_MIN 1000000 48 #define ADC_STARTUP_NORM 40 50 #define ADC_STARTUP_FAST 12 53 #if SAM3S_SERIES || SAM4S_SERIES || SAM3XA_SERIES 54 enum adc_resolution_t {
59 enum adc_resolution_t {
64 enum adc_resolution_t {
82 #
if SAM3S_SERIES || SAM4S_SERIES || SAM3XA_SERIES || SAM3U_SERIES
90 #if SAM3S_SERIES || SAM4S_SERIES || SAM3N_SERIES || SAM3XA_SERIES 92 enum adc_channel_num_t {
108 ADC_TEMPERATURE_SENSOR = 15,
112 enum adc_channel_num_t {
124 enum adc_gainvalue_t{
131 #if SAM3S_SERIES || SAM4S_SERIES || SAM3XA_SERIES 132 enum adc_settling_time_t{
140 #if SAM3S_SERIES || SAM4S_SERIES || SAM3N_SERIES || SAM3XA_SERIES 141 uint32_t adc_init(
Adc *p_adc,
const uint32_t ul_mck,
142 const uint32_t ul_adc_clock,
const uint8_t uc_startup);
143 void adc_configure_trigger(
Adc *p_adc,
const enum adc_trigger_t trigger,
144 const uint8_t uc_freerun);
145 void adc_configure_power_save(
Adc *p_adc,
const uint8_t uc_sleep,
const uint8_t uc_fwup);
146 void adc_configure_sequence(
Adc *p_adc,
const enum adc_channel_num_t ch_list[],
147 const uint8_t uc_num);
148 void adc_enable_tag(
Adc *p_adc);
149 void adc_disable_tag(
Adc *p_adc);
150 enum adc_channel_num_t adc_get_tag(
const Adc *p_adc);
151 void adc_start_sequencer(
Adc *p_adc);
152 void adc_stop_sequencer(
Adc *p_adc);
153 void adc_set_comparison_mode(
Adc *p_adc,
const uint8_t uc_mode);
154 uint32_t adc_get_comparison_mode(
const Adc *p_adc);
155 void adc_set_comparison_window(
Adc *p_adc,
const uint16_t us_low_threshold,
156 const uint16_t us_high_threshold);
157 void adc_set_comparison_channel(
Adc *p_adc,
const enum adc_channel_num_t channel);
158 void adc_set_writeprotect(
Adc *p_adc,
const uint32_t ul_enable);
159 uint32_t adc_get_writeprotect_status(
const Adc *p_adc);
160 void adc_check(
Adc* p_adc,
const uint32_t ul_mck);
161 uint32_t adc_get_overrun_status(
const Adc *p_adc);
163 uint32_t adc_init(
Adc * p_adc,
const uint32_t ul_mck,
const uint32_t ul_adc_clock,
164 const uint32_t ul_startuptime);
165 void adc_configure_trigger(
Adc *p_adc,
const enum adc_trigger_t trigger);
166 void adc_configure_power_save(
Adc *p_adc,
const uint8_t uc_sleep);
182 uint32_t adc_get_status(
const Adc *p_adc);
186 #if SAM3S_SERIES || SAM4S_SERIES || SAM3XA_SERIES 187 void adc_configure_timing(
Adc *p_adc,
const uint8_t uc_tracking,
188 const enum adc_settling_time_t settling,
const uint8_t uc_transfer);
189 void adc_enable_anch(
Adc *p_adc );
190 void adc_disable_anch(
Adc *p_adc );
191 void adc_enable_channel_differential_input(
Adc *p_adc,
const enum adc_channel_num_t channel);
192 void adc_disable_channel_differential_input(
Adc *p_adc,
const enum adc_channel_num_t channel);
193 void adc_enable_channel_input_offset(
Adc *p_adc,
const enum adc_channel_num_t channel);
194 void adc_disable_channel_input_offset(
Adc *p_adc,
const enum adc_channel_num_t channel);
195 void adc_set_channel_input_gain(
Adc *p_adc,
const enum adc_channel_num_t channel,
196 const enum adc_gainvalue_t uc_gain);
197 void adc_set_bias_current(
Adc *p_adc,
const uint8_t uc_ibctl);
198 void adc_enable_ts(
Adc *p_adc);
199 void adc_disable_ts(
Adc *p_adc);
201 void adc_configure_timing(
Adc *p_adc,
const uint8_t uc_tracking);
203 void adc_configure_timing(
Adc *p_adc,
const uint32_t ul_sh);
206 #if SAM3SD8_SERIES || SAM4S_SERIES 207 void adc_set_calibmode(
Adc *p_adc);
211 uint32_t adc12b_init(
Adc12b *p_adc,
const uint32_t ul_mck,
const uint32_t ul_adc_clock,
212 const uint32_t ul_startuptime,
const uint32_t ul_offmode_startuptime);
213 void adc12b_set_resolution(
Adc12b *p_adc,
const enum adc_resolution_t resolution);
214 void adc12b_configure_trigger(
Adc12b *p_adc,
const enum adc_trigger_t trigger);
215 void adc12b_configure_power_save(
Adc12b *p_adc,
const uint8_t uc_sleep,
const uint8_t uc_offmode);
216 void adc12b_configure_timing(
Adc12b *p_adc,
const uint32_t ul_sh);
217 void adc12b_start(
Adc12b *p_adc);
218 void adc12b_stop(
Adc12b *p_adc);
219 void adc12b_enable_channel(
Adc12b *p_adc,
const enum adc_channel_num_t adc_ch);
220 void adc12b_disable_channel(
Adc12b *p_adc,
const enum adc_channel_num_t adc_ch);
221 void adc12b_enable_all_channel(
Adc12b *p_adc);
222 void adc12b_disable_all_channel(
Adc12b *p_adc);
223 uint32_t adc12b_get_channel_status(
const Adc12b *p_adc,
const enum adc_channel_num_t adc_ch);
224 uint32_t adc12b_get_channel_value(
const Adc12b *p_adc,
const enum adc_channel_num_t adc_ch);
225 uint32_t adc12b_get_latest_value(
const Adc12b *p_adc);
226 void adc12b_enable_differential_input(
Adc12b *p_adc);
227 void adc12b_disable_differential_input(
Adc12b *p_adc);
228 void adc12b_enable_input_offset(
Adc12b *p_adc);
229 void adc12b_disable_input_offset(
Adc12b *p_adc);
230 void adc12b_set_input_gain(
Adc12b *p_adc,
const enum adc_gainvalue_t uc_gain);
231 uint32_t adc12b_get_actual_adc_clock(
const Adc12b *p_adc,
const uint32_t ul_mck);
232 void adc12b_enable_interrupt(
Adc12b *p_adc,
const uint32_t ul_source);
233 void adc12b_disable_interrupt(
Adc12b *p_adc,
const uint32_t ul_source);
234 uint32_t adc12b_get_interrupt_mask(
const Adc12b *p_adc);
235 uint32_t adc12b_get_status(
const Adc12b *p_adc);
236 void adc12b_set_bias_current(
Adc12b *p_adc,
const uint8_t uc_ibctl);
237 Pdc *adc12b_get_pdc_base(
const Adc12b *p_adc);
#define ADC_MR_TRGSEL_ADC_TRIG5
(ADC_MR) PWM Event Line 1
Definition: component_adc.h:92
Pdc * adc_get_pdc_base(const Adc *p_adc)
Get PDC registers base address.
Definition: adc.c:970
#define ADC12B_MR_LOWRES_BITS_10
(ADC12B_MR) 10-bit resolution
Definition: component_adc12b.h:86
#define ADC_MR_LOWRES_BITS_12
(ADC_MR) 12-bit resolution
Definition: component_adc.h:94
void adc_enable_all_channel(Adc *p_adc)
Enable all ADC channels.
Definition: adc.c:402
void adc_disable_all_channel(Adc *p_adc)
Disable all ADC channel.
Definition: adc.c:427
uint32_t adc_get_interrupt_mask(const Adc *p_adc)
Read ADC interrupt mask.
Definition: adc.c:781
#define ADC_MR_TRGEN
(ADC_MR) Trigger Enable
Definition: component_adc.h:79
void adc_disable_interrupt(Adc *p_adc, const uint32_t ul_source)
Disable ADC interrupts.
Definition: adc.c:731
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.
Definition: adc.c:458
void adc_enable_channel(Adc *p_adc, const enum adc_channel_num_t adc_ch)
Enable the specified ADC channel.
Definition: adc.c:392
#define ADC_MR_SETTLING_AST3
(ADC_MR) 3 periods of ADCClock
Definition: component_adc.h:128
Pdc hardware registers.
Definition: component_pdc.h:41
#define ADC_MR_TRGSEL_ADC_TRIG2
(ADC_MR) TIO Output of the Timer Counter Channel 1
Definition: component_adc.h:86
void adc_set_resolution(Adc *p_adc, const enum adc_resolution_t resolution)
Configure the conversion resolution.
Definition: adc.c:176
#define ADC_MR_SETTLING_AST17
(ADC_MR) 17 periods of ADCClock
Definition: component_adc.h:131
#define ADC_MR_TRGEN_DIS
(ADC_MR) Hardware triggers are disabled. Starting a conversion is only possible by software...
Definition: component_adc.h:80
#define ADC12B_MR_LOWRES_BITS_12
(ADC12B_MR) 12-bit resolution
Definition: component_adc12b.h:85
#define ADC_MR_TRGSEL_ADC_TRIG1
(ADC_MR) TIO Output of the Timer Counter Channel 0
Definition: component_adc.h:85
void adc_disable_channel(Adc *p_adc, const enum adc_channel_num_t adc_ch)
Disable the specified ADC channel.
Definition: adc.c:417
#define ADC_MR_LOWRES_BITS_8
(ADC_MR) 8-bit resolution
Definition: component_adc.h:90
#define ADC_MR_TRGSEL_ADC_TRIG0
(ADC_MR) External trigger
Definition: component_adc.h:84
Adc12b hardware registers.
Definition: component_adc12b.h:41
void adc_start(Adc *p_adc)
Start analog-to-digital conversion.
Definition: adc.c:371
uint32_t adc_get_channel_status(const Adc *p_adc, const enum adc_channel_num_t adc_ch)
Read the ADC channel status.
Definition: adc.c:445
#define ADC_MR_TRGSEL_Msk
(ADC_MR) Trigger Selection
Definition: component_adc.h:83
#define ADC_MR_TRGSEL_ADC_TRIG4
(ADC_MR) PWM Event Line 0
Definition: component_adc.h:91
void adc_stop(Adc *p_adc)
Stop analog-to-digital conversion.
Definition: adc.c:381
#define ADC_MR_TRGSEL_ADC_TRIG3
(ADC_MR) TIO Output of the Timer Counter Channel 2
Definition: component_adc.h:87
#define ADC_MR_LOWRES_BITS_10
(ADC_MR) 10-bit resolution
Definition: component_adc.h:89
#define ADC_MR_SETTLING_AST5
(ADC_MR) 5 periods of ADCClock
Definition: component_adc.h:129
Adc hardware registers.
Definition: component_adc.h:41
uint32_t adc_get_actual_adc_clock(const Adc *p_adc, const uint32_t ul_mck)
Return the actual ADC clock.
Definition: adc.c:703
uint32_t adc_get_latest_value(const Adc *p_adc)
Read the last ADC result data.
Definition: adc.c:476
#define ADC_MR_SETTLING_AST9
(ADC_MR) 9 periods of ADCClock
Definition: component_adc.h:130
void adc_enable_interrupt(Adc *p_adc, const uint32_t ul_source)
Enable ADC interrupts.
Definition: adc.c:720