|
@@ -427,7 +427,6 @@ void HAL_init() {
|
427
|
427
|
dma_init();
|
428
|
428
|
#endif
|
429
|
429
|
#if ENABLED(SDSUPPORT)
|
430
|
|
- // SD_DETECT_PIN may be removed if NO_SD_HOST_DRIVE is not defined in Configuration_adv.h
|
431
|
430
|
#if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
|
432
|
431
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
433
|
432
|
#endif
|
|
@@ -496,14 +495,14 @@ void HAL_adc_init() {
|
496
|
495
|
// Preloaded data (fixed for all ADC instances hence not loaded by DMA)
|
497
|
496
|
adc->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA_Val; // VRefA pin
|
498
|
497
|
SYNC(adc->SYNCBUSY.bit.REFCTRL);
|
499
|
|
- adc->CTRLB.bit.RESSEL = ADC_CTRLB_RESSEL_12BIT_Val;
|
|
498
|
+ adc->CTRLB.bit.RESSEL = ADC_CTRLB_RESSEL_10BIT_Val; // ... ADC_CTRLB_RESSEL_16BIT_Val
|
500
|
499
|
SYNC(adc->SYNCBUSY.bit.CTRLB);
|
501
|
500
|
adc->SAMPCTRL.bit.SAMPLEN = (6 - 1); // Sampling clocks
|
502
|
|
- adc->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_16 | ADC_AVGCTRL_ADJRES(4); // 16 Accumulated conversions and shift 4 to get oversampled 12 bits result
|
503
|
|
- SYNC(adc->SYNCBUSY.bit.AVGCTRL);
|
|
501
|
+ //adc->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_16 | ADC_AVGCTRL_ADJRES(4); // 16 Accumulated conversions and shift 4 to get oversampled 12 bits result
|
|
502
|
+ //SYNC(adc->SYNCBUSY.bit.AVGCTRL);
|
|
503
|
+
|
504
|
504
|
// Registers loaded by DMA
|
505
|
505
|
adc->DSEQCTRL.bit.INPUTCTRL = true;
|
506
|
|
-
|
507
|
506
|
adc->DSEQCTRL.bit.AUTOSTART = true; // Start conversion after DMA sequence
|
508
|
507
|
|
509
|
508
|
adc->CTRLA.bit.ENABLE = true; // Enable ADC
|