39#ifndef LIBOPENCM3_ADC_H
40#define LIBOPENCM3_ADC_H
45#define ADC_JOFR1(block) MMIO32((block) + 0x14)
46#define ADC_JOFR2(block) MMIO32((block) + 0x18)
47#define ADC_JOFR3(block) MMIO32((block) + 0x1c)
48#define ADC_JOFR4(block) MMIO32((block) + 0x20)
51#define ADC_HTR(block) MMIO32((block) + 0x24)
54#define ADC_LTR(block) MMIO32((block) + 0x28)
57#define ADC_SQR1(block) MMIO32((block) + 0x2c)
60#define ADC_SQR2(block) MMIO32((block) + 0x30)
63#define ADC_SQR3(block) MMIO32((block) + 0x34)
66#define ADC_JSQR(block) MMIO32((block) + 0x38)
69#define ADC_JDR1(block) MMIO32((block) + 0x3c)
70#define ADC_JDR2(block) MMIO32((block) + 0x40)
71#define ADC_JDR3(block) MMIO32((block) + 0x44)
72#define ADC_JDR4(block) MMIO32((block) + 0x48)
75#define ADC_DR(block) MMIO32((block) + 0x4c)
80#define ADC_CHANNEL_TEMP 18
81#define ADC_CHANNEL_VREF 17
82#define ADC_CHANNEL_VBAT 18
87#define ADC_CR1_AWDCH_MAX 18
97#define ADC_CR2_EXTSEL_TIM1_CC1 (0x0 << 24)
99#define ADC_CR2_EXTSEL_TIM1_CC2 (0x1 << 24)
101#define ADC_CR2_EXTSEL_TIM1_CC3 (0x2 << 24)
103#define ADC_CR2_EXTSEL_TIM2_CC2 (0x3 << 24)
105#define ADC_CR2_EXTSEL_TIM5_TRGO (0x4 << 24)
107#define ADC_CR2_EXTSEL_TIM4_CC4 (0x5 << 24)
109#define ADC_CR2_EXTSEL_TIM3_CC4 (0x6 << 24)
111#define ADC_CR2_EXTSEL_TIM8_TRGO (0x7 << 24)
113#define ADC_CR2_EXTSEL_TIM8_TRGO2 (0x8 << 24)
115#define ADC_CR2_EXTSEL_TIM1_TRGO (0x9 << 24)
117#define ADC_CR2_EXTSEL_TIM1_TRGO2 (0xA << 24)
119#define ADC_CR2_EXTSEL_TIM2_TRGO (0xB << 24)
121#define ADC_CR2_EXTSEL_TIM4_TRGO (0xC << 24)
123#define ADC_CR2_EXTSEL_TIM6_TRGO (0xD << 24)
125#define ADC_CR2_EXTSEL_EXTI_LINE_11 (0xF << 24)
134#define ADC_CR2_JEXTSEL_TIM1_TRGO (0x0 << 16)
135#define ADC_CR2_JEXTSEL_TIM1_CC4 (0x1 << 16)
136#define ADC_CR2_JEXTSEL_TIM2_TRGO (0x2 << 16)
137#define ADC_CR2_JEXTSEL_TIM2_CC1 (0x3 << 16)
138#define ADC_CR2_JEXTSEL_TIM3_CC4 (0x4 << 16)
139#define ADC_CR2_JEXTSEL_TIM4_TRGO (0x5 << 16)
141#define ADC_CR2_JEXTSEL_TIM8_CC4 (0x7 << 16)
142#define ADC_CR2_JEXTSEL_TIM1_TRGO2 (0x8 << 16)
143#define ADC_CR2_JEXTSEL_TIM8_TRGO (0x9 << 16)
144#define ADC_CR2_JEXTSEL_TIM8_TRGO2 (0xA << 16)
145#define ADC_CR2_JEXTSEL_TIM3_cc3 (0xB << 16)
146#define ADC_CR2_JEXTSEL_TIM5_TRGO (0xC << 16)
147#define ADC_CR2_JEXTSEL_TIM3_CC1 (0xD << 16)
148#define ADC_CR2_JEXTSEL_TIM6_TRGO (0xE << 16)
157#define ADC_SMPR_SMP_3CYC 0x0
158#define ADC_SMPR_SMP_15CYC 0x1
159#define ADC_SMPR_SMP_28CYC 0x2
160#define ADC_SMPR_SMP_56CYC 0x3
161#define ADC_SMPR_SMP_84CYC 0x4
162#define ADC_SMPR_SMP_112CYC 0x5
163#define ADC_SMPR_SMP_144CYC 0x6
164#define ADC_SMPR_SMP_480CYC 0x7
168#define ADC_SQR1_L_MSK (0xf << ADC_SQR1_L_LSB)
170#define ADC_SQR_MAX_CHANNELS_REGULAR 16
178#define ADC_CCR_ADCPRE_BY2 (0x0 << 16)
179#define ADC_CCR_ADCPRE_BY4 (0x1 << 16)
180#define ADC_CCR_ADCPRE_BY6 (0x2 << 16)
181#define ADC_CCR_ADCPRE_BY8 (0x3 << 16)
183#define ADC_CCR_ADCPRE_MASK (0x3 << 16)
184#define ADC_CCR_ADCPRE_SHIFT 16
void adc_disable_vbat_sensor(void)
Disable The VBat Sensor.
void adc_set_multi_mode(uint32_t mode)
ADC Set Dual/Triple Mode.
void adc_enable_vbat_sensor(void)
Enable The VBat Sensor.