update libopencm3

This brings in the new ADC api for STM32 parts.

Update to new standardized ADC apis.
Drops pointless channel definitions, uses common names for common functions.
No functional changes.

Based on work in: https://github.com/libopencm3/libopencm3-examples/pull/130
This commit is contained in:
Karl Palsson
2016-04-10 13:41:54 +00:00
parent b50cdb56de
commit 2092a6759d
12 changed files with 15 additions and 15 deletions

View File

@@ -26,7 +26,7 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/stm32/gpio.h>
uint8_t channel_array[] = { ADC_CHANNEL1, ADC_CHANNEL1, ADC_CHANNEL_TEMP};
uint8_t channel_array[] = { 1, 1, ADC_CHANNEL_TEMP};
static void adc_setup(void)
{

View File

@@ -67,7 +67,7 @@ static void adc_setup(void)
rcc_periph_clock_enable(RCC_ADC1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single injected conversion. */
adc_disable_scan_mode(ADC1);

View File

@@ -87,7 +87,7 @@ static void adc_setup(void)
rcc_periph_clock_enable(RCC_ADC1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single timer triggered injected conversion. */
adc_disable_scan_mode(ADC1);

View File

@@ -98,7 +98,7 @@ static void adc_setup(void)
rcc_periph_clock_enable(RCC_ADC1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single timer triggered injected conversion with interrupt generation. */
/* While not needed for a single channel, try out scan mode which does all channels in one sweep and

View File

@@ -106,7 +106,7 @@ static void adc_setup(void)
rcc_periph_clock_enable(RCC_ADC1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single timer triggered injected conversion with interrupt generation. */
/* While not needed for a single channel, try out scan mode which does all channels in one sweep and

View File

@@ -67,7 +67,7 @@ static void adc_setup(void)
rcc_periph_clock_enable(RCC_ADC1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single conversion. */
adc_disable_scan_mode(ADC1);

View File

@@ -64,7 +64,7 @@ static void adc_setup(void)
rcc_periph_clock_enable(RCC_ADC1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single conversion. */
adc_disable_scan_mode(ADC1);

View File

@@ -95,7 +95,7 @@ static void adc_setup(void)
gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO1);
/* Make sure the ADC doesn't run during config. */
adc_off(ADC1);
adc_power_off(ADC1);
/* We configure everything for one single conversion. */
adc_disable_scan_mode(ADC1);

View File

@@ -52,19 +52,19 @@ static void adc_setup(void)
//ADC
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
adc_off(ADC1);
adc_set_clk_prescale(ADC_CCR_CKMODE_DIV2);
adc_power_off(ADC1);
adc_set_clk_prescale(ADC1, ADC_CCR_CKMODE_DIV2);
adc_set_single_conversion_mode(ADC1);
adc_disable_external_trigger_regular(ADC1);
adc_set_right_aligned(ADC1);
/* We want to read the temperature sensor, so we have to enable it. */
adc_enable_temperature_sensor();
adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR1_SMP_61DOT5CYC);
adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR_SMP_61DOT5CYC);
uint8_t channel_array[16];
channel_array[0]=16; // Vts (Internal temperature sensor
channel_array[0]=1; //ADC1_IN1 (PA0)
adc_set_regular_sequence(ADC1, 1, channel_array);
adc_set_resolution(ADC1, ADC_CFGR_RES_12_BIT);
adc_set_resolution(ADC1, ADC_CFGR1_RES_12_BIT);
adc_power_on(ADC1);
/* Wait for ADC starting up. */

View File

@@ -98,7 +98,7 @@ static void adc_setup(void)
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
adc_off(ADC1);
adc_power_off(ADC1);
adc_disable_scan_mode(ADC1);
adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR_SMP_3CYC);

View File

@@ -99,7 +99,7 @@ static void adc_setup(void)
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
adc_off(ADC1);
adc_power_off(ADC1);
adc_disable_scan_mode(ADC1);
adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR_SMP_3CYC);