Paparazzi UAS
v5.8.2_stable-0-g6260b7c
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 |
uint16_t | value = 0 |
struct adc_buf * | buf |
return | |
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 418 of file adc_arch.c.
Referenced by adc_init_rcc().
#define TIM_ADC TIM2 |
Definition at line 417 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).
Definition at line 370 of file adc_arch.c.
References adc_buf::av_nb_sample, nb_adc1_channels, and nb_adc2_channels.
void adc_init | ( | void | ) |
Starts conversions.
Starts conversions.
Definition at line 223 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, 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_dev_init(), adc_init_irq(), adc_init_rcc(), adc_init_single(), gpio_setup_pin_analog(), nb_adc1_channels, nb_adc2_channels, and PRINT_CONFIG_MSG().
|
inlinestatic |
Configure and enable ADC interrupt.
Definition at line 459 of file adc_arch.c.
References NVIC_ADC_IRQ, and NVIC_ADC_IRQ_PRIO.
Referenced by adc_init().
|
inlinestatic |
Configure and enable RCC for peripherals (ADC1, ADC2, Timer)
Definition at line 422 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 471 of file adc_arch.c.
References PRINT_CONFIG_MSG().
Referenced by adc_init().
Definition at line 562 of file adc_arch.c.
References adc_buf::av_nb_sample, adc_buf::head, adc_buf::sum, value, and adc_buf::values.
struct adc_buf* buf |
Definition at line 587 of file adc_arch.c.
Referenced by adcISR0(), adcISR1(), create_tag(), fifo_init(), gsm_send_report_continue(), imu_krooz_event(), nmea_configure(), parse_mf_daq_msg(), and udp_receive().
|
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.
return |
Definition at line 667 of file adc_arch.c.
uint16_t value = 0 |
Definition at line 586 of file adc_arch.c.
Referenced by actuators_esc32_dir(), adc_push_sample(), adcISR0(), adcISR1(), add_byte_to_buffer(), enose_set_heat(), gsm_receive_content(), i2c_smbus_process_call(), i2c_smbus_write_byte_data(), i2c_smbus_write_word_data(), init_first_order_low_pass(), init_second_order_low_pass(), init_second_order_low_pass_int(), jpeg_quantization(), mt9f002_write_reg8(), mtostk_apply_polynomial_temp(), sc18is600_write_to_register(), update_first_order_low_pass(), update_second_order_low_pass(), and update_second_order_low_pass_int().