34#ifdef LIBOPENCM3_ADC_H
36#ifndef LIBOPENCM3_ADC_COMMON_V1_MULTI_H
37#define LIBOPENCM3_ADC_COMMON_V1_MULTI_H
45#define ADC_COMMON_REGISTERS_BASE (ADC1_BASE+0x300)
46#define ADC_CSR MMIO32(ADC_COMMON_REGISTERS_BASE + 0x0)
47#define ADC_CCR MMIO32(ADC_COMMON_REGISTERS_BASE + 0x4)
48#define ADC_CDR MMIO32(ADC_COMMON_REGISTERS_BASE + 0x8)
60#define ADC_SR_OVR (1 << 5)
64#define ADC_CR1_OVRIE (1 << 26)
72#define ADC_CR1_RES_12BIT (0x0 << 24)
73#define ADC_CR1_RES_10BIT (0x1 << 24)
74#define ADC_CR1_RES_8BIT (0x2 << 24)
75#define ADC_CR1_RES_6BIT (0x3 << 24)
77#define ADC_CR1_RES_MASK (0x3 << 24)
78#define ADC_CR1_RES_SHIFT 24
87#define ADC_CR2_SWSTART (1 << 30)
91#define ADC_CR2_EXTEN_SHIFT 28
92#define ADC_CR2_EXTEN_MASK (0x3 << ADC_CR2_EXTEN_SHIFT)
96#define ADC_CR2_EXTEN_DISABLED (0x0 << ADC_CR2_EXTEN_SHIFT)
97#define ADC_CR2_EXTEN_RISING_EDGE (0x1 << ADC_CR2_EXTEN_SHIFT)
98#define ADC_CR2_EXTEN_FALLING_EDGE (0x2 << ADC_CR2_EXTEN_SHIFT)
99#define ADC_CR2_EXTEN_BOTH_EDGES (0x3 << ADC_CR2_EXTEN_SHIFT)
105#define ADC_CR2_EXTSEL_MASK (0xF << 24)
106#define ADC_CR2_EXTSEL_SHIFT 24
111#define ADC_CR2_JSWSTART (1 << 22)
115#define ADC_CR2_JEXTEN_SHIFT 20
116#define ADC_CR2_JEXTEN_MASK (0x3 << ADC_CR2_JEXTEN_SHIFT)
120#define ADC_CR2_JEXTEN_DISABLED (0x0 << ADC_CR2_JEXTEN_SHIFT)
121#define ADC_CR2_JEXTEN_RISING_EDGE (0x1 << ADC_CR2_JEXTEN_SHIFT)
122#define ADC_CR2_JEXTEN_FALLING_EDGE (0x2 << ADC_CR2_JEXTEN_SHIFT)
123#define ADC_CR2_JEXTEN_BOTH_EDGES (0x3 << ADC_CR2_JEXTEN_SHIFT)
129#define ADC_CR2_JEXTSEL_SHIFT 16
130#define ADC_CR2_JEXTSEL_MASK (0xF << ADC_CR2_JEXTSEL_SHIFT)
133#define ADC_CR2_ALIGN_RIGHT (0 << 11)
134#define ADC_CR2_ALIGN_LEFT (1 << 11)
135#define ADC_CR2_ALIGN (1 << 11)
138#define ADC_CR2_EOCS (1 << 10)
141#define ADC_CR2_DDS (1 << 9)
144#define ADC_CR2_DMA (1 << 8)
149#define ADC_CR2_CONT (1 << 1)
157#define ADC_CR2_ADON (1 << 0)
163#define ADC_SQRx_MASK 0x1f
167#define ADC_JDATA_LSB 0
168#define ADC_DATA_LSB 0
169#define ADC_JDATA_MSK (0xffff << ADC_JDATA_LSB)
170#define ADC_DATA_MSK (0xffff << ADC_DA)
177#define ADC_CSR_OVR3 (1 << 21)
180#define ADC_CSR_STRT3 (1 << 20)
183#define ADC_CSR_JSTRT3 (1 << 19)
186#define ADC_CSR_JEOC3 (1 << 18)
189#define ADC_CSR_EOC3 (1 << 17)
192#define ADC_CSR_AWD3 (1 << 16)
197#define ADC_CSR_OVR2 (1 << 13)
200#define ADC_CSR_STRT2 (1 << 12)
203#define ADC_CSR_JSTRT2 (1 << 11)
206#define ADC_CSR_JEOC2 (1 << 10)
209#define ADC_CSR_EOC2 (1 << 9)
212#define ADC_CSR_AWD2 (1 << 8)
217#define ADC_CSR_OVR1 (1 << 5)
220#define ADC_CSR_STRT1 (1 << 4)
223#define ADC_CSR_JSTRT1 (1 << 3)
226#define ADC_CSR_JEOC1 (1 << 2)
229#define ADC_CSR_EOC1 (1 << 1)
232#define ADC_CSR_AWD1 (1 << 0)
237#define ADC_CCR_TSVREFE (1 << 23)
240#define ADC_CCR_VBATE (1 << 22)
250#define ADC_CCR_DMA_DISABLE (0x0 << 14)
251#define ADC_CCR_DMA_MODE_1 (0x1 << 14)
252#define ADC_CCR_DMA_MODE_2 (0x2 << 14)
253#define ADC_CCR_DMA_MODE_3 (0x3 << 14)
255#define ADC_CCR_DMA_MASK (0x3 << 14)
256#define ADC_CCR_DMA_SHIFT 14
259#define ADC_CCR_DDS (1 << 13)
269#define ADC_CCR_DELAY_5ADCCLK (0x0 << 8)
270#define ADC_CCR_DELAY_6ADCCLK (0x1 << 8)
271#define ADC_CCR_DELAY_7ADCCLK (0x2 << 8)
272#define ADC_CCR_DELAY_8ADCCLK (0x3 << 8)
273#define ADC_CCR_DELAY_9ADCCLK (0x4 << 8)
274#define ADC_CCR_DELAY_10ADCCLK (0x5 << 8)
275#define ADC_CCR_DELAY_11ADCCLK (0x6 << 8)
276#define ADC_CCR_DELAY_12ADCCLK (0x7 << 8)
277#define ADC_CCR_DELAY_13ADCCLK (0x8 << 8)
278#define ADC_CCR_DELAY_14ADCCLK (0x9 << 8)
279#define ADC_CCR_DELAY_15ADCCLK (0xa << 8)
280#define ADC_CCR_DELAY_16ADCCLK (0xb << 8)
281#define ADC_CCR_DELAY_17ADCCLK (0xc << 8)
282#define ADC_CCR_DELAY_18ADCCLK (0xd << 8)
283#define ADC_CCR_DELAY_19ADCCLK (0xe << 8)
284#define ADC_CCR_DELAY_20ADCCLK (0xf << 8)
286#define ADC_CCR_DELAY_MASK (0xf << 8)
287#define ADC_CCR_DELAY_SHIFT 8
299#define ADC_CCR_MULTI_INDEPENDENT (0x00 << 0)
306#define ADC_CCR_MULTI_DUAL_REG_SIMUL_AND_INJECTED_SIMUL (0x01 << 0)
311#define ADC_CCR_MULTI_DUAL_REG_SIMUL_AND_ALTERNATE_TRIG (0x02 << 0)
313#define ADC_CCR_MULTI_DUAL_INJECTED_SIMUL (0x05 << 0)
315#define ADC_CCR_MULTI_DUAL_REGULAR_SIMUL (0x06 << 0)
317#define ADC_CCR_MULTI_DUAL_INTERLEAVED (0x07 << 0)
319#define ADC_CCR_MULTI_DUAL_ALTERNATE_TRIG (0x09 << 0)
326#define ADC_CCR_MULTI_TRIPLE_REG_SIMUL_AND_INJECTED_SIMUL (0x11 << 0)
331#define ADC_CCR_MULTI_TRIPLE_REG_SIMUL_AND_ALTERNATE_TRIG (0x12 << 0)
333#define ADC_CCR_MULTI_TRIPLE_INJECTED_SIMUL (0x15 << 0)
335#define ADC_CCR_MULTI_TRIPLE_REGULAR_SIMUL (0x16 << 0)
337#define ADC_CCR_MULTI_TRIPLE_INTERLEAVED (0x17 << 0)
339#define ADC_CCR_MULTI_TRIPLE_ALTERNATE_TRIG (0x19 << 0)
342#define ADC_CCR_MULTI_MASK (0x1f << 0)
343#define ADC_CCR_MULTI_SHIFT 0
347#define ADC_CDR_DATA2_MASK (0xffff << 16)
348#define ADC_CDR_DATA2_SHIFT 16
350#define ADC_CDR_DATA1_MASK (0xffff << 0)
351#define ADC_CDR_DATA1_SHIFT 0
void adc_disable_temperature_sensor(void)
ADC Disable The Temperature Sensor.
void adc_disable_overrun_interrupt(uint32_t adc)
ADC Disable the Overrun Interrupt.
void adc_set_dma_terminate(uint32_t adc)
ADC Set DMA to Terminate.
void adc_clear_overrun_flag(uint32_t adc)
ADC Clear Overrun Flags.
void adc_set_dma_continue(uint32_t adc)
ADC Set DMA to Continue.
void adc_set_resolution(uint32_t adc, uint32_t resolution)
ADC Set Resolution.
void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger, uint32_t polarity)
ADC Enable an External Trigger for Regular Channels.
void adc_enable_temperature_sensor(void)
ADC Enable The Temperature Sensor.
void adc_eoc_after_each(uint32_t adc)
ADC Enable an EOC for Each Conversion.
void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger, uint32_t polarity)
ADC Enable an External Trigger for Injected Channels.
void adc_enable_overrun_interrupt(uint32_t adc)
ADC Enable the Overrun Interrupt.
bool adc_awd(uint32_t adc)
ADC Read the Analog Watchdog Flag.
void adc_eoc_after_group(uint32_t adc)
ADC Disable the EOC for Each Conversion.
bool adc_get_overrun_flag(uint32_t adc)
ADC Read the Overrun Flag.
void adc_set_clk_prescale(uint32_t prescaler)
ADC Set Clock Prescale The ADC clock can be prescaled.