Adafruit Grand Central M4 fixes (#16812)

This commit is contained in:
Giuliano Zaro 2020-02-09 16:57:22 +01:00 committed by GitHub
parent 84b6e11bd5
commit 90e2c42031
6 changed files with 11 additions and 13 deletions

View file

@ -427,7 +427,6 @@ void HAL_init() {
dma_init();
#endif
#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)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
@ -496,14 +495,14 @@ void HAL_adc_init() {
// Preloaded data (fixed for all ADC instances hence not loaded by DMA)
adc->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA_Val; // VRefA pin
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);
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
SYNC(adc->SYNCBUSY.bit.AVGCTRL);
//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);
// Registers loaded by DMA
adc->DSEQCTRL.bit.INPUTCTRL = true;
adc->DSEQCTRL.bit.AUTOSTART = true; // Start conversion after DMA sequence
adc->CTRLA.bit.ENABLE = true; // Enable ADC

View file

@ -122,14 +122,14 @@ uint8_t eeprom_read_byte(uint8_t *pos);
//
// 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)
void HAL_adc_init();
#define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL
#define HAL_ADC_RESOLUTION 12
//#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values.
#define HAL_ADC_RESOLUTION 10 // ... 12
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true

View file

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

View file

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

View file

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

View file

@ -300,7 +300,7 @@
/**
* 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
#endif
@ -2218,7 +2218,7 @@
#endif
#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.
// When sharing the SD card with a PC we want the menu options to