38#ifndef LIBOPENCM3_ADC_H
39#define LIBOPENCM3_ADC_H
46#define ADC_JOFR1(block) MMIO32((block) + 0x14)
47#define ADC_JOFR2(block) MMIO32((block) + 0x18)
48#define ADC_JOFR3(block) MMIO32((block) + 0x1c)
49#define ADC_JOFR4(block) MMIO32((block) + 0x20)
52#define ADC_HTR(block) MMIO32((block) + 0x24)
55#define ADC_LTR(block) MMIO32((block) + 0x28)
58#define ADC_SQR1(block) MMIO32((block) + 0x2c)
61#define ADC_SQR2(block) MMIO32((block) + 0x30)
64#define ADC_SQR3(block) MMIO32((block) + 0x34)
67#define ADC_JSQR(block) MMIO32((block) + 0x38)
70#define ADC_JDR1(block) MMIO32((block) + 0x3c)
71#define ADC_JDR2(block) MMIO32((block) + 0x40)
72#define ADC_JDR3(block) MMIO32((block) + 0x44)
73#define ADC_JDR4(block) MMIO32((block) + 0x48)
76#define ADC_DR(block) MMIO32((block) + 0x4c)
103#define ADC_CR1_DUALMOD_IND (0x0 << 16)
105#define ADC_CR1_DUALMOD_CRSISM (0x1 << 16)
107#define ADC_CR1_DUALMOD_CRSATM (0x2 << 16)
109#define ADC_CR1_DUALMOD_CISFIM (0x3 << 16)
111#define ADC_CR1_DUALMOD_CISSIM (0x4 << 16)
113#define ADC_CR1_DUALMOD_ISM (0x5 << 16)
115#define ADC_CR1_DUALMOD_RSM (0x6 << 16)
117#define ADC_CR1_DUALMOD_FIM (0x7 << 16)
119#define ADC_CR1_DUALMOD_SIM (0x8 << 16)
121#define ADC_CR1_DUALMOD_ATM (0x9 << 16)
123#define ADC_CR1_DUALMOD_MASK (0xF << 16)
124#define ADC_CR1_DUALMOD_SHIFT 16
126#define ADC_CR1_AWDCH_MAX 17
131#define ADC_CR2_TSVREFE (1 << 23)
134#define ADC_CR2_SWSTART (1 << 22)
137#define ADC_CR2_JSWSTART (1 << 21)
140#define ADC_CR2_EXTTRIG (1 << 20)
151#define ADC_CR2_EXTSEL_TIM1_CC1 (0x0 << 17)
153#define ADC_CR2_EXTSEL_TIM1_CC2 (0x1 << 17)
155#define ADC_CR2_EXTSEL_TIM1_CC3 (0x2 << 17)
157#define ADC_CR2_EXTSEL_TIM2_CC2 (0x3 << 17)
159#define ADC_CR2_EXTSEL_TIM3_TRGO (0x4 << 17)
161#define ADC_CR2_EXTSEL_TIM4_CC4 (0x5 << 17)
163#define ADC_CR2_EXTSEL_EXTI11 (0x6 << 17)
165#define ADC_CR2_EXTSEL_SWSTART (0x7 << 17)
176#define ADC_CR2_EXTSEL_TIM3_CC1 (0x0 << 17)
178#define ADC_CR2_EXTSEL_TIM2_CC3 (0x1 << 17)
180#define ADC_CR2_EXTSEL_TIM1_CC3 (0x2 << 17)
182#define ADC_CR2_EXTSEL_TIM8_CC1 (0x3 << 17)
184#define ADC_CR2_EXTSEL_TIM8_TRGO (0x4 << 17)
186#define ADC_CR2_EXTSEL_TIM5_CC1 (0x5 << 17)
188#define ADC_CR2_EXTSEL_TIM5_CC3 (0x6 << 17)
191#define ADC_CR2_EXTSEL_MASK (0x7 << 17)
192#define ADC_CR2_EXTSEL_SHIFT 17
197#define ADC_CR2_JEXTTRIG (1 << 15)
209#define ADC_CR2_JEXTSEL_TIM1_TRGO (0x0 << 12)
211#define ADC_CR2_JEXTSEL_TIM1_CC4 (0x1 << 12)
213#define ADC_CR2_JEXTSEL_TIM2_TRGO (0x2 << 12)
215#define ADC_CR2_JEXTSEL_TIM2_CC1 (0x3 << 12)
217#define ADC_CR2_JEXTSEL_TIM3_CC4 (0x4 << 12)
219#define ADC_CR2_JEXTSEL_TIM4_TRGO (0x5 << 12)
221#define ADC_CR2_JEXTSEL_EXTI15 (0x6 << 12)
223#define ADC_CR2_JEXTSEL_JSWSTART (0x7 << 12)
234#define ADC_CR2_JEXTSEL_TIM1_TRGO (0x0 << 12)
236#define ADC_CR2_JEXTSEL_TIM1_CC4 (0x1 << 12)
238#define ADC_CR2_JEXTSEL_TIM4_CC3 (0x2 << 12)
240#define ADC_CR2_JEXTSEL_TIM8_CC2 (0x3 << 12)
242#define ADC_CR2_JEXTSEL_TIM8_CC4 (0x4 << 12)
244#define ADC_CR2_JEXTSEL_TIM5_TRGO (0x5 << 12)
246#define ADC_CR2_JEXTSEL_TIM5_CC4 (0x6 << 12)
248#define ADC_CR2_JEXTSEL_JSWSTART (0x7 << 12)
251#define ADC_CR2_JEXTSEL_MASK (0x7 << 12)
252#define ADC_CR2_JEXTSEL_SHIFT 12
255#define ADC_CR2_ALIGN_RIGHT (0 << 11)
256#define ADC_CR2_ALIGN_LEFT (1 << 11)
257#define ADC_CR2_ALIGN (1 << 11)
262#define ADC_CR2_DMA (1 << 8)
267#define ADC_CR2_RSTCAL (1 << 3)
270#define ADC_CR2_CAL (1 << 2)
273#define ADC_CR2_CONT (1 << 1)
281#define ADC_CR2_ADON (1 << 0)
284#define ADC_SMPR1_SMP17_LSB 21
285#define ADC_SMPR1_SMP16_LSB 18
286#define ADC_SMPR1_SMP15_LSB 15
287#define ADC_SMPR1_SMP14_LSB 12
288#define ADC_SMPR1_SMP13_LSB 9
289#define ADC_SMPR1_SMP12_LSB 6
290#define ADC_SMPR1_SMP11_LSB 3
291#define ADC_SMPR1_SMP10_LSB 0
292#define ADC_SMPR1_SMP17_MSK (0x7 << ADC_SMPR1_SMP17_LSB)
293#define ADC_SMPR1_SMP16_MSK (0x7 << ADC_SMPR1_SMP16_LSB)
294#define ADC_SMPR1_SMP15_MSK (0x7 << ADC_SMPR1_SMP15_LSB)
295#define ADC_SMPR1_SMP14_MSK (0x7 << ADC_SMPR1_SMP14_LSB)
296#define ADC_SMPR1_SMP13_MSK (0x7 << ADC_SMPR1_SMP13_LSB)
297#define ADC_SMPR1_SMP12_MSK (0x7 << ADC_SMPR1_SMP12_LSB)
298#define ADC_SMPR1_SMP11_MSK (0x7 << ADC_SMPR1_SMP11_LSB)
299#define ADC_SMPR1_SMP10_MSK (0x7 << ADC_SMPR1_SMP10_LSB)
303#define ADC_SMPR2_SMP9_LSB 27
304#define ADC_SMPR2_SMP8_LSB 24
305#define ADC_SMPR2_SMP7_LSB 21
306#define ADC_SMPR2_SMP6_LSB 18
307#define ADC_SMPR2_SMP5_LSB 15
308#define ADC_SMPR2_SMP4_LSB 12
309#define ADC_SMPR2_SMP3_LSB 9
310#define ADC_SMPR2_SMP2_LSB 6
311#define ADC_SMPR2_SMP1_LSB 3
312#define ADC_SMPR2_SMP0_LSB 0
313#define ADC_SMPR2_SMP9_MSK (0x7 << ADC_SMPR2_SMP9_LSB)
314#define ADC_SMPR2_SMP8_MSK (0x7 << ADC_SMPR2_SMP8_LSB)
315#define ADC_SMPR2_SMP7_MSK (0x7 << ADC_SMPR2_SMP7_LSB)
316#define ADC_SMPR2_SMP6_MSK (0x7 << ADC_SMPR2_SMP6_LSB)
317#define ADC_SMPR2_SMP5_MSK (0x7 << ADC_SMPR2_SMP5_LSB)
318#define ADC_SMPR2_SMP4_MSK (0x7 << ADC_SMPR2_SMP4_LSB)
319#define ADC_SMPR2_SMP3_MSK (0x7 << ADC_SMPR2_SMP3_LSB)
320#define ADC_SMPR2_SMP2_MSK (0x7 << ADC_SMPR2_SMP2_LSB)
321#define ADC_SMPR2_SMP1_MSK (0x7 << ADC_SMPR2_SMP1_LSB)
322#define ADC_SMPR2_SMP0_MSK (0x7 << ADC_SMPR2_SMP0_LSB)
331#define ADC_SMPR_SMP_1DOT5CYC 0x0
332#define ADC_SMPR_SMP_7DOT5CYC 0x1
333#define ADC_SMPR_SMP_13DOT5CYC 0x2
334#define ADC_SMPR_SMP_28DOT5CYC 0x3
335#define ADC_SMPR_SMP_41DOT5CYC 0x4
336#define ADC_SMPR_SMP_55DOT5CYC 0x5
337#define ADC_SMPR_SMP_71DOT5CYC 0x6
338#define ADC_SMPR_SMP_239DOT5CYC 0x7
344#define ADC_SQR_MAX_CHANNELS_REGULAR 16
346#define ADC_SQR1_SQ16_LSB 15
347#define ADC_SQR1_SQ15_LSB 10
348#define ADC_SQR1_SQ14_LSB 5
349#define ADC_SQR1_SQ13_LSB 0
350#define ADC_SQR1_L_MSK (0xf << ADC_SQR1_L_LSB)
351#define ADC_SQR1_SQ16_MSK (0x1f << ADC_SQR1_SQ16_LSB)
352#define ADC_SQR1_SQ15_MSK (0x1f << ADC_SQR1_SQ15_LSB)
353#define ADC_SQR1_SQ14_MSK (0x1f << ADC_SQR1_SQ14_LSB)
354#define ADC_SQR1_SQ13_MSK (0x1f << ADC_SQR1_SQ13_LSB)
358#define ADC_SQR2_SQ12_LSB 25
359#define ADC_SQR2_SQ11_LSB 20
360#define ADC_SQR2_SQ10_LSB 15
361#define ADC_SQR2_SQ9_LSB 10
362#define ADC_SQR2_SQ8_LSB 5
363#define ADC_SQR2_SQ7_LSB 0
364#define ADC_SQR2_SQ12_MSK (0x1f << ADC_SQR2_SQ12_LSB)
365#define ADC_SQR2_SQ11_MSK (0x1f << ADC_SQR2_SQ11_LSB)
366#define ADC_SQR2_SQ10_MSK (0x1f << ADC_SQR2_SQ10_LSB)
367#define ADC_SQR2_SQ9_MSK (0x1f << ADC_SQR2_SQ9_LSB)
368#define ADC_SQR2_SQ8_MSK (0x1f << ADC_SQR2_SQ8_LSB)
369#define ADC_SQR2_SQ7_MSK (0x1f << ADC_SQR2_SQ7_LSB)
373#define ADC_SQR3_SQ6_LSB 25
374#define ADC_SQR3_SQ5_LSB 20
375#define ADC_SQR3_SQ4_LSB 15
376#define ADC_SQR3_SQ3_LSB 10
377#define ADC_SQR3_SQ2_LSB 5
378#define ADC_SQR3_SQ1_LSB 0
379#define ADC_SQR3_SQ6_MSK (0x1f << ADC_SQR3_SQ6_LSB)
380#define ADC_SQR3_SQ5_MSK (0x1f << ADC_SQR3_SQ5_LSB)
381#define ADC_SQR3_SQ4_MSK (0x1f << ADC_SQR3_SQ4_LSB)
382#define ADC_SQR3_SQ3_MSK (0x1f << ADC_SQR3_SQ3_LSB)
383#define ADC_SQR3_SQ2_MSK (0x1f << ADC_SQR3_SQ2_LSB)
384#define ADC_SQR3_SQ1_MSK (0x1f << ADC_SQR3_SQ1_LSB)
388#define ADC_JDATA_LSB 0
389#define ADC_DATA_LSB 0
390#define ADC_ADC2DATA_LSB 16
391#define ADC_JDATA_MSK (0xffff << ADC_JDATA_LSB)
392#define ADC_DATA_MSK (0xffff << ADC_DA)
393#define ADC_ADC2DATA_MSK (0xffff << ADC_ADC2DATA_LSB)
400#define ADC_CHANNEL_TEMP 16
401#define ADC_CHANNEL_VREF 17
#define LIBOPENCM3_DEPRECATED(x)
void adc_disable_temperature_sensor(void)
ADC Disable The Temperature Sensor.
void adc_calibrate_async(uint32_t adc)
Start the ADC calibration and immediately return.
bool adc_is_calibrating(uint32_t adc)
Is the ADC Calibrating?
void adc_calibration(uint32_t adc) LIBOPENCM3_DEPRECATED("see adc_calibrate/_async")
ADC Calibration.
void adc_start_conversion_direct(uint32_t adc)
ADC Start a Conversion Without Trigger.
void adc_reset_calibration(uint32_t adc)
ADC Initialize Calibration Registers.
void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger)
ADC Enable an External Trigger for Injected Channels.
void adc_enable_temperature_sensor(void)
ADC Enable The Temperature Sensor.
void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger)
ADC Enable an External Trigger for Regular Channels.
void adc_set_dual_mode(uint32_t mode)
ADC Set Dual A/D Mode.
void adc_calibrate(uint32_t adc)
Start ADC calibration and wait for it to finish.