27 rcc_periph_clock_enable(RCC_ADC1);
31 rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV2);
32 adc_set_dual_mode(ADC_CR1_DUALMOD_IND);
33 adc_disable_scan_mode(ADC1);
36 adc_set_single_conversion_mode(ADC1);
39 adc_enable_external_trigger_regular(ADC1, ADC_CR2_EXTSEL_SWSTART);
43 adc_reset_calibration(ADC1);
184 ADC_SQR3(ADC1) = 0x0;
189 ADC_SQR3(ADC1) = 0x1;
194 ADC_SQR3(ADC1) = 0x2;
199 ADC_SQR3(ADC1) = 0x3;
204 ADC_SQR3(ADC1) = 0x4;
209 ADC_SQR3(ADC1) = 0x5;
214 ADC_SQR3(ADC1) = 0x6;
219 ADC_SQR3(ADC1) = 0x7;
236 ADC_SQR3(ADC1) = 0x8;
241 ADC_SQR3(ADC1) = 0x9;
271 adc_start_conversion_regular(ADC1);
274 while (!adc_eoc(ADC1));
275 return adc_read_regular(ADC1);
gpio_port
GPIO ports available for the MCU.
uint16_t ADC_sample(gpio_port port, gpio_pin pin)
Get a sample from the ADC.
#define ADC_VOLT_REF
Typical voltage reference value used by ADC_volts()
uint16_t ADC_addChannel(gpio_port port, gpio_pin pin)
Add an aditional channel to the ADC.
void MCU_printError(mcu_error errorNum)
Print a given error number as a character stream.
uint8_t MCU_debugIsEnabled(void)
Checks if debug is enabled.
mcu_error ADC_setup(gpio_port port, gpio_pin pin)
Initialize ADC for a given port and pin.
Error ADC: Port doesn't exist with ADC.
float ADC_volts(gpio_port port, gpio_pin pin)
Get a sample from the ADC and convert it to volts.
gpio_pin
GPIO pins available for each port.
Error ADC: No ADC on pin.
mcu_error pinSetup(gpio_mode mode, gpio_port port, gpio_pin pin)
Setup a GPIO pin for a given function.
Header file for stm32f103cb ADC API.
mcu_error
Error enumerators for the Debug peripheral.