Paparazzi UAS
v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for the analog to digital converters on STM32. More...
#include "mcu_periph/adc.h"
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/adc.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/timer.h>
#include <string.h>
#include "mcu_periph/gpio.h"
#include "mcu_arch.h"
#include "std.h"
#include <BOARD_CONFIG>
Go to the source code of this file.
Macros | |
#define | NVIC_ADC_IRQ_PRIO 0 |
#define | USE_AD3 0 |
#define | ADC_TIMER_PERIOD 10000 |
#define | ADC_TIMER_FREQUENCY 2000000 |
Timer frequency for ADC Timer will trigger an update event after reaching the period reload value. More... | |
#define | TIM_ADC TIM2 |
#define | RCC_TIM_ADC RCC_TIM2 |
Functions | |
static void | adc_init_single (uint32_t adc, uint8_t nb_channels, uint8_t *channel_map) |
static void | adc_push_sample (struct adc_buf *buf, uint16_t sample) |
static void | adc_init_rcc (void) |
Configure and enable RCC for peripherals (ADC1, ADC2, Timer) More... | |
static void | adc_init_irq (void) |
Configure and enable ADC interrupt. More... | |
void | adc_init (void) |
Starts conversions. More... | |
void | adc_buf_channel (uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample) |
Registers a buffer to be used to store the specified converted channel Usage: More... | |
Variables | |
static uint8_t | nb_adc1_channels = 0 |
static uint8_t | nb_adc2_channels = 0 |
static uint8_t | nb_adc3_channels = 0 |
Driver for the analog to digital converters on STM32.
Usage: Define flags for ADCs to use (can be explicitly disabled by setting to 0):
-DUSE_ADC_1 -DUSE_ADC_3=1 -DUSE_ADC_4=0
would explicitly enable the ADC_1 and ADC_3 and disable ADC_4.
The mapping of these virtual "board" ADC_x numbers to a concrete AD converter and channel is done in the sw/airborne/boards/<boardname>.h header files. Some ADCs are normally already enabled in the board files per default (e.g. for battery voltage measurement).
Definition in file adc_arch.c.
#define ADC_TIMER_FREQUENCY 2000000 |
Timer frequency for ADC Timer will trigger an update event after reaching the period reload value.
New conversion is triggered on update event. ADC measuerement frequency is hence ADC_TIMER_FREQUENCY / ADC_TIMER_PERIOD.
Definition at line 164 of file adc_arch.c.
Referenced by adc_init_rcc().
#define ADC_TIMER_PERIOD 10000 |
Definition at line 155 of file adc_arch.c.
Referenced by adc_init_rcc().
#define NVIC_ADC_IRQ_PRIO 0 |
Definition at line 104 of file adc_arch.c.
Referenced by adc_init_irq().
#define RCC_TIM_ADC RCC_TIM2 |
Definition at line 422 of file adc_arch.c.
Referenced by adc_init_rcc().
#define TIM_ADC TIM2 |
Definition at line 421 of file adc_arch.c.
Referenced by adc_init_rcc().
#define USE_AD3 0 |
Definition at line 138 of file adc_arch.c.
Registers a buffer to be used to store the specified converted channel Usage:
Registers channel_buf as buffer for ADC channel 1, with max index 12 (12 samples).
Registers a buffer to be used to store the specified converted channel Usage:
Definition at line 375 of file adc_arch.c.
References ADC_NUM_CHANNELS, adc_buf::av_nb_sample, MAX_AV_NB_SAMPLE, nb_adc1_channels, nb_adc2_channels, and s.
void adc_init | ( | void | ) |
Starts conversions.
Starts conversions.
Initialize ADC drivers, buffers and start conversion in the background
Starts conversions.
Definition at line 227 of file adc_arch.c.
References AD1_1_CHANNEL, AD1_2_CHANNEL, AD1_3_CHANNEL, AD1_4_CHANNEL, AD2_1_CHANNEL, AD2_2_CHANNEL, AD3_1_CHANNEL, AD3_2_CHANNEL, ADC1, adc1callback(), ADC_1_GPIO_PIN, ADC_1_GPIO_PORT, ADC_2_GPIO_PIN, ADC_2_GPIO_PORT, ADC_3_GPIO_PIN, ADC_3_GPIO_PORT, ADC_4_GPIO_PIN, ADC_4_GPIO_PORT, ADC_5_GPIO_PIN, ADC_5_GPIO_PORT, ADC_6_GPIO_PIN, ADC_6_GPIO_PORT, ADC_7_GPIO_PIN, ADC_7_GPIO_PORT, ADC_9_GPIO_PIN, ADC_9_GPIO_PORT, ADC_BUF_DEPTH, adc_channel_map, adc_init_irq(), adc_init_rcc(), adc_init_single(), ADC_NUM_CHANNELS, adc_regular_sequence(), adc_sample_time_on_all_channels(), adcerrorcallback(), adcgrpcfg, gpio_setup_pin_analog(), nb_adc1_channels, nb_adc2_channels, PRINT_CONFIG_MSG(), and TRUE.
|
inlinestatic |
Configure and enable ADC interrupt.
Definition at line 463 of file adc_arch.c.
References NVIC_ADC_IRQ_PRIO.
Referenced by adc_init().
|
inlinestatic |
Configure and enable RCC for peripherals (ADC1, ADC2, Timer)
Definition at line 426 of file adc_arch.c.
References ADC_TIMER_FREQUENCY, ADC_TIMER_PERIOD, RCC_TIM_ADC, TIM_ADC, and timer_get_frequency().
Referenced by adc_init().
|
inlinestatic |
Definition at line 475 of file adc_arch.c.
References PRINT_CONFIG_MSG().
Referenced by adc_init().
Definition at line 558 of file adc_arch.c.
References adc_buf::av_nb_sample, adc_buf::head, adc_buf::sum, and adc_buf::values.
|
static |
Definition at line 192 of file adc_arch.c.
Referenced by adc_buf_channel(), and adc_init().
|
static |
Definition at line 193 of file adc_arch.c.
Referenced by adc_buf_channel(), and adc_init().
|
static |
Definition at line 194 of file adc_arch.c.