70 #if defined(__STM32F10x_H) || defined(__STM32F105xC_H) || defined (__STM32F107xC_H)
72 #define ADC_SAMPLE_RATE ADC_SAMPLE_41P5
73 #define ADC_CR2_CFG ADC_CR2_TSVREFE
74 #elif defined(__STM32F4xx_H) || defined(__STM32F7xx_H)
76 #define ADC_SAMPLE_RATE ADC_SAMPLE_480
77 #define ADC_CR2_CFG ADC_CR2_SWSTART
110 #ifdef AD1_10_CHANNEL
113 #ifdef AD1_11_CHANNEL
116 #ifdef AD1_12_CHANNEL
119 #ifdef AD1_13_CHANNEL
122 #ifdef AD1_14_CHANNEL
125 #ifdef AD1_15_CHANNEL
128 #ifdef AD1_16_CHANNEL
138 #ifndef ADC_BUF_DEPTH
139 #define ADC_BUF_DEPTH (MAX_AV_NB_SAMPLE/2)
149 #error ADC2_not implemented in ChibiOS
152 #error ADC3_not implemented in ChibiOS
161 adc_watchdog_callback cb;
170 uint32_t third6 = ADC_SQR1_NUM_CH(length);
173 for (i = 1; i <= length; i++) {
175 first6 |= (channel[i - 1] << ((i - 1) * 5));
177 if ((i > 6) & (i <= 12)) {
178 second6 |= (channel[i - 1] << ((i - 6 - 1) * 5));
180 if ((i > 12) & (i <= 18)) {
181 third6 |= (channel[i - 1] << ((i - 12 - 1) * 5));
195 for (i = 0; i <= 9; i++) {
196 reg32 |= (time << (i * 3));
201 for (i = 10; i <= 17; i++) {
202 reg32 |= (time << ((i - 10) * 3));
221 if (adcp->state != ADC_STOP) {
224 if (adc1_buffers[
channel] != NULL) {
231 for (
unsigned int sample = 0; sample < n; sample++) {
238 if (adc1_buffers[
channel] != NULL) {
244 if ((adc_watchdog.adc == adcp) &&
245 (adc_watchdog.channel < ADC_NUM_CHANNELS) &&
246 (adc_watchdog.cb != NULL)) {
247 if (adc1_buffers[adc_watchdog.channel]->
sum <
248 (adc1_buffers[adc_watchdog.channel]->
av_nb_sample * adc_watchdog.vmin)) {
252 #endif // USE_ADC_WATCHDOG
254 chSysUnlockFromISR();
270 chSysUnlockFromISR();
280 adc1_buffers[adc_channel] = s;
350 adc_watchdog.adc = NULL;
351 adc_watchdog.cb = NULL;
352 adc_watchdog.channel = 0;
353 adc_watchdog.vmin = (1<<12)-1;
368 adcStart(&ADCD1, NULL);
373 void register_adc_watchdog(ADCDriver *adc, adc_channels_num_t
channel, adcsample_t
vmin,
374 adc_watchdog_callback cb)
378 adc_watchdog.adc = adc;
379 adc_watchdog.channel = i;
380 adc_watchdog.vmin =
vmin;
381 adc_watchdog.cb = cb;
Specific RAM section for DMA usage on F7.
Some architecture independent helper functions for GPIOs.
static IN_DMA_SECTION(adcsample_t adc_samples[ADC_NUM_CHANNELS *ADC_BUF_DEPTH])
static uint32_t adc1_sum_tmp[ADC_NUM_CHANNELS]
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.
static ADCConversionGroup adcgrpcfg
Configuration structure must be global.
arch independent ADC (Analog to Digital Converter) API
static struct adc_buf * adc1_buffers[ADC_NUM_CHANNELS]
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
static const uint8_t adc_channel_map[ADC_NUM_CHANNELS]
#endif
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void gpio_setup_pin_analog(ioportid_t port, uint16_t pin)
Setup a gpio for analog use.
static void adc_sample_time_on_all_channels(uint32_t *smpr1, uint32_t *smpr2, uint8_t time)
static void adcerrorcallback(ADCDriver *adcp, adcerror_t err)
Adc error callback.
void adc1callback(ADCDriver *adcp, adcsample_t *buffer, size_t n)
Adc1 callback.
static uint8_t adc1_samples_tmp[ADC_NUM_CHANNELS]
void adc_init(void)
Adc init.
static void adc_regular_sequence(uint32_t *sqr1, uint32_t *sqr2, uint32_t *sqr3, uint8_t length, const uint8_t channel[])