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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user