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
78 #elif defined(__STM32F373xC_H)
79 #define ADC_SAMPLE_RATE ADC_SAMPLE_239P5
80 #define ADC_CR2_CFG ADC_CR2_SWSTART
81 #elif defined(__STM32F3xx_H)
82 #define ADC_SAMPLE_RATE ADC_SMPR_SMP_601P5
115 #ifdef AD1_10_CHANNEL
118 #ifdef AD1_11_CHANNEL
121 #ifdef AD1_12_CHANNEL
124 #ifdef AD1_13_CHANNEL
127 #ifdef AD1_14_CHANNEL
130 #ifdef AD1_15_CHANNEL
133 #ifdef AD1_16_CHANNEL
143 #ifndef ADC_BUF_DEPTH
144 #define ADC_BUF_DEPTH (MAX_AV_NB_SAMPLE/2)
154 #error ADC2_not implemented in ChibiOS
157 #error ADC3_not implemented in ChibiOS
166 adc_watchdog_callback cb;
175 uint32_t third6 = ADC_SQR1_NUM_CH(length);
178 for (i = 1; i <= length; i++) {
180 first6 |= (channel[i - 1] << ((i - 1) * 5));
182 if ((i > 6) & (i <= 12)) {
183 second6 |= (channel[i - 1] << ((i - 6 - 1) * 5));
185 if ((i > 12) & (i <= 18)) {
186 third6 |= (channel[i - 1] << ((i - 12 - 1) * 5));
200 for (i = 0; i <= 9; i++) {
201 reg32 |= (time << (i * 3));
206 for (i = 10; i <= 17; i++) {
207 reg32 |= (time << ((i - 10) * 3));
226 if (adcp->state != ADC_STOP) {
229 if (adc1_buffers[
channel] != NULL) {
236 for (
unsigned int sample = 0; sample < n; sample++) {
243 if (adc1_buffers[
channel] != NULL) {
249 if ((adc_watchdog.adc == adcp) &&
250 (adc_watchdog.channel < ADC_NUM_CHANNELS) &&
251 (adc_watchdog.cb != NULL)) {
252 if (adc1_buffers[adc_watchdog.channel]->
sum <
253 (adc1_buffers[adc_watchdog.channel]->
av_nb_sample * adc_watchdog.vmin)) {
257 #endif // USE_ADC_WATCHDOG
259 chSysUnlockFromISR();
275 chSysUnlockFromISR();
285 adc1_buffers[adc_channel] = s;
353 adc_watchdog.adc = NULL;
354 adc_watchdog.cb = NULL;
355 adc_watchdog.channel = 0;
356 adc_watchdog.vmin = (1 << 12) - 1;
363 #if defined(__STM32F373xC_H)
371 #elif defined(__STM32F3xx_H)
373 #warning ADCs not tested with stm32f30
393 adcStart(&ADCD1, NULL);
398 void register_adc_watchdog(ADCDriver *adc, adc_channels_num_t
channel, adcsample_t
vmin,
399 adc_watchdog_callback cb)
403 adc_watchdog.adc = adc;
404 adc_watchdog.channel = i;
405 adc_watchdog.vmin =
vmin;
406 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[])