Browse Source

Adafruit Grand Central M4 fixes (#16812)

pull/1/head
Giuliano Zaro 5 years ago
committed by GitHub
parent
commit
90e2c42031
  1. 9
      Marlin/src/HAL/HAL_SAMD51/HAL.cpp
  2. 6
      Marlin/src/HAL/HAL_SAMD51/HAL.h
  3. 3
      Marlin/src/HAL/HAL_SAMD51/HAL_SPI.cpp
  4. 1
      Marlin/src/HAL/HAL_SAMD51/fastio.h
  5. 1
      Marlin/src/HAL/HAL_SAMD51/pinsDebug.h
  6. 4
      Marlin/src/inc/Conditionals_post.h

9
Marlin/src/HAL/HAL_SAMD51/HAL.cpp

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

6
Marlin/src/HAL/HAL_SAMD51/HAL.h

@ -122,14 +122,14 @@ uint8_t eeprom_read_byte(uint8_t *pos);
// //
// ADC // ADC
// //
extern uint16_t HAL_adc_result; // result of last ADC conversion extern uint16_t HAL_adc_result; // Most recent ADC conversion
#define HAL_ANALOG_SELECT(pin) #define HAL_ANALOG_SELECT(pin)
void HAL_adc_init(); void HAL_adc_init();
#define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values.
#define HAL_ADC_RESOLUTION 12 #define HAL_ADC_RESOLUTION 10 // ... 12
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result #define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true #define HAL_ADC_READY() true

3
Marlin/src/HAL/HAL_SAMD51/HAL_SPI.cpp

@ -46,9 +46,6 @@
// ------------------------ // ------------------------
#error "Software SPI not supported for SAMD51. Use Hardware SPI." #error "Software SPI not supported for SAMD51. Use Hardware SPI."
#if SD_CONNECTION_IS(ONBOARD)
#endif
#else // !SOFTWARE_SPI #else // !SOFTWARE_SPI
#ifdef ADAFRUIT_GRAND_CENTRAL_M4 #ifdef ADAFRUIT_GRAND_CENTRAL_M4

1
Marlin/src/HAL/HAL_SAMD51/fastio.h

@ -245,6 +245,7 @@
#define DIO17_PIN PIN_PC23 #define DIO17_PIN PIN_PC23
#define DIO88_PIN PIN_PC24 // NEOPIXEL #define DIO88_PIN PIN_PC24 // NEOPIXEL
// PORTD // PORTD
#define DIO53_PIN PIN_PD10
#define DIO22_PIN PIN_PD12 #define DIO22_PIN PIN_PD12
#define DIO6_PIN PIN_PD20 #define DIO6_PIN PIN_PD20
#define DIO7_PIN PIN_PD21 #define DIO7_PIN PIN_PD21

1
Marlin/src/HAL/HAL_SAMD51/pinsDebug.h

@ -149,5 +149,6 @@ void pwm_details(int32_t pin) {
* 92 | PA9 | QSPI: IO1 * 92 | PA9 | QSPI: IO1
* 93 | PA10 | QSPI: IO2 * 93 | PA10 | QSPI: IO2
* 94 | PA11 | QSPI: IO3 * 94 | PA11 | QSPI: IO3
* 95 | PB31 | SD: DETECT
* *
*/ */

4
Marlin/src/inc/Conditionals_post.h

@ -300,7 +300,7 @@
/** /**
* Override here because this is set in Configuration_adv.h * Override here because this is set in Configuration_adv.h
*/ */
#if HAS_LCD_MENU && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) #if HAS_LCD_MENU && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) && !(defined(ARDUINO_GRAND_CENTRAL_M4) && SD_CONNECTION_IS(ONBOARD))
#undef SD_DETECT_INVERTED #undef SD_DETECT_INVERTED
#endif #endif
@ -2218,7 +2218,7 @@
#endif #endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE) #if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE) && !defined(ARDUINO_GRAND_CENTRAL_M4)
// //
// The external SD card is not used. Hardware SPI is used to access the card. // The external SD card is not used. Hardware SPI is used to access the card.
// When sharing the SD card with a PC we want the menu options to // When sharing the SD card with a PC we want the menu options to

Loading…
Cancel
Save