Browse Source

Adafruit Grand Central M4 fixes (#16812)

Giuliano Zaro 5 years ago
parent
commit
90e2c42031

+ 4
- 5
Marlin/src/HAL/HAL_SAMD51/HAL.cpp View File

427
     dma_init();
427
     dma_init();
428
   #endif
428
   #endif
429
   #if ENABLED(SDSUPPORT)
429
   #if ENABLED(SDSUPPORT)
430
-    // SD_DETECT_PIN may be removed if NO_SD_HOST_DRIVE is not defined in Configuration_adv.h
431
     #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
430
     #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
432
       SET_INPUT_PULLUP(SD_DETECT_PIN);
431
       SET_INPUT_PULLUP(SD_DETECT_PIN);
433
     #endif
432
     #endif
496
       // Preloaded data (fixed for all ADC instances hence not loaded by DMA)
495
       // Preloaded data (fixed for all ADC instances hence not loaded by DMA)
497
       adc->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA_Val;               // VRefA pin
496
       adc->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA_Val;               // VRefA pin
498
       SYNC(adc->SYNCBUSY.bit.REFCTRL);
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
       SYNC(adc->SYNCBUSY.bit.CTRLB);
499
       SYNC(adc->SYNCBUSY.bit.CTRLB);
501
       adc->SAMPCTRL.bit.SAMPLEN = (6 - 1);                                  // Sampling clocks
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
       // Registers loaded by DMA
504
       // Registers loaded by DMA
505
       adc->DSEQCTRL.bit.INPUTCTRL = true;
505
       adc->DSEQCTRL.bit.INPUTCTRL = true;
506
-
507
       adc->DSEQCTRL.bit.AUTOSTART = true;                                   // Start conversion after DMA sequence
506
       adc->DSEQCTRL.bit.AUTOSTART = true;                                   // Start conversion after DMA sequence
508
 
507
 
509
       adc->CTRLA.bit.ENABLE = true;                                         // Enable ADC
508
       adc->CTRLA.bit.ENABLE = true;                                         // Enable ADC

+ 3
- 3
Marlin/src/HAL/HAL_SAMD51/HAL.h View File

122
 //
122
 //
123
 // ADC
123
 // ADC
124
 //
124
 //
125
-extern uint16_t HAL_adc_result;     // result of last ADC conversion
125
+extern uint16_t HAL_adc_result;     // Most recent ADC conversion
126
 
126
 
127
 #define HAL_ANALOG_SELECT(pin)
127
 #define HAL_ANALOG_SELECT(pin)
128
 
128
 
129
 void HAL_adc_init();
129
 void HAL_adc_init();
130
 
130
 
131
-#define HAL_ADC_FILTERED            // Disable oversampling done in Marlin as ADC values already filtered in HAL
132
-#define HAL_ADC_RESOLUTION  12
131
+//#define HAL_ADC_FILTERED          // Disable Marlin's oversampling. The HAL filters ADC values.
132
+#define HAL_ADC_RESOLUTION  10      // ... 12
133
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
133
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
134
 #define HAL_READ_ADC()      HAL_adc_result
134
 #define HAL_READ_ADC()      HAL_adc_result
135
 #define HAL_ADC_READY()     true
135
 #define HAL_ADC_READY()     true

+ 0
- 3
Marlin/src/HAL/HAL_SAMD51/HAL_SPI.cpp View File

46
   // ------------------------
46
   // ------------------------
47
   #error "Software SPI not supported for SAMD51. Use Hardware SPI."
47
   #error "Software SPI not supported for SAMD51. Use Hardware SPI."
48
 
48
 
49
-  #if SD_CONNECTION_IS(ONBOARD)
50
-  #endif
51
-
52
 #else // !SOFTWARE_SPI
49
 #else // !SOFTWARE_SPI
53
 
50
 
54
   #ifdef ADAFRUIT_GRAND_CENTRAL_M4
51
   #ifdef ADAFRUIT_GRAND_CENTRAL_M4

+ 1
- 0
Marlin/src/HAL/HAL_SAMD51/fastio.h View File

245
   #define DIO17_PIN   PIN_PC23
245
   #define DIO17_PIN   PIN_PC23
246
   #define DIO88_PIN   PIN_PC24    // NEOPIXEL
246
   #define DIO88_PIN   PIN_PC24    // NEOPIXEL
247
   // PORTD
247
   // PORTD
248
+  #define DIO53_PIN   PIN_PD10
248
   #define DIO22_PIN   PIN_PD12
249
   #define DIO22_PIN   PIN_PD12
249
   #define DIO6_PIN    PIN_PD20
250
   #define DIO6_PIN    PIN_PD20
250
   #define DIO7_PIN    PIN_PD21
251
   #define DIO7_PIN    PIN_PD21

+ 1
- 0
Marlin/src/HAL/HAL_SAMD51/pinsDebug.h View File

149
  *  92             |  PA9   | QSPI: IO1
149
  *  92             |  PA9   | QSPI: IO1
150
  *  93             |  PA10  | QSPI: IO2
150
  *  93             |  PA10  | QSPI: IO2
151
  *  94             |  PA11  | QSPI: IO3
151
  *  94             |  PA11  | QSPI: IO3
152
+ *  95             |  PB31  | SD: DETECT
152
  *
153
  *
153
  */
154
  */

+ 2
- 2
Marlin/src/inc/Conditionals_post.h View File

300
 /**
300
 /**
301
  * Override here because this is set in Configuration_adv.h
301
  * Override here because this is set in Configuration_adv.h
302
  */
302
  */
303
-#if HAS_LCD_MENU && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
303
+#if HAS_LCD_MENU && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) && !(defined(ARDUINO_GRAND_CENTRAL_M4) && SD_CONNECTION_IS(ONBOARD))
304
   #undef SD_DETECT_INVERTED
304
   #undef SD_DETECT_INVERTED
305
 #endif
305
 #endif
306
 
306
 
2218
 #endif
2218
 #endif
2219
 
2219
 
2220
 #if ENABLED(SDSUPPORT)
2220
 #if ENABLED(SDSUPPORT)
2221
-  #if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE)
2221
+  #if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE) && !defined(ARDUINO_GRAND_CENTRAL_M4)
2222
     //
2222
     //
2223
     // The external SD card is not used. Hardware SPI is used to access the card.
2223
     // The external SD card is not used. Hardware SPI is used to access the card.
2224
     // When sharing the SD card with a PC we want the menu options to
2224
     // When sharing the SD card with a PC we want the menu options to

Loading…
Cancel
Save