102 #ifdef AD1_11_CHANNEL
105 #ifdef AD1_12_CHANNEL
108 #ifdef AD1_13_CHANNEL
111 #ifdef AD1_14_CHANNEL
114 #ifdef AD1_15_CHANNEL
117 #ifdef AD1_16_CHANNEL
127 #ifndef ADC_BUF_DEPTH
128 #define ADC_BUF_DEPTH (MAX_AV_NB_SAMPLE/2)
138 #error ADC2_not implemented in ChibiOS
141 #error ADC3_not implemented in ChibiOS
150 adc_watchdog_callback cb;
159 uint32_t third6 = ADC_SQR1_NUM_CH(length);
162 for (i = 1; i <= length; i++) {
164 first6 |= (channel[i - 1] << ((i - 1) * 5));
166 if ((i > 6) & (i <= 12)) {
167 second6 |= (channel[i - 1] << ((i - 6 - 1) * 5));
169 if ((i > 12) & (i <= 18)) {
170 third6 |= (channel[i - 1] << ((i - 12 - 1) * 5));
184 for (i = 0; i <= 9; i++) {
185 reg32 |= (time << (i * 3));
190 for (i = 10; i <= 17; i++) {
191 reg32 |= (time << ((i - 10) * 3));
210 if (adcp->state != ADC_STOP) {
213 if (adc1_buffers[
channel] != NULL) {
220 for (
unsigned int sample = 0; sample < n; sample++) {
227 if (adc1_buffers[
channel] != NULL) {
233 if ((adc_watchdog.adc == adcp) &&
234 (adc_watchdog.channel < ADC_NUM_CHANNELS) &&
235 (adc_watchdog.cb != NULL)) {
236 if (adc1_buffers[adc_watchdog.channel]->
sum <
237 (adc1_buffers[adc_watchdog.channel]->
av_nb_sample * adc_watchdog.vmin)) {
241 #endif // USE_ADC_WATCHDOG
243 chSysUnlockFromISR();
259 chSysUnlockFromISR();
267 adc1_buffers[adc_channel] = s;
336 #elif defined(__STM32F4xx_H)
344 adc_watchdog.adc = NULL;
345 adc_watchdog.cb = NULL;
346 adc_watchdog.channel = 0;
347 adc_watchdog.vmin = (1<<12)-1;
362 adcStart(&ADCD1, NULL);
367 void register_adc_watchdog(ADCDriver *adc, adc_channels_num_t
channel, adcsample_t
vmin,
368 adc_watchdog_callback cb)
372 adc_watchdog.adc = adc;
373 adc_watchdog.channel = i;
374 adc_watchdog.vmin =
vmin;
375 adc_watchdog.cb = cb;
Some architecture independent helper functions for GPIOs.
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.
static adcsample_t adc_samples[ADC_NUM_CHANNELS *ADC_BUF_DEPTH]
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[])