33#ifndef LIBOPENCM3_ADC_H
34#define LIBOPENCM3_ADC_H
55#define ADC1_ISR ADC_ISR(ADC)
56#define ADC1_IER ADC_IER(ADC)
57#define ADC1_CR ADC_CR(ADC)
58#define ADC1_CFGR1 ADC_CFGR1(ADC)
59#define ADC1_CFGR2 ADC_CFGR2(ADC)
60#define ADC1_SMPR1 ADC_SMPR1(ADC)
61#define ADC_SMPR(adc) ADC_SMPR1(adc)
62#define ADC1_SMPR ADC_SMPR1(ADC)
63#define ADC1_TR1 ADC_TR1(ADC)
64#define ADC_TR(adc) ADC_TR1(adc)
65#define ADC1_TR ADC1_TR(ADC)
66#define ADC1_CHSELR ADC_CHSELR(ADC)
67#define ADC1_DR ADC_DR(ADC)
68#define ADC1_CCR ADC_CCR(ADC)
77#define ADC_CFGR1_ALIGN (1 << 5)
80#define ADC_CFGR1_EXTSEL_SHIFT 6
81#define ADC_CFGR1_EXTSEL_MASK 0x7
84#define ADC_CFGR1_EXTSEL_TIM1_TRGO 0x0
85#define ADC_CFGR1_EXTSEL_TIM1_CC4 0x1
86#define ADC_CFGR1_EXTSEL_TIM2_TRGO 0x2
87#define ADC_CFGR1_EXTSEL_TIM3_TRGO 0x3
88#define ADC_CFGR1_EXTSEL_TIM15_TRGO 0x4
93#define ADC_CFGR2_CKMODE_SHIFT 30
94#define ADC_CFGR2_CKMODE (3 << ADC_CFGR2_CKMODE_SHIFT)
95#define ADC_CFGR2_CKMODE_CK_ADC (0 << ADC_CFGR2_CKMODE_SHIFT)
96#define ADC_CFGR2_CKMODE_PCLK_DIV2 (1 << ADC_CFGR2_CKMODE_SHIFT)
97#define ADC_CFGR2_CKMODE_PCLK_DIV4 (2 << ADC_CFGR2_CKMODE_SHIFT)
101#define ADC_SMPR_SMP_SHIFT 0
102#define ADC_SMPR_SMP (7 << ADC_SMPR_SMP_SHIFT)
103#define ADC_SMPR_SMP_001DOT5 (0 << ADC_SMPR_SMP_SHIFT)
104#define ADC_SMPR_SMP_007DOT5 (1 << ADC_SMPR_SMP_SHIFT)
105#define ADC_SMPR_SMP_013DOT5 (2 << ADC_SMPR_SMP_SHIFT)
106#define ADC_SMPR_SMP_028DOT5 (3 << ADC_SMPR_SMP_SHIFT)
107#define ADC_SMPR_SMP_041DOT5 (4 << ADC_SMPR_SMP_SHIFT)
108#define ADC_SMPR_SMP_055DOT5 (5 << ADC_SMPR_SMP_SHIFT)
109#define ADC_SMPR_SMP_071DOT5 (6 << ADC_SMPR_SMP_SHIFT)
110#define ADC_SMPR_SMP_239DOT5 (7 << ADC_SMPR_SMP_SHIFT)
121#define ADC_RESOLUTION_12BIT ADC_CFGR1_RES_12_BIT
122#define ADC_RESOLUTION_10BIT ADC_CFGR1_RES_10_BIT
123#define ADC_RESOLUTION_8BIT ADC_CFGR1_RES_8_BIT
124#define ADC_RESOLUTION_6BIT ADC_CFGR1_RES_6_BIT
131#define ADC_SMPTIME_001DOT5 ADC_SMPR_SMP_001DOT5
132#define ADC_SMPTIME_007DOT5 ADC_SMPR_SMP_007DOT5
133#define ADC_SMPTIME_013DOT5 ADC_SMPR_SMP_013DOT5
134#define ADC_SMPTIME_028DOT5 ADC_SMPR_SMP_028DOT5
135#define ADC_SMPTIME_041DOT5 ADC_SMPR_SMP_041DOT5
136#define ADC_SMPTIME_055DOT5 ADC_SMPR_SMP_055DOT5
137#define ADC_SMPTIME_071DOT5 ADC_SMPR_SMP_071DOT5
138#define ADC_SMPTIME_239DOT5 ADC_SMPR_SMP_239DOT5
145#define ADC_CLKSOURCE_ADC ADC_CFGR2_CKMODE_CK_ADC
146#define ADC_CLKSOURCE_PCLK_DIV2 ADC_CFGR2_CKMODE_PCLK_DIV2
147#define ADC_CLKSOURCE_PCLK_DIV4 ADC_CFGR2_CKMODE_PCLK_DIV4
154#define ADC_CHANNEL_TEMP 16
155#define ADC_CHANNEL_VREF 17
156#define ADC_CHANNEL_VBAT 18
#define LIBOPENCM3_DEPRECATED(x)
void adc_disable_vbat_sensor(void)
ADC Disable The VBat Sensor.
void adc_calibrate_wait_finish(uint32_t adc) LIBOPENCM3_DEPRECATED("see adc_is_calibrating")
ADC Wait to finish the ADC calibration procedure.
void adc_calibrate_start(uint32_t adc) LIBOPENCM3_DEPRECATED("see adc_calibrate/_async")
ADC Start the calibration procedure.
void adc_enable_vbat_sensor(void)
ADC Enable The VBat Sensor.
void adc_set_clk_source(uint32_t adc, uint32_t source)
ADC Set Clock Source.
void adc_clear_watchdog_flag(uint32_t adc)
ADC Clear Analog Watchdog Flag.
void adc_disable_eoc_sequence_interrupt(uint32_t adc)
ADC Disable Regular End-Of-Conversion Sequence Interrupt.
void adc_disable_watchdog_interrupt(uint32_t adc)
ADC Disable Regular End-Of-Conversion Interrupt.
void adc_clear_eoc_sequence_flag(uint32_t adc)
ADC Clear Regular End-Of-Conversion Sequence Flag.
void adc_enable_watchdog_interrupt(uint32_t adc)
ADC Enable Analog Watchdog Interrupt.
bool adc_get_eoc_sequence_flag(uint32_t adc)
ADC Read the Regular End-Of-Conversion Sequence Flag.
bool adc_get_watchdog_flag(uint32_t adc)
ADC Read the Analog Watchdog Flag.
void adc_enable_eoc_sequence_interrupt(uint32_t adc)
ADC Enable Regular End-Of-Conversion Sequence Interrupt.
void adc_set_operation_mode(uint32_t adc, enum adc_opmode opmode)
ADC Set operation mode.
void adc_disable_discontinuous_mode(uint32_t adc)
ADC Disable Discontinuous Mode for Regular Conversions.
void adc_enable_discontinuous_mode(uint32_t adc)
ADC Enable Discontinuous Mode for Regular Conversions.
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_disable_external_trigger_regular(uint32_t adc)
ADC Disable an External Trigger for Regular Channels.
void adc_set_watchdog_high_threshold(uint32_t adc, uint16_t threshold)
ADC Set Analog Watchdog Upper Threshold.
void adc_enable_analog_watchdog_on_all_channels(uint32_t adc)
ADC Enable Analog Watchdog for All Channels.
void adc_enable_analog_watchdog_on_selected_channel(uint32_t adc, uint8_t chan)
ADC Enable Analog Watchdog for a Selected Channel.
void adc_disable_analog_watchdog(uint32_t adc)
ADC Disable Analog Watchdog.
void adc_set_watchdog_low_threshold(uint32_t adc, uint16_t threshold)
ADC Set Analog Watchdog Lower Threshold.