Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
adc_arch.c File Reference

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/cm3/nvic.h>
#include <libopencm3/stm32/timer.h>
#include <string.h>
#include "std.h"
#include "led.h"
#include <BOARD_CONFIG>
+ Include dependency graph for adc_arch.c:

Go to the source code of this file.

Functions

static void adc_init_single (uint32_t adc, uint8_t chan1, uint8_t chan2, uint8_t chan3, uint8_t chan4)
 Enable selected channels on specified ADC. More...
 
static void adc_push_sample (struct adc_buf *buf, uint16_t sample)
 
static void adc_init_rcc (void)
 
static void adc_init_irq (void)
 
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...
 
void adc_init (void)
 Starts conversions. More...
 

Variables

volatile uint8_t adc_new_data_trigger
 
volatile uint32_tadc_injected_channels [4]
 Maps integer value x to ADC_InjectedChannel_x. More...
 
static uint8_t adc_channel_map [4]
 Maps integer value x to ADC_Channel_y. More...
 
uint16_t value = 0
 ADC1+2 interrupt hander. More...
 
struct adc_bufbuf
 

Detailed Description

Driver for the analog to digital converters on STM32.

Usage: Define flags for ADCs to use and their channels:

-DUSE_AD1 -DUSE_AD1_1 -DUSE_AD1_3

would enable ADC1 and it's channels 1 and 3.

Definition in file adc_arch.c.

Function Documentation

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:

1 struct adc_buf channel_buf;
2 adc_buf_channel(1, &channel_buf, 12);

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 208 of file adc_arch.c.

References adc_buf::av_nb_sample.

static void adc_init_irq ( void  )
inlinestatic

Definition at line 289 of file adc_arch.c.

Referenced by adc_init().

+ Here is the caller graph for this function:

static void adc_init_rcc ( void  )
inlinestatic

Definition at line 218 of file adc_arch.c.

References ADC_GPIO_CLOCK_PORT.

Referenced by adc_init().

+ Here is the caller graph for this function:

static void adc_init_single ( uint32_t  adc,
uint8_t  chan1,
uint8_t  chan2,
uint8_t  chan3,
uint8_t  chan4 
)
inlinestatic

Enable selected channels on specified ADC.

Usage:

adc_init_single(ADC1, 1, 1, 0, 0);

... would enable ADC1, enabling channels 1 and 2, but not 3 and 4.

Definition at line 309 of file adc_arch.c.

References ADC1, ADC1_GPIO_INIT, adc_channel_map, NB_ADC1_CHANNELS, and NB_ADC2_CHANNELS.

Referenced by adc_init().

+ Here is the caller graph for this function:

static void adc_push_sample ( struct adc_buf buf,
uint16_t  sample 
)
inlinestatic

Definition at line 555 of file adc_arch.c.

References adc_buf::av_nb_sample, adc_buf::head, adc_buf::sum, value, and adc_buf::values.

Variable Documentation

uint8_t adc_channel_map[4]
static

Maps integer value x to ADC_Channel_y.

like e.g.

  • 0 –> ADC_Channel_5
  • 1 –> ADC_Channel_8
  • 2 –> ADC_Channel_13

so they can be iterated incrementally.

Definition at line 202 of file adc_arch.c.

Referenced by adc_init(), and adc_init_single().

volatile uint32_t* adc_injected_channels[4]

Maps integer value x to ADC_InjectedChannel_x.

so they can be iterated safely

Definition at line 191 of file adc_arch.c.

Referenced by adc_init().

volatile uint8_t adc_new_data_trigger

Definition at line 104 of file adc_arch.c.

Referenced by adc_init(), main_event_task(), and main_periodic().

struct adc_buf* buf

Definition at line 578 of file adc_arch.c.

Referenced by adcISR0(), adcISR1(), and gsm_send_report_continue().