Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
ADC driver. More...
#include "mcu_periph/adc.h"
#include "mcu_periph/gpio.h"
#include "hal.h"
#include "std.h"
#include "mcu_periph/ram_arch.h"
Go to the source code of this file.
Macros | |
#define | USE_AD1 1 |
#define | ADC_SAMPLE_RATE ADC_SAMPLE_480 |
#endif More... | |
#define | ADC_BUF_DEPTH (MAX_AV_NB_SAMPLE/2) |
Functions | |
static | IN_DMA_SECTION (adcsample_t adc_samples[ADC_NUM_CHANNELS *MAX_AV_NB_SAMPLE]) |
static void | adc_configure (ADCConversionGroup *cfg, uint8_t num_channels, const uint8_t channels[], uint32_t sample_rate, adccallback_t end_cb, adcerrorcallback_t error_cb) |
Configure the ADC conversion group depending on the architecture. More... | |
void | adc1callback (ADCDriver *adcp) |
Adc1 callback. More... | |
static void | adcerrorcallback (ADCDriver *adcp, adcerror_t err) |
Adc error callback. More... | |
void | adc_buf_channel (uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample) |
Link between ChibiOS ADC drivers and Paparazzi adc_buffers. More... | |
void | adc_init (void) |
Adc init. More... | |
Variables | |
static const uint8_t | adc_channel_map [ADC_NUM_CHANNELS] |
uint8_t | adc_error_flag = 0 |
ADCDriver * | adcp_err = NULL |
static ADCConversionGroup | adc1_group |
static struct adc_buf * | adc1_buffers [ADC_NUM_CHANNELS] |
static uint32_t | adc1_sum_tmp [ADC_NUM_CHANNELS] |
static uint8_t | adc1_samples_tmp [ADC_NUM_CHANNELS] |
ADC driver.
ADC defines for Lia board (STM32F105) 5 Channels: 1 - ADC1, Channel 13 2 - ADC2, Channel 10 3 - ADC3, Channel 11 4 - ADC4, Channel 14 5 - Temperature sensor, Channel 16
Default buffer depth is equal to MAX_AV_NB_SAMPLE This allows us to always have more or equal samples than the user requires
For 5 actual channels we have to define (DUMMY stants for 1 dummy channel): CH1 + DUMMY + CH2 + DUMMY + CH3 + DUMMY + CH4 + DUMMY + CH_TEMP = 9 channels Then only every second channel is really read. Might be fixed in next version of ChibiOS
V_ref is 3.3V, ADC has 12bit or 16bit resolution.
Definition in file adc_arch.c.
#define ADC_BUF_DEPTH (MAX_AV_NB_SAMPLE/2) |
Definition at line 138 of file adc_arch.c.
#define ADC_SAMPLE_RATE ADC_SAMPLE_480 |
#endif
Definition at line 76 of file adc_arch.c.
#define USE_AD1 1 |
Definition at line 64 of file adc_arch.c.
void adc1callback | ( | ADCDriver * | adcp | ) |
Adc1 callback.
Callback, fired after half of the buffer is filled (i.e. half of the samples is collected). Since we are assuming continuous ADC conversion, the ADC state is never equal to ADC_COMPLETE.
[in] | adcp | pointer to a ADCDriver object |
[in] | buffer | pointer to a buffer with samples |
[in] | n | number of samples |
Definition at line 243 of file adc_arch.c.
References adc1_buffers, adc1_samples_tmp, adc1_sum_tmp, ADC_BUF_DEPTH, ADC_NUM_CHANNELS, adc_buf::av_nb_sample, and adc_buf::sum.
Referenced by adc_init().
Link between ChibiOS ADC drivers and Paparazzi adc_buffers.
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 312 of file adc_arch.c.
References adc1_buffers, ADC_NUM_CHANNELS, MAX_AV_NB_SAMPLE, and s.
Referenced by adc_generic_init(), airspeed_adc_init(), aoa_adc_init(), electrical_init(), glide_wing_lock_init(), humid_hih_init(), light_solar_init(), light_temt_init(), mf_ptu_init(), sonar_adc_init(), temp_adc_init(), temp_tcouple_adc_init(), and wing_rotation_adc_init().
|
static |
Configure the ADC conversion group depending on the architecture.
cfg | The configuration to be set |
num_channels | The number of channels in the ADC |
channels | The channel mapping to real channels |
sample_rate | The sample rate for all channels |
end_cb | The callback function at the end of conversion |
error_cb | The callback function whenever an error occurs |
Definition at line 175 of file adc_arch.c.
References error_cb.
Referenced by adc_init().
void adc_init | ( | void | ) |
Adc init.
Starts conversions.
Initialize ADC drivers, buffers and start conversion in the background
Definition at line 332 of file adc_arch.c.
References adc1_group, 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_7_GPIO_PIN, ADC_7_GPIO_PORT, ADC_9_GPIO_PIN, ADC_9_GPIO_PORT, ADC_BUF_DEPTH, adc_channel_map, adc_configure(), ADC_NUM_CHANNELS, ADC_SAMPLE_RATE, adcerrorcallback(), gpio_setup_pin_analog(), and PRINT_CONFIG_MSG().
Referenced by mcu_init().
|
static |
Adc error callback.
Fired if DMA error happens or ADC overflows
Definition at line 301 of file adc_arch.c.
References adc_error_flag, and adcp_err.
Referenced by adc_init().
|
static |
|
static |
Definition at line 144 of file adc_arch.c.
Referenced by adc1callback(), adc_buf_channel(), and adc_init().
|
static |
Definition at line 143 of file adc_arch.c.
Referenced by adc_init().
|
static |
Definition at line 146 of file adc_arch.c.
Referenced by adc1callback().
|
static |
Definition at line 145 of file adc_arch.c.
Referenced by adc1callback().
|
static |
Definition at line 81 of file adc_arch.c.
Referenced by adc_init().
uint8_t adc_error_flag = 0 |
Definition at line 132 of file adc_arch.c.
Referenced by adcerrorcallback().
ADCDriver* adcp_err = NULL |
Definition at line 133 of file adc_arch.c.
Referenced by adcerrorcallback().