update code to libopencm3 API change

This commit is contained in:
King Kévin 2018-04-28 12:22:19 +02:00
parent fd393cb76d
commit ae717d162e
1 changed files with 4 additions and 3 deletions

View File

@ -99,15 +99,16 @@ void busvoodoo_setup(void)
rcc_periph_clock_enable(RCC_ADC12_IN(BUSVOODOO_HW_VERSION_CHANNEL)); // enable clock for GPIO domain for hardware version channel
gpio_set_mode(ADC12_IN_PORT(BUSVOODOO_HW_VERSION_CHANNEL), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, ADC12_IN_PIN(BUSVOODOO_HW_VERSION_CHANNEL)); // set hardware version channel as analogue input for the ADC
rcc_periph_clock_enable(RCC_ADC1); // enable clock for ADC domain
adc_off(ADC1); // switch off ADC while configuring it
adc_power_off(ADC1); // switch off ADC while configuring it
adc_disable_scan_mode(ADC1); // ensure scan mode is disabled
adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR_SMP_28DOT5CYC); // use 28.5 cycles to sample (long enough to be stable)
adc_enable_temperature_sensor(ADC1); // enable internal voltage reference
adc_enable_temperature_sensor(); // enable internal voltage reference
adc_enable_external_trigger_regular(ADC1, ADC_CR2_EXTSEL_SWSTART); // use software trigger to start conversion
adc_set_single_conversion_mode(ADC1); // we only convert one channel after another
adc_power_on(ADC1); // switch on ADC
sleep_us(1); // wait t_stab for the ADC to stabilize
adc_reset_calibration(ADC1); // remove previous non-calibration
adc_calibration(ADC1); // calibrate ADC for less accuracy errors
adc_calibrate(ADC1); // calibrate ADC for less accuracy errors
// find out version of the board
gpio_set_mode(GPIO(BUSVOODOO_HW_VERSION_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO(BUSVOODOO_HW_VERSION_PIN)); // use pull up and down to check if a voltage divider is present on the pin