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) {
233 const adcsample_t *buffer = adc_samples + (adcIsBufferComplete(adcp) ?
244 for (
unsigned int sample = 0; sample < n; sample++) {
257 if ((adc_watchdog.adc == adcp) &&
259 (adc_watchdog.cb != NULL)) {
265 #endif // USE_ADC_WATCHDOG
267 chSysUnlockFromISR();
283 chSysUnlockFromISR();
295 s->av_nb_sample = av_nb_sample;
361 adc_watchdog.adc = NULL;
362 adc_watchdog.cb = NULL;
363 adc_watchdog.channel = 0;
364 adc_watchdog.vmin = (1 << 12) - 1;
371 #if defined(__STM32F373xC_H)
379 #elif defined(__STM32F3xx_H)
381 #warning ADCs not tested with stm32f30
401 adcStart(&ADCD1, NULL);
406 void register_adc_watchdog(ADCDriver *adc, adc_channels_num_t
channel, adcsample_t
vmin,
407 adc_watchdog_callback cb)
411 adc_watchdog.adc = adc;
412 adc_watchdog.channel = i;
413 adc_watchdog.vmin =
vmin;
414 adc_watchdog.cb = cb;