212
Marlin/src/HAL/SAMD21/HAL.cpp
Normal file
212
Marlin/src/HAL/SAMD21/HAL.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include <wiring_private.h>
|
||||
|
||||
#if USING_HW_SERIALUSB
|
||||
DefaultSerial1 MSerialUSB(false, SerialUSB);
|
||||
#endif
|
||||
#if USING_HW_SERIAL0
|
||||
DefaultSerial2 MSerial1(false, Serial1);
|
||||
#endif
|
||||
#if USING_HW_SERIAL1
|
||||
DefaultSerial3 MSerial2(false, Serial2);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define WDT_CONFIG_PER_7_Val 0x9u
|
||||
#define WDT_CONFIG_PER_Pos 0
|
||||
#define WDT_CONFIG_PER_7 (WDT_CONFIG_PER_7_Val << WDT_CONFIG_PER_Pos)
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
|
||||
#define WDT_TIMEOUT_REG TERN(WATCHDOG_DURATION_8S, WDT_CONFIG_PER_CYC8192, WDT_CONFIG_PER_CYC4096) // 4 or 8 second timeout
|
||||
|
||||
void MarlinHAL::watchdog_init() {
|
||||
// Set up the generic clock (GCLK2) used to clock the watchdog timer at 1.024kHz
|
||||
GCLK->GENDIV.reg = GCLK_GENDIV_DIV(4) | // Divide the 32.768kHz clock source by divisor 32, where 2^(4 + 1): 32.768kHz/32=1.024kHz
|
||||
GCLK_GENDIV_ID(2); // Select Generic Clock (GCLK) 2
|
||||
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||
|
||||
REG_GCLK_GENCTRL = GCLK_GENCTRL_DIVSEL | // Set to divide by 2^(GCLK_GENDIV_DIV(4) + 1)
|
||||
GCLK_GENCTRL_IDC | // Set the duty cycle to 50/50 HIGH/LOW
|
||||
GCLK_GENCTRL_GENEN | // Enable GCLK2
|
||||
GCLK_GENCTRL_SRC_OSCULP32K | // Set the clock source to the ultra low power oscillator (OSCULP32K)
|
||||
GCLK_GENCTRL_ID(2); // Select GCLK2
|
||||
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||
|
||||
// Feed GCLK2 to WDT (Watchdog Timer)
|
||||
REG_GCLK_CLKCTRL = GCLK_CLKCTRL_CLKEN | // Enable GCLK2 to the WDT
|
||||
GCLK_CLKCTRL_GEN_GCLK2 | // Select GCLK2
|
||||
GCLK_CLKCTRL_ID_WDT; // Feed the GCLK2 to the WDT
|
||||
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||
|
||||
WDT->CONFIG.bit.PER = WDT_CONFIG_PER_7; // Set the WDT reset timeout to 4 seconds
|
||||
while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||
REG_WDT_CTRL = WDT_CTRL_ENABLE; // Enable the WDT in normal mode
|
||||
while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization
|
||||
}
|
||||
|
||||
// Reset watchdog. MUST be called at least every 4 seconds after the
|
||||
// first watchdog_init or SAMD will go into emergency procedures.
|
||||
void MarlinHAL::watchdog_refresh() {
|
||||
WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
|
||||
while (WDT->STATUS.bit.SYNCBUSY);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// ------------------------
|
||||
|
||||
// ------------------------
|
||||
// Private functions
|
||||
// ------------------------
|
||||
|
||||
void MarlinHAL::dma_init() {}
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
// HAL initialization task
|
||||
void MarlinHAL::init() {
|
||||
TERN_(DMA_IS_REQUIRED, dma_init());
|
||||
#if ENABLED(SDSUPPORT)
|
||||
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||
#endif
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma push_macro("WDT")
|
||||
#undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
#pragma pop_macro("WDT")
|
||||
|
||||
void MarlinHAL::reboot() { NVIC_SystemReset(); }
|
||||
|
||||
extern "C" {
|
||||
void * _sbrk(int incr);
|
||||
extern unsigned int __bss_end__; // end of bss section
|
||||
}
|
||||
|
||||
// Return free memory between end of heap (or end bss) and whatever is current
|
||||
int freeMemory() {
|
||||
int free_memory, heap_end = (int)_sbrk(0);
|
||||
return (int)&free_memory - (heap_end ?: (int)&__bss_end__);
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
void MarlinHAL::adc_init() {
|
||||
/* thanks to https://www.eevblog.com/forum/microcontrollers/samd21g18-adc-with-resrdy-interrupts-only-reads-once-or-twice/ */
|
||||
|
||||
ADC->CTRLA.bit.ENABLE = false;
|
||||
while(ADC->STATUS.bit.SYNCBUSY);
|
||||
|
||||
// load chip corrections
|
||||
uint32_t bias = (*((uint32_t *) ADC_FUSES_BIASCAL_ADDR) & ADC_FUSES_BIASCAL_Msk) >> ADC_FUSES_BIASCAL_Pos;
|
||||
uint32_t linearity = (*((uint32_t *) ADC_FUSES_LINEARITY_0_ADDR) & ADC_FUSES_LINEARITY_0_Msk) >> ADC_FUSES_LINEARITY_0_Pos;
|
||||
linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5;
|
||||
|
||||
/* Wait for bus synchronization. */
|
||||
while (ADC->STATUS.bit.SYNCBUSY) {};
|
||||
|
||||
ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity);
|
||||
|
||||
/* Wait for bus synchronization. */
|
||||
while (ADC->STATUS.bit.SYNCBUSY) {};
|
||||
|
||||
ADC->CTRLA.bit.SWRST = true;
|
||||
while(ADC->STATUS.bit.SYNCBUSY);
|
||||
|
||||
ADC->REFCTRL.reg = ADC_REFCTRL_REFSEL_INTVCC1;
|
||||
ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_32| ADC_AVGCTRL_ADJRES(4);;
|
||||
|
||||
|
||||
ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV128 |
|
||||
ADC_CTRLB_RESSEL_16BIT |
|
||||
ADC_CTRLB_FREERUN;
|
||||
while(ADC->STATUS.bit.SYNCBUSY);
|
||||
|
||||
ADC->SAMPCTRL.bit.SAMPLEN = 0x00;
|
||||
while(ADC->STATUS.bit.SYNCBUSY);
|
||||
|
||||
ADC->INPUTCTRL.reg = ADC_INPUTCTRL_INPUTSCAN(HAL_ADC_AIN_LEN) // scan (INPUTSCAN + NUM_EXTUDERS - 1) pins
|
||||
| ADC_INPUTCTRL_GAIN_DIV2 |ADC_INPUTCTRL_MUXNEG_GND| HAL_ADC_AIN_START ; /* set to first AIN */
|
||||
|
||||
while(ADC->STATUS.bit.SYNCBUSY);
|
||||
|
||||
ADC->INTENSET.reg |= ADC_INTENSET_RESRDY; // enable Result Ready ADC interrupts
|
||||
while (ADC->STATUS.bit.SYNCBUSY);
|
||||
|
||||
NVIC_EnableIRQ(ADC_IRQn); // enable ADC interrupts
|
||||
|
||||
NVIC_SetPriority(ADC_IRQn, 3);
|
||||
|
||||
ADC->CTRLA.bit.ENABLE = true;
|
||||
}
|
||||
|
||||
volatile uint32_t adc_results[HAL_ADC_AIN_NUM_SENSORS];
|
||||
|
||||
void ADC_Handler() {
|
||||
while(ADC->STATUS.bit.SYNCBUSY == 1);
|
||||
int pos = ADC->INPUTCTRL.bit.INPUTOFFSET;
|
||||
|
||||
adc_results[pos] = ADC->RESULT.reg; /* Read the value. */
|
||||
ADC->INTFLAG.reg = ADC_INTENSET_RESRDY; /* Clear the data ready flag. */
|
||||
}
|
||||
|
||||
void MarlinHAL::adc_start(const pin_t pin) {
|
||||
/* due to the way INPUTOFFSET works, the last sensor is the first position in the array
|
||||
and we want the ADC_handler interrupt to be as simple possible, so we do the calculation here.
|
||||
*/
|
||||
unsigned int pos = PIN_TO_INPUTCTRL(pin) - HAL_ADC_AIN_START + 1;
|
||||
if (pos == HAL_ADC_AIN_NUM_SENSORS) pos = 0;
|
||||
adc_result = adc_results[pos]; // 16-bit resolution
|
||||
//adc_result = 0xFFFF;
|
||||
}
|
||||
|
||||
#endif // __SAMD21__
|
223
Marlin/src/HAL/SAMD21/HAL.h
Normal file
223
Marlin/src/HAL/SAMD21/HAL.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include "fastio.h"
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerialUSB;
|
||||
|
||||
// Serial ports
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
|
||||
extern DefaultSerial2 MSerial0;
|
||||
extern DefaultSerial3 MSerial1;
|
||||
|
||||
|
||||
#define __MSERIAL(X) MSerial##X
|
||||
#define _MSERIAL(X) __MSERIAL(X)
|
||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||
|
||||
#if WITHIN(SERIAL_PORT, 0, 1)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#elif SERIAL_PORT == -1
|
||||
#define MYSERIAL1 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT must be -1 (Native USB only)."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if WITHIN(SERIAL_PORT_2, 0, 1)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT)
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be -1 (Native USB only)."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
#if WITHIN(MMU2_SERIAL_PORT, 0, 1)
|
||||
#define MMU2_SERIAL MSERIAL(SERIAL_PORT)
|
||||
#elif MMU2_SERIAL_PORT == -1
|
||||
#define MMU2_SERIAL MSerialUSB
|
||||
#else
|
||||
#error "MMU2_SERIAL_PORT must be -1 (Native USB only)."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if WITHIN(LCD_SERIAL_PORT, 0, 1)
|
||||
#define LCD_SERIAL MSERIAL(SERIAL_PORT)
|
||||
#elif LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL MSerialUSB
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be -1 (Native USB only)."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
|
||||
|
||||
class Servo;
|
||||
typedef Servo hal_servo_t;
|
||||
|
||||
//
|
||||
// Interrupts
|
||||
//
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
#define cli() __disable_irq() // Disable interrupts
|
||||
#define sei() __enable_irq() // Enable interrupts
|
||||
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
|
||||
#define HAL_ADC_FILTERED 1 // Disable Marlin's oversampling. The HAL filters ADC values.
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 12
|
||||
#define HAL_ADC_AIN_START ADC_INPUTCTRL_MUXPOS_PIN3
|
||||
#define HAL_ADC_AIN_NUM_SENSORS 3
|
||||
#define HAL_ADC_AIN_LEN HAL_ADC_AIN_NUM_SENSORS-1
|
||||
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
//
|
||||
// Tone
|
||||
//
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
|
||||
void noTone(const pin_t _pin);
|
||||
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
|
||||
|
||||
extern "C" int freeMemory();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
// Watchdog
|
||||
static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {});
|
||||
static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {});
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { sei(); }
|
||||
static void isr_off() { cli(); }
|
||||
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const uint8_t ch) {}
|
||||
|
||||
// Begin ADC sampling on the given pin. Called from Temperature::isr!
|
||||
static void adc_start(const pin_t pin);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
private:
|
||||
static void dma_init();
|
||||
};
|
148
Marlin/src/HAL/SAMD21/HAL_SPI.cpp
Normal file
148
Marlin/src/HAL/SAMD21/HAL_SPI.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hardware and software SPI implementations are included in this file.
|
||||
*
|
||||
* Control of the slave select pin(s) is handled by the calling routines and
|
||||
* SAMD21 let hardware SPI handling to remove SS from its logic.
|
||||
*/
|
||||
|
||||
#ifdef __SAMD21__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include <SPI.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#if EITHER(SOFTWARE_SPI, FORCE_SOFT_SPI)
|
||||
|
||||
// ------------------------
|
||||
// Software SPI
|
||||
// ------------------------
|
||||
#error "Software SPI not supported for SAMD21. Use Hardware SPI."
|
||||
|
||||
#else // !SOFTWARE_SPI
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
// ------------------------
|
||||
// Hardware SPI
|
||||
// ------------------------
|
||||
void spiBegin() {
|
||||
spiInit(SPI_HALF_SPEED);
|
||||
}
|
||||
|
||||
void spiInit(uint8_t spiRate) {
|
||||
// Use datarates Marlin uses
|
||||
uint32_t clock;
|
||||
switch (spiRate) {
|
||||
case SPI_FULL_SPEED: clock = 8000000; break;
|
||||
case SPI_HALF_SPEED: clock = 4000000; break;
|
||||
case SPI_QUARTER_SPEED: clock = 2000000; break;
|
||||
case SPI_EIGHTH_SPEED: clock = 1000000; break;
|
||||
case SPI_SIXTEENTH_SPEED: clock = 500000; break;
|
||||
case SPI_SPEED_5: clock = 250000; break;
|
||||
case SPI_SPEED_6: clock = 125000; break;
|
||||
default: clock = 4000000; break; // Default from the SPI library
|
||||
}
|
||||
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
|
||||
SPI.begin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receives a single byte from the SPI port.
|
||||
*
|
||||
* @return Byte received
|
||||
*
|
||||
* @details
|
||||
*/
|
||||
uint8_t spiRec() {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
uint8_t returnByte = SPI.transfer(0xFF);
|
||||
SPI.endTransaction();
|
||||
return returnByte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receives a number of bytes from the SPI port to a buffer
|
||||
*
|
||||
* @param buf Pointer to starting address of buffer to write to.
|
||||
* @param nbyte Number of bytes to receive.
|
||||
* @return Nothing
|
||||
*/
|
||||
void spiRead(uint8_t *buf, uint16_t nbyte) {
|
||||
if (nbyte == 0) return;
|
||||
memset(buf, 0xFF, nbyte);
|
||||
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(buf, nbyte);
|
||||
SPI.endTransaction();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sends a single byte on SPI port
|
||||
*
|
||||
* @param b Byte to send
|
||||
*
|
||||
* @details
|
||||
*/
|
||||
void spiSend(uint8_t b) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(b);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write token and then write from 512 byte buffer to SPI (for SD card)
|
||||
*
|
||||
* @param buf Pointer with buffer start address
|
||||
* @return Nothing
|
||||
*
|
||||
* @details Uses DMA
|
||||
*/
|
||||
void spiSendBlock(uint8_t token, const uint8_t *buf) {
|
||||
SPI.beginTransaction(spiConfig);
|
||||
SPI.transfer(token);
|
||||
SPI.transfer((uint8_t*)buf, 512);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
|
||||
spiConfig = SPISettings(spiClock, (BitOrder)bitOrder, dataMode);
|
||||
SPI.beginTransaction(spiConfig);
|
||||
}
|
||||
#endif // !SOFTWARE_SPI
|
||||
|
||||
#endif // __SAMD21__
|
31
Marlin/src/HAL/SAMD21/MarlinSPI.h
Normal file
31
Marlin/src/HAL/SAMD21/MarlinSPI.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
using MarlinSPI = SPIClass;
|
82
Marlin/src/HAL/SAMD21/QSPIFlash.cpp
Normal file
82
Marlin/src/HAL/SAMD21/QSPIFlash.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(QSPI_EEPROM)
|
||||
|
||||
#include "QSPIFlash.h"
|
||||
|
||||
#define INVALID_ADDR 0xFFFFFFFF
|
||||
#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1))
|
||||
#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1))
|
||||
|
||||
Adafruit_SPIFlashBase * QSPIFlash::_flashBase = nullptr;
|
||||
uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE];
|
||||
uint32_t QSPIFlash::_addr = INVALID_ADDR;
|
||||
|
||||
void QSPIFlash::begin() {
|
||||
if (_flashBase) return;
|
||||
|
||||
_flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI());
|
||||
_flashBase->begin(nullptr);
|
||||
}
|
||||
|
||||
size_t QSPIFlash::size() {
|
||||
return _flashBase->size();
|
||||
}
|
||||
|
||||
uint8_t QSPIFlash::readByte(const uint32_t address) {
|
||||
if (SECTOR_OF(address) == _addr) return _buf[OFFSET_OF(address)];
|
||||
|
||||
return _flashBase->read8(address);
|
||||
}
|
||||
|
||||
void QSPIFlash::writeByte(const uint32_t address, const uint8_t value) {
|
||||
uint32_t const sector_addr = SECTOR_OF(address);
|
||||
|
||||
// Page changes, flush old and update new cache
|
||||
if (sector_addr != _addr) {
|
||||
flush();
|
||||
_addr = sector_addr;
|
||||
|
||||
// read a whole page from flash
|
||||
_flashBase->readBuffer(sector_addr, _buf, SFLASH_SECTOR_SIZE);
|
||||
}
|
||||
|
||||
_buf[OFFSET_OF(address)] = value;
|
||||
}
|
||||
|
||||
void QSPIFlash::flush() {
|
||||
if (_addr == INVALID_ADDR) return;
|
||||
|
||||
_flashBase->eraseSector(_addr / SFLASH_SECTOR_SIZE);
|
||||
_flashBase->writeBuffer(_addr, _buf, SFLASH_SECTOR_SIZE);
|
||||
|
||||
_addr = INVALID_ADDR;
|
||||
}
|
||||
|
||||
#endif // QSPI_EEPROM
|
49
Marlin/src/HAL/SAMD21/QSPIFlash.h
Normal file
49
Marlin/src/HAL/SAMD21/QSPIFlash.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file QSPIFlash.h
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach and Dean Miller for Adafruit Industries LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Derived from Adafruit_SPIFlash class with no SdFat references
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Adafruit_SPIFlashBase.h>
|
||||
|
||||
// This class extends Adafruit_SPIFlashBase by adding caching support.
|
||||
//
|
||||
// This class will use 4096 Bytes of RAM as a block cache.
|
||||
class QSPIFlash {
|
||||
public:
|
||||
static void begin();
|
||||
static size_t size();
|
||||
static uint8_t readByte(const uint32_t address);
|
||||
static void writeByte(const uint32_t address, const uint8_t v);
|
||||
static void flush();
|
||||
|
||||
private:
|
||||
static Adafruit_SPIFlashBase * _flashBase;
|
||||
static uint8_t _buf[SFLASH_SECTOR_SIZE];
|
||||
static uint32_t _addr;
|
||||
};
|
||||
|
||||
extern QSPIFlash qspi;
|
66
Marlin/src/HAL/SAMD21/SAMD21.h
Normal file
66
Marlin/src/HAL/SAMD21/SAMD21.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
#define SYNC(sc) while (sc) { \
|
||||
asm(""); \
|
||||
}
|
||||
|
||||
// Get SAMD port/pin from specified arduino pin
|
||||
#define GET_SAMD_PORT(P) _GET_SAMD_PORT(PIN_TO_SAMD_PIN(P))
|
||||
#define GET_SAMD_PIN(P) _GET_SAMD_PIN(PIN_TO_SAMD_PIN(P))
|
||||
|
||||
// Get external interrupt line associated to specified arduino pin
|
||||
#define PIN_TO_EILINE(P) _SAMDPORTPIN_TO_EILINE(GET_SAMD_PORT(P), GET_SAMD_PIN(P))
|
||||
|
||||
// Get adc/ain associated to specified arduino pin
|
||||
#define PIN_TO_ADC(P) (ANAPIN_TO_ADCAIN(P) >> 8)
|
||||
|
||||
// Private defines
|
||||
#define PIN_TO_SAMD_PIN(P) DIO##P##_PIN
|
||||
|
||||
#define _GET_SAMD_PORT(P) ((P) >> 5)
|
||||
#define _GET_SAMD_PIN(P) ((P) & 0x1F)
|
||||
|
||||
// Get external interrupt line
|
||||
#define _SAMDPORTPIN_TO_EILINE(P,B) ((P == 0 && WITHIN(B, 0, 31) && B != 26 && B != 28 && B != 29) ? (B) & 0xF \
|
||||
: (P == 1 && (WITHIN(B, 0, 25) || WITHIN(B, 30, 31))) ? (B) & 0xF \
|
||||
: (P == 1 && WITHIN(B, 26, 29)) ? 12 + (B) - 26 \
|
||||
: (P == 2 && (WITHIN(B, 0, 6) || WITHIN(B, 10, 31)) && B != 29) ? (B) & 0xF \
|
||||
: (P == 2 && B == 7) ? 9 \
|
||||
: (P == 3 && WITHIN(B, 0, 1)) ? (B) \
|
||||
: (P == 3 && WITHIN(B, 8, 12)) ? 3 + (B) - 8 \
|
||||
: (P == 3 && WITHIN(B, 20, 21)) ? 10 + (B) - 20 \
|
||||
: -1)
|
||||
|
||||
|
||||
|
||||
#define A2_AIN 3
|
||||
#define A3_AIN 4
|
||||
#define A4_AIN 5
|
||||
#define PIN_TO_AIN(P) A##P##_AIN
|
||||
#define AIN_TO_RESULT(P) ( (P - HAL_ADC_AIN_START == HAL_ADC_AIN_NUM_SENSORS-1) ? 0 : (P - HAL_ADC_AIN_START + 1) )
|
220
Marlin/src/HAL/SAMD21/Servo.cpp
Normal file
220
Marlin/src/HAL/SAMD21/Servo.cpp
Normal file
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* This comes from Arduino library which at the moment is buggy and uncompilable
|
||||
*/
|
||||
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SERVOS
|
||||
|
||||
#include "../shared/servo.h"
|
||||
#include "../shared/servo_private.h"
|
||||
#include "SAMD21.h"
|
||||
|
||||
#define __TC_GCLK_ID(t) TC##t##_GCLK_ID
|
||||
#define _TC_GCLK_ID(t) __TC_GCLK_ID(t)
|
||||
#define TC_GCLK_ID _TC_GCLK_ID(SERVO_TC)
|
||||
|
||||
#define _TC_PRESCALER(d) TC_CTRLA_PRESCALER_DIV##d##_Val
|
||||
#define TC_PRESCALER(d) _TC_PRESCALER(d)
|
||||
|
||||
#define __SERVO_IRQn(t) TC##t##_IRQn
|
||||
#define _SERVO_IRQn(t) __SERVO_IRQn(t)
|
||||
#define SERVO_IRQn _SERVO_IRQn(SERVO_TC)
|
||||
|
||||
#define HAL_SERVO_TIMER_ISR() TC_HANDLER(SERVO_TC)
|
||||
|
||||
#define TIMER_TCCHANNEL(t) ((t) & 1)
|
||||
#define TC_COUNTER_START_VAL 0xFFFF
|
||||
|
||||
|
||||
static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval)
|
||||
|
||||
FORCE_INLINE static uint16_t getTimerCount() {
|
||||
Tcc * const tc = timer_config[SERVO_TC].pTcc;
|
||||
|
||||
tc->CTRLBSET.reg = TCC_CTRLBCLR_CMD_READSYNC;
|
||||
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
|
||||
return tc->COUNT.bit.COUNT;
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// Interrupt handler for the TC
|
||||
// ----------------------------
|
||||
HAL_SERVO_TIMER_ISR() {
|
||||
Tcc * const tc = timer_config[SERVO_TC].pTcc;
|
||||
const timer16_Sequence_t timer =
|
||||
#ifndef _useTimer1
|
||||
_timer2
|
||||
#elif !defined(_useTimer2)
|
||||
_timer1
|
||||
#else
|
||||
(tc->INTFLAG.reg & tc->INTENSET.reg & TC_INTFLAG_MC0) ? _timer1 : _timer2
|
||||
#endif
|
||||
;
|
||||
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
|
||||
|
||||
int8_t cho = currentServoIndex[timer]; // Handle the prior servo first
|
||||
if (cho < 0) { // Servo -1 indicates the refresh interval completed...
|
||||
#if defined(_useTimer1) && defined(_useTimer2)
|
||||
if (currentServoIndex[timer ^ 1] >= 0) {
|
||||
// Wait for both channels
|
||||
// Clear the interrupt
|
||||
tc->INTFLAG.reg = (tcChannel == 0) ? TC_INTFLAG_MC0 : TC_INTFLAG_MC1;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
tc->COUNT.reg = TC_COUNTER_START_VAL; // ...so reset the timer
|
||||
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
}
|
||||
else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled?
|
||||
digitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW
|
||||
|
||||
currentServoIndex[timer] = ++cho; // go to the next channel (or 0)
|
||||
if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) {
|
||||
if (SERVO(timer, cho).Pin.isActive) // activated?
|
||||
digitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH
|
||||
|
||||
tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, cho).ticks;
|
||||
}
|
||||
else {
|
||||
// finished all channels so wait for the refresh period to expire before starting over
|
||||
currentServoIndex[timer] = -1; // reset the timer COUNT.reg on the next call
|
||||
const uint16_t cval = getTimerCount() - 256 / (SERVO_TIMER_PRESCALER), // allow 256 cycles to ensure the next CV not missed
|
||||
ival = (TC_COUNTER_START_VAL) - (uint16_t)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed
|
||||
tc->CC[tcChannel].reg = min(cval, ival);
|
||||
}
|
||||
if (tcChannel == 0) {
|
||||
SYNC(tc->SYNCBUSY.bit.CC0);
|
||||
tc->INTFLAG.reg = TC_INTFLAG_MC0; // Clear the interrupt
|
||||
}
|
||||
else {
|
||||
SYNC(tc->SYNCBUSY.bit.CC1);
|
||||
tc->INTFLAG.reg = TC_INTFLAG_MC1; // Clear the interrupt
|
||||
}
|
||||
}
|
||||
|
||||
void initISR(const timer16_Sequence_t timer) {
|
||||
Tcc * const tc = timer_config[SERVO_TC].pTcc;
|
||||
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
|
||||
|
||||
static bool initialized = false; // Servo TC has been initialized
|
||||
if (!initialized) {
|
||||
NVIC_DisableIRQ(SERVO_IRQn);
|
||||
|
||||
// Disable the timer
|
||||
tc->CTRLA.bit.ENABLE = false;
|
||||
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
|
||||
// Select GCLK0 as timer/counter input clock source
|
||||
GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID));
|
||||
SYNC (GCLK->STATUS.bit.SYNCBUSY);
|
||||
|
||||
// Reset the timer
|
||||
tc->CTRLA.bit.SWRST = true;
|
||||
SYNC(tc->CTRLA.bit.SWRST);
|
||||
|
||||
// Set timer counter mode to 16 bits
|
||||
tc->CTRLA.reg = TC_CTRLA_MODE_COUNT16;
|
||||
|
||||
// Set timer counter mode as normal PWM
|
||||
tc->WAVE.bit.WAVEGEN = TCC_WAVE_WAVEGEN_NPWM_Val;
|
||||
|
||||
// Set the prescaler factor
|
||||
tc->CTRLA.bit.PRESCALER = TC_PRESCALER(SERVO_TIMER_PRESCALER);
|
||||
|
||||
// Count down
|
||||
tc->CTRLBSET.reg = TCC_CTRLBCLR_DIR;
|
||||
SYNC(tc->SYNCBUSY.bit.CTRLB);
|
||||
|
||||
// Reset all servo indexes
|
||||
memset((void *)currentServoIndex, 0xFF, sizeof(currentServoIndex));
|
||||
|
||||
// Configure interrupt request
|
||||
NVIC_ClearPendingIRQ(SERVO_IRQn);
|
||||
NVIC_SetPriority(SERVO_IRQn, 5);
|
||||
NVIC_EnableIRQ(SERVO_IRQn);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
if (!tc->CTRLA.bit.ENABLE) {
|
||||
// Reset the timer counter
|
||||
tc->COUNT.reg = TC_COUNTER_START_VAL;
|
||||
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
|
||||
// Enable the timer and start it
|
||||
tc->CTRLA.bit.ENABLE = true;
|
||||
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
}
|
||||
// First interrupt request after 1 ms
|
||||
tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)usToTicks(1000UL);
|
||||
|
||||
if (tcChannel == 0 ) {
|
||||
SYNC(tc->SYNCBUSY.bit.CC0);
|
||||
|
||||
// Clear pending match interrupt
|
||||
tc->INTFLAG.reg = TC_INTENSET_MC0;
|
||||
// Enable the match channel interrupt request
|
||||
tc->INTENSET.reg = TC_INTENSET_MC0;
|
||||
}
|
||||
else {
|
||||
SYNC(tc->SYNCBUSY.bit.CC1);
|
||||
|
||||
// Clear pending match interrupt
|
||||
tc->INTFLAG.reg = TC_INTENSET_MC1;
|
||||
// Enable the match channel interrupt request
|
||||
tc->INTENSET.reg = TC_INTENSET_MC1;
|
||||
}
|
||||
}
|
||||
|
||||
void finISR(const timer16_Sequence_t timer_index) {
|
||||
Tcc * const tc = timer_config[SERVO_TC].pTcc;
|
||||
const uint8_t tcChannel = TIMER_TCCHANNEL(timer_index);
|
||||
|
||||
// Disable the match channel interrupt request
|
||||
tc->INTENCLR.reg = (tcChannel == 0) ? TC_INTENCLR_MC0 : TC_INTENCLR_MC1;
|
||||
|
||||
if (true
|
||||
#if defined(_useTimer1) && defined(_useTimer2)
|
||||
&& (tc->INTENCLR.reg & (TC_INTENCLR_MC0|TC_INTENCLR_MC1)) == 0
|
||||
#endif
|
||||
) {
|
||||
// Disable the timer if not used
|
||||
tc->CTRLA.bit.ENABLE = false;
|
||||
SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_SERVOS
|
||||
|
||||
#endif // __SAMD21__
|
45
Marlin/src/HAL/SAMD21/ServoTimers.h
Normal file
45
Marlin/src/HAL/SAMD21/ServoTimers.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
#define _useTimer1
|
||||
#define _useTimer2
|
||||
|
||||
#define TRIM_DURATION 5 // compensation ticks to trim adjust for digitalWrite delays
|
||||
#define SERVO_TIMER_PRESCALER 64 // timer prescaler factor to 64 (avoid overflowing 16-bit clock counter, at 120MHz this is 1831 ticks per millisecond
|
||||
|
||||
#define SERVO_TC 3
|
||||
|
||||
typedef enum {
|
||||
#ifdef _useTimer1
|
||||
_timer1,
|
||||
#endif
|
||||
#ifdef _useTimer2
|
||||
_timer2,
|
||||
#endif
|
||||
_Nbr_16timers
|
||||
} timer16_Sequence_t;
|
141
Marlin/src/HAL/SAMD21/eeprom_flash.cpp
Normal file
141
Marlin/src/HAL/SAMD21/eeprom_flash.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION)
|
||||
|
||||
#define TOTAL_FLASH_SIZE (MARLIN_EEPROM_SIZE+255)/256*256
|
||||
|
||||
/* reserve flash memory */
|
||||
static const uint8_t flashdata[TOTAL_FLASH_SIZE] __attribute__((__aligned__(256))) { }; \
|
||||
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
size_t PersistentStore::capacity() {
|
||||
return MARLIN_EEPROM_SIZE;
|
||||
/* const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ,
|
||||
sblk = NVMCTRL->SEESTAT.bit.SBLK;
|
||||
|
||||
return (!psz && !sblk) ? 0
|
||||
: (psz <= 2) ? (0x200 << psz)
|
||||
: (sblk == 1 || psz == 3) ? 4096
|
||||
: (sblk == 2 || psz == 4) ? 8192
|
||||
: (sblk <= 4 || psz == 5) ? 16384
|
||||
: (sblk >= 9 && psz == 7) ? 65536
|
||||
: 32768;*/
|
||||
}
|
||||
|
||||
uint32_t PAGE_SIZE;
|
||||
uint32_t ROW_SIZE;
|
||||
bool hasWritten = false;
|
||||
uint8_t * buffer;
|
||||
|
||||
void _erase(const volatile void *flash_ptr) {
|
||||
NVMCTRL->ADDR.reg = ((uint32_t)flash_ptr) / 2;
|
||||
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER;
|
||||
while (!NVMCTRL->INTFLAG.bit.READY) { }
|
||||
|
||||
}
|
||||
|
||||
void erase(const volatile void *flash_ptr, uint32_t size) {
|
||||
const uint8_t *ptr = (const uint8_t *)flash_ptr;
|
||||
while (size > ROW_SIZE) {
|
||||
_erase(ptr);
|
||||
ptr += ROW_SIZE;
|
||||
size -= ROW_SIZE;
|
||||
}
|
||||
_erase(ptr);
|
||||
}
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
/* clear page buffer*/
|
||||
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
|
||||
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
|
||||
|
||||
PAGE_SIZE = pow(2,3 + NVMCTRL->PARAM.bit.PSZ);
|
||||
ROW_SIZE= PAGE_SIZE * 4;
|
||||
/*NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active
|
||||
if (NVMCTRL->SEESTAT.bit.RLOCK)
|
||||
NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); */ // Unlock E2P data write access
|
||||
// erase(&flashdata[0], TOTAL_FLASH_SIZE);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
if (hasWritten) {
|
||||
erase(&flashdata[0], TOTAL_FLASH_SIZE);
|
||||
|
||||
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
|
||||
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
|
||||
|
||||
NVMCTRL->CTRLB.bit.MANW = 0;
|
||||
|
||||
volatile uint32_t *dst_addr = (volatile uint32_t *) &flashdata;
|
||||
|
||||
uint32_t *pointer = (uint32_t *) buffer;
|
||||
for (uint32_t i = 0; i < TOTAL_FLASH_SIZE; i+=4) {
|
||||
|
||||
*dst_addr = (uint32_t) *pointer;
|
||||
pointer++;
|
||||
dst_addr ++;
|
||||
}
|
||||
|
||||
// Execute "WP" Write Page
|
||||
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP;
|
||||
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
|
||||
|
||||
free(buffer);
|
||||
hasWritten = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
if (!hasWritten) {
|
||||
// init temp buffer
|
||||
buffer = (uint8_t *) malloc(MARLIN_EEPROM_SIZE);
|
||||
hasWritten=true;
|
||||
}
|
||||
|
||||
memcpy(buffer+pos,value,size);
|
||||
pos += size;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
volatile uint8_t *dst_addr = (volatile uint8_t *) &flashdata;
|
||||
dst_addr += pos;
|
||||
|
||||
memcpy(value,(const void *) dst_addr,size);
|
||||
pos += size;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // FLASH_EEPROM_EMULATION
|
||||
#endif // __SAMD21__
|
79
Marlin/src/HAL/SAMD21/eeprom_qspi.cpp
Normal file
79
Marlin/src/HAL/SAMD21/eeprom_qspi.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(QSPI_EEPROM)
|
||||
|
||||
#error "QSPI_EEPROM emulation Not implemented on SAMD21"
|
||||
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
#include "QSPIFlash.h"
|
||||
|
||||
static bool initialized;
|
||||
|
||||
size_t PersistentStore::capacity() { return qspi.size(); }
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
if (!initialized) {
|
||||
qspi.begin();
|
||||
initialized = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
qspi.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
while (size--) {
|
||||
const uint8_t v = *value;
|
||||
qspi.writeByte(pos, v);
|
||||
crc16(crc, &v, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
while (size--) {
|
||||
uint8_t c = qspi.readByte(pos);
|
||||
if (writing) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // QSPI_EEPROM
|
||||
#endif // __SAMD21__
|
82
Marlin/src/HAL/SAMD21/eeprom_wired.cpp
Normal file
82
Marlin/src/HAL/SAMD21/eeprom_wired.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if USE_WIRED_EEPROM
|
||||
|
||||
#error "USE_WIRED_EEPROM emulation Not implemented on SAMD21"
|
||||
/**
|
||||
* PersistentStore for Arduino-style EEPROM interface
|
||||
* with simple implementations supplied by Marlin.
|
||||
*/
|
||||
|
||||
#include "../shared/eeprom_if.h"
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
#ifndef MARLIN_EEPROM_SIZE
|
||||
#error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM."
|
||||
#endif
|
||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
||||
|
||||
bool PersistentStore::access_start() { eeprom_init(); return true; }
|
||||
bool PersistentStore::access_finish() { return true; }
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
uint16_t written = 0;
|
||||
while (size--) {
|
||||
const uint8_t v = *value;
|
||||
uint8_t * const p = (uint8_t * const)pos;
|
||||
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
|
||||
eeprom_write_byte(p, v);
|
||||
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
|
||||
if (eeprom_read_byte(p) != v) {
|
||||
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
crc16(crc, &v, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
while (size--) {
|
||||
uint8_t c = eeprom_read_byte((uint8_t*)pos);
|
||||
if (writing) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // USE_WIRED_EEPROM
|
||||
#endif // __SAMD21__
|
253
Marlin/src/HAL/SAMD21/endstop_interrupts.h
Normal file
253
Marlin/src/HAL/SAMD21/endstop_interrupts.h
Normal file
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Endstop interrupts for ATMEL SAMD21 based targets.
|
||||
*
|
||||
* On SAMD21, all pins support external interrupt capability.
|
||||
* Any pin can be used for external interrupts, but there are some restrictions.
|
||||
* At most 16 different external interrupts can be used at one time.
|
||||
* Further, you can’t just pick any 16 pins to use. This is because every pin on the SAMD21
|
||||
* connects to what is called an EXTINT line, and only one pin per EXTINT line can be used for external
|
||||
* interrupts at a time
|
||||
*/
|
||||
|
||||
/**
|
||||
* Endstop Interrupts
|
||||
*
|
||||
* Without endstop interrupts the endstop pins must be polled continually in
|
||||
* the temperature-ISR via endstops.update(), most of the time finding no change.
|
||||
* With this feature endstops.update() is called only when we know that at
|
||||
* least one endstop has changed state, saving valuable CPU cycles.
|
||||
*
|
||||
* This feature only works when all used endstop pins can generate an 'external interrupt'.
|
||||
*
|
||||
* Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
|
||||
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
|
||||
*/
|
||||
|
||||
#include "../../module/endstops.h"
|
||||
|
||||
#define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2))
|
||||
#define MATCH_X_MAX_EILINE(P) TERN0(HAS_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN))
|
||||
#define MATCH_X_MIN_EILINE(P) TERN0(HAS_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN))
|
||||
#define MATCH_Y_MAX_EILINE(P) TERN0(HAS_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN))
|
||||
#define MATCH_Y_MIN_EILINE(P) TERN0(HAS_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN))
|
||||
#define MATCH_Z_MAX_EILINE(P) TERN0(HAS_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN))
|
||||
#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN))
|
||||
#define MATCH_I_MAX_EILINE(P) TERN0(HAS_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN))
|
||||
#define MATCH_I_MIN_EILINE(P) TERN0(HAS_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN))
|
||||
#define MATCH_J_MAX_EILINE(P) TERN0(HAS_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN))
|
||||
#define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN))
|
||||
#define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN))
|
||||
#define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN))
|
||||
#define MATCH_U_MAX_EILINE(P) TERN0(HAS_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN))
|
||||
#define MATCH_U_MIN_EILINE(P) TERN0(HAS_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN))
|
||||
#define MATCH_V_MAX_EILINE(P) TERN0(HAS_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN))
|
||||
#define MATCH_V_MIN_EILINE(P) TERN0(HAS_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN))
|
||||
#define MATCH_W_MAX_EILINE(P) TERN0(HAS_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN))
|
||||
#define MATCH_W_MIN_EILINE(P) TERN0(HAS_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN))
|
||||
#define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN))
|
||||
#define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN))
|
||||
#define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN))
|
||||
#define MATCH_Z3_MIN_EILINE(P) TERN0(HAS_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN))
|
||||
#define MATCH_Z4_MAX_EILINE(P) TERN0(HAS_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN))
|
||||
#define MATCH_Z4_MIN_EILINE(P) TERN0(HAS_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN))
|
||||
#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(HAS_Z_MIN_PROBE_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN))
|
||||
|
||||
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
|
||||
&& !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \
|
||||
&& !MATCH_Y_MAX_EILINE(P) && !MATCH_Y_MIN_EILINE(P) \
|
||||
&& !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \
|
||||
&& !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \
|
||||
&& !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \
|
||||
&& !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \
|
||||
&& !MATCH_U_MAX_EILINE(P) && !MATCH_U_MIN_EILINE(P) \
|
||||
&& !MATCH_V_MAX_EILINE(P) && !MATCH_V_MIN_EILINE(P) \
|
||||
&& !MATCH_W_MAX_EILINE(P) && !MATCH_W_MIN_EILINE(P) \
|
||||
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
|
||||
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
|
||||
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
|
||||
&& !MATCH_Z_MIN_PROBE_EILINE(P) )
|
||||
|
||||
// One ISR for all EXT-Interrupts
|
||||
void endstop_ISR() { endstops.update(); }
|
||||
|
||||
void setup_endstop_interrupts() {
|
||||
#define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
|
||||
#if HAS_X_MAX
|
||||
#if !AVAILABLE_EILINE(X_MAX_PIN)
|
||||
#error "X_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(X_MAX_PIN);
|
||||
#endif
|
||||
#if HAS_X_MIN
|
||||
#if !AVAILABLE_EILINE(X_MIN_PIN)
|
||||
#error "X_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(X_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
#if !AVAILABLE_EILINE(Y_MAX_PIN)
|
||||
#error "Y_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Y_MAX_PIN);
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
#if !AVAILABLE_EILINE(Y_MIN_PIN)
|
||||
#error "Y_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Y_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
#if !AVAILABLE_EILINE(Z_MAX_PIN)
|
||||
#error "Z_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z_MAX_PIN);
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
#if !AVAILABLE_EILINE(Z_MIN_PIN)
|
||||
#error "Z_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
#if !AVAILABLE_EILINE(Z2_MAX_PIN)
|
||||
#error "Z2_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z2_MAX_PIN);
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
#if !AVAILABLE_EILINE(Z2_MIN_PIN)
|
||||
#error "Z2_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z2_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_Z3_MAX
|
||||
#if !AVAILABLE_EILINE(Z3_MAX_PIN)
|
||||
#error "Z3_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z3_MAX_PIN);
|
||||
#endif
|
||||
#if HAS_Z3_MIN
|
||||
#if !AVAILABLE_EILINE(Z3_MIN_PIN)
|
||||
#error "Z3_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z3_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_Z4_MAX
|
||||
#if !AVAILABLE_EILINE(Z4_MAX_PIN)
|
||||
#error "Z4_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z4_MAX_PIN);
|
||||
#endif
|
||||
#if HAS_Z4_MIN
|
||||
#if !AVAILABLE_EILINE(Z4_MIN_PIN)
|
||||
#error "Z4_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z4_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
#if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN)
|
||||
#error "Z_MIN_PROBE_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z_MIN_PROBE_PIN);
|
||||
#endif
|
||||
#if HAS_I_MAX
|
||||
#if !AVAILABLE_EILINE(I_MAX_PIN)
|
||||
#error "I_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(I_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_I_MIN
|
||||
#if !AVAILABLE_EILINE(I_MIN_PIN)
|
||||
#error "I_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(I_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_J_MAX
|
||||
#if !AVAILABLE_EILINE(J_MAX_PIN)
|
||||
#error "J_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(J_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_J_MIN
|
||||
#if !AVAILABLE_EILINE(J_MIN_PIN)
|
||||
#error "J_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(J_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_K_MAX
|
||||
#if !AVAILABLE_EILINE(K_MAX_PIN)
|
||||
#error "K_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(K_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_K_MIN
|
||||
#if !AVAILABLE_EILINE(K_MIN_PIN)
|
||||
#error "K_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_U_MAX
|
||||
#if !AVAILABLE_EILINE(U_MAX_PIN)
|
||||
#error "U_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(U_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_U_MIN
|
||||
#if !AVAILABLE_EILINE(U_MIN_PIN)
|
||||
#error "U_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(U_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_V_MAX
|
||||
#if !AVAILABLE_EILINE(V_MAX_PIN)
|
||||
#error "V_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(V_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_V_MIN
|
||||
#if !AVAILABLE_EILINE(V_MIN_PIN)
|
||||
#error "V_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(V_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_W_MAX
|
||||
#if !AVAILABLE_EILINE(W_MAX_PIN)
|
||||
#error "W_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(W_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_W_MIN
|
||||
#if !AVAILABLE_EILINE(W_MIN_PIN)
|
||||
#error "W_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(W_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
}
|
216
Marlin/src/HAL/SAMD21/fastio.h
Normal file
216
Marlin/src/HAL/SAMD21/fastio.h
Normal file
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fast IO functions for SAMD21
|
||||
*/
|
||||
|
||||
#include "SAMD21.h"
|
||||
|
||||
/**
|
||||
* Utility functions
|
||||
*/
|
||||
|
||||
#ifndef MASK
|
||||
#define MASK(PIN) _BV(PIN)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Magic I/O routines
|
||||
*
|
||||
* Now you can simply SET_OUTPUT(IO); WRITE(IO, HIGH); WRITE(IO, LOW);
|
||||
*/
|
||||
|
||||
// Read a pin
|
||||
#define READ(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].IN.reg & MASK(GET_SAMD_PIN(IO))) != 0)
|
||||
|
||||
// Write to a pin
|
||||
#define WRITE(IO,V) do{ \
|
||||
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
|
||||
const uint32_t mask = MASK(GET_SAMD_PIN(IO)); \
|
||||
\
|
||||
if (V) PORT->Group[port].OUTSET.reg = mask; \
|
||||
else PORT->Group[port].OUTCLR.reg = mask; \
|
||||
}while(0)
|
||||
|
||||
// Toggle a pin
|
||||
#define TOGGLE(IO) PORT->Group[(EPortType)GET_SAMD_PORT(IO)].OUTTGL.reg = MASK(GET_SAMD_PIN(IO));
|
||||
|
||||
// Set pin as input
|
||||
#define SET_INPUT(IO) do{ \
|
||||
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
|
||||
const uint32_t pin = GET_SAMD_PIN(IO); \
|
||||
\
|
||||
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN); \
|
||||
PORT->Group[port].DIRCLR.reg = MASK(pin); \
|
||||
}while(0)
|
||||
// Set pin as input with pullup
|
||||
#define SET_INPUT_PULLUP(IO) do{ \
|
||||
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
|
||||
const uint32_t pin = GET_SAMD_PIN(IO); \
|
||||
const uint32_t mask = MASK(pin); \
|
||||
\
|
||||
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \
|
||||
PORT->Group[port].DIRCLR.reg = mask; \
|
||||
PORT->Group[port].OUTSET.reg = mask; \
|
||||
}while(0)
|
||||
// Set pin as input with pulldown
|
||||
#define SET_INPUT_PULLDOWN(IO) do{ \
|
||||
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
|
||||
const uint32_t pin = GET_SAMD_PIN(IO); \
|
||||
const uint32_t mask = MASK(pin); \
|
||||
\
|
||||
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \
|
||||
PORT->Group[port].DIRCLR.reg = mask; \
|
||||
PORT->Group[port].OUTCLR.reg = mask; \
|
||||
}while(0)
|
||||
// Set pin as output (push pull)
|
||||
#define SET_OUTPUT(IO) do{ \
|
||||
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
|
||||
const uint32_t pin = GET_SAMD_PIN(IO); \
|
||||
\
|
||||
PORT->Group[port].DIRSET.reg = MASK(pin); \
|
||||
PORT->Group[port].PINCFG[pin].reg = 0; \
|
||||
}while(0)
|
||||
// Set pin as output (open drain)
|
||||
#define SET_OUTPUT_OD(IO) do{ \
|
||||
const EPortType port = (EPortType)GET_SAMD_PORT(IO); \
|
||||
const uint32_t pin = GET_SAMD_PIN(IO); \
|
||||
\
|
||||
PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_PULLEN); \
|
||||
PORT->Group[port].DIRCLR.reg = MASK(pin); \
|
||||
}while(0)
|
||||
// Set pin as PWM (push pull)
|
||||
#define SET_PWM SET_OUTPUT
|
||||
// Set pin as PWM (open drain)
|
||||
#define SET_PWM_OD SET_OUTPUT_OD
|
||||
|
||||
// check if pin is an output
|
||||
#define IS_OUTPUT(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].DIR.reg & MASK(GET_SAMD_PIN(IO))) \
|
||||
|| (PORT->Group[(EPortType)GET_SAMD_PORT(IO)].PINCFG[GET_SAMD_PIN(IO)].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN)
|
||||
// check if pin is an input
|
||||
#define IS_INPUT(IO) !IS_OUTPUT(IO)
|
||||
|
||||
// Shorthand
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
#define OUT_WRITE_OD(IO,V) do{ SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
#define extDigitalRead(IO) digitalRead(IO)
|
||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||
|
||||
/**
|
||||
* Ports and functions
|
||||
* Added as necessary or if I feel like it- not a comprehensive list!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some of these share the same source and so can't be used in the same time
|
||||
*/
|
||||
#define PWM_PIN(P) (WITHIN(P, 2, 13) || WITHIN(P, 22, 23) || WITHIN(P, 44, 45) || P == 48)
|
||||
|
||||
// Return fulfilled ADCx->INPUTCTRL.reg
|
||||
#define PIN_TO_INPUTCTRL(P) ( (P == 0) ? ADC_INPUTCTRL_MUXPOS_PIN0 \
|
||||
: ((P) == 1) ? ADC_INPUTCTRL_MUXPOS_PIN1 \
|
||||
: ((P) == 2) ? ADC_INPUTCTRL_MUXPOS_PIN3 \
|
||||
: ((P) == 3) ? ADC_INPUTCTRL_MUXPOS_PIN4 \
|
||||
: ((P) == 4) ? ADC_INPUTCTRL_MUXPOS_PIN5 \
|
||||
: ((P) == 5) ? ADC_INPUTCTRL_MUXPOS_PIN5 \
|
||||
: ((P) == 6) ? ADC_INPUTCTRL_MUXPOS_PIN6 \
|
||||
: ((P) == 7) ? ADC_INPUTCTRL_MUXPOS_PIN7 \
|
||||
: ((P) == 8) ? ADC_INPUTCTRL_MUXPOS_PIN8 \
|
||||
: ((P) == 9) ? ADC_INPUTCTRL_MUXPOS_PIN9 \
|
||||
: ((P) == 10) ? ADC_INPUTCTRL_MUXPOS_PIN10 \
|
||||
: ((P) == 11) ? ADC_INPUTCTRL_MUXPOS_PIN11 \
|
||||
: ((P) == 12) ? ADC_INPUTCTRL_MUXPOS_PIN12 \
|
||||
: ((P) == 13) ? ADC_INPUTCTRL_MUXPOS_PIN13 \
|
||||
: ((P) == 14) ? ADC_INPUTCTRL_MUXPOS_PIN14 \
|
||||
: ADC_INPUTCTRL_MUXPOS_PIN15)
|
||||
|
||||
#define digitalPinToAnalogInput(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1)
|
||||
|
||||
/**
|
||||
* pins
|
||||
*/
|
||||
|
||||
// PORTA
|
||||
#define DIO28_PIN PIN_PA02 // A0
|
||||
#define DIO56_PIN PIN_PA03 // A13
|
||||
#define DIO31_PIN PIN_PA04 // A13
|
||||
#define DIO32_PIN PIN_PA05 // A1
|
||||
#define DIO8_PIN PIN_PA06 // A14
|
||||
#define DIO9_PIN PIN_PA07 // A15
|
||||
#define DIO4_PIN PIN_PA08 // A15
|
||||
#define DIO3_PIN PIN_PA09 // A15
|
||||
#define DIO1_PIN PIN_PA10
|
||||
#define DIO0_PIN PIN_PA11
|
||||
#define DIO18_PIN PIN_PA12
|
||||
#define DIO52_PIN PIN_PA13
|
||||
#define DIO2_PIN PIN_PA14
|
||||
#define DIO5_PIN PIN_PA15
|
||||
#define DIO11_PIN PIN_PA16
|
||||
#define DIO13_PIN PIN_PA17
|
||||
#define DIO10_PIN PIN_PA18
|
||||
#define DIO12_PIN PIN_PA19
|
||||
#define DIO6_PIN PIN_PA20
|
||||
#define DIO07_PIN PIN_PA21
|
||||
#define DIO34_PIN PIN_PA22
|
||||
#define DIO35_PIN PIN_PA23
|
||||
#define DIO42_PIN PIN_PA24
|
||||
#define DIO43_PIN PIN_PA25
|
||||
|
||||
#define DIO40_PIN PIN_PA27
|
||||
|
||||
#define DIO26_PIN PIN_PB00
|
||||
#define DIO27_PIN PIN_PB01 // A0
|
||||
#define DIO33_PIN PIN_PB02
|
||||
#define DIO39_PIN PIN_PB03
|
||||
#define DIO14_PIN PIN_PB04
|
||||
#define DIO15_PIN PIN_PB05
|
||||
#define DIO16_PIN PIN_PB06
|
||||
#define DIO17_PIN PIN_PB07
|
||||
#define DIO29_PIN PIN_PB08
|
||||
#define DIO30_PIN PIN_PB09
|
||||
#define DIO37_PIN PIN_PB10
|
||||
#define DIO38_PIN PIN_PB11
|
||||
#define DIO36_PIN PIN_PB12
|
||||
#define DIO19_PIN PIN_PB13
|
||||
#define DIO20_PIN PIN_PB14
|
||||
#define DIO21_PIN PIN_PB15
|
||||
#define DIO22_PIN PIN_PB16
|
||||
#define DIO23_PIN PIN_PB17
|
||||
|
||||
#define DIO44_PIN PIN_PB22
|
||||
#define DIO45_PIN PIN_PB23
|
||||
#define DIO24_PIN PIN_PB30
|
||||
#define DIO25_PIN PIN_PB31
|
||||
|
||||
#define DIO53_PIN PIN_PA21
|
||||
#define DIO54_PIN PIN_PA06
|
||||
#define DIO55_PIN PIN_PA07
|
||||
|
31
Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h
Normal file
31
Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if HAS_SPI_TFT || HAS_FSMC_TFT
|
||||
#error "Sorry! TFT displays are not available for HAL/SAMD21."
|
||||
#endif
|
27
Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h
Normal file
27
Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
33
Marlin/src/HAL/SAMD21/inc/Conditionals_post.h
Normal file
33
Marlin/src/HAL/SAMD21/inc/Conditionals_post.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if USE_FALLBACK_EEPROM
|
||||
#define FLASH_EEPROM_EMULATION
|
||||
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
|
||||
#define USE_SHARED_EEPROM 1
|
||||
#endif
|
50
Marlin/src/HAL/SAMD21/inc/SanityCheck.h
Normal file
50
Marlin/src/HAL/SAMD21/inc/SanityCheck.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test SAMD21 specific configuration values for errors at compile-time.
|
||||
*/
|
||||
|
||||
#if SERVO_TC == MF_TIMER_RTC
|
||||
#error "Servos can't use RTC timer"
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for SAMD21. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDIO_SUPPORT)
|
||||
#error "SDIO_SUPPORT is not supported on SAMD21."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "Features requiring Hardware PWM (FAST_PWM_FAN) are not yet supported on SAMD21."
|
||||
#endif
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#error "POSTMORTEM_DEBUGGING is not yet supported on SAMD21."
|
||||
#endif
|
160
Marlin/src/HAL/SAMD21/pinsDebug.h
Normal file
160
Marlin/src/HAL/SAMD21/pinsDebug.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
#define NUMBER_PINS_TOTAL PINS_COUNT
|
||||
|
||||
#define digitalRead_mod(p) extDigitalRead(p)
|
||||
#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0)
|
||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
||||
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
|
||||
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL)
|
||||
#define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p)
|
||||
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1)
|
||||
#define pwm_status(pin) digitalPinHasPWM(pin)
|
||||
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
|
||||
|
||||
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
||||
// uses pin index
|
||||
#define M43_NEVER_TOUCH(Q) ((Q) >= 75)
|
||||
|
||||
bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
|
||||
const EPortType samdport = g_APinDescription[pin].ulPort;
|
||||
const uint32_t samdpin = g_APinDescription[pin].ulPin;
|
||||
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
|
||||
}
|
||||
|
||||
void pwm_details(int32_t pin) {
|
||||
if (pwm_status(pin)) {
|
||||
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
|
||||
//SERIAL_ECHOPGM("PWM = ", duty);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SAMD21 Board pin| PORT | Label
|
||||
* ----------------+--------+-------
|
||||
* 0 | PB25 | "RX0"
|
||||
* 1 | PB24 | "TX0"
|
||||
* 2 | PC18 |
|
||||
* 3 | PC19 |
|
||||
* 4 | PC20 |
|
||||
* 5 | PC21 |
|
||||
* 6 | PD20 |
|
||||
* 7 | PD21 |
|
||||
* 8 | PB18 |
|
||||
* 9 | PB2 |
|
||||
* 10 | PB22 |
|
||||
* 11 | PB23 |
|
||||
* 12 | PB0 | "A16"
|
||||
* 13 | PB1 | LED AMBER "L" / "A17"
|
||||
* 14 | PB16 | "TX3"
|
||||
* 15 | PB17 | "RX3"
|
||||
* 16 | PC22 | "TX2"
|
||||
* 17 | PC23 | "RX2"
|
||||
* 18 | PB12 | "TX1" / "A18"
|
||||
* 19 | PB13 | "RX1"
|
||||
* 20 | PB20 | "SDA"
|
||||
* 21 | PB21 | "SCL"
|
||||
* 22 | PD12 |
|
||||
* 23 | PA15 |
|
||||
* 24 | PC17 |
|
||||
* 25 | PC16 |
|
||||
* 26 | PA12 |
|
||||
* 27 | PA13 |
|
||||
* 28 | PA14 |
|
||||
* 29 | PB19 |
|
||||
* 30 | PA23 |
|
||||
* 31 | PA22 |
|
||||
* 32 | PA21 |
|
||||
* 33 | PA20 |
|
||||
* 34 | PA19 |
|
||||
* 35 | PA18 |
|
||||
* 36 | PA17 |
|
||||
* 37 | PA16 |
|
||||
* 38 | PB15 |
|
||||
* 39 | PB14 |
|
||||
* 40 | PC13 |
|
||||
* 41 | PC12 |
|
||||
* 42 | PC15 |
|
||||
* 43 | PC14 |
|
||||
* 44 | PC11 |
|
||||
* 45 | PC10 |
|
||||
* 46 | PC6 |
|
||||
* 47 | PC7 |
|
||||
* 48 | PC4 |
|
||||
* 49 | PC5 |
|
||||
* 50 | PD11 |
|
||||
* 51 | PD8 |
|
||||
* 52 | PD9 |
|
||||
* 53 | PD10 |
|
||||
* 54 | PB5 | "A8"
|
||||
* 55 | PB6 | "A9"
|
||||
* 56 | PB7 | "A10"
|
||||
* 57 | PB8 | "A11"
|
||||
* 58 | PB9 | "A12"
|
||||
* 69 | PA4 | "A13"
|
||||
* 60 | PA6 | "A14"
|
||||
* 61 | PA7 | "A15"
|
||||
* 62 | PB17 |
|
||||
* 63 | PB20 |
|
||||
* 64 | PD11 |
|
||||
* 65 | PD8 |
|
||||
* 66 | PD9 |
|
||||
* 67 | PA2 | "A0" / "DAC0"
|
||||
* 68 | PA5 | "A1" / "DAC1"
|
||||
* 69 | PB3 | "A2"
|
||||
* 70 | PC0 | "A3"
|
||||
* 71 | PC1 | "A4"
|
||||
* 72 | PC2 | "A5"
|
||||
* 73 | PC3 | "A6"
|
||||
* 74 | PB4 | "A7"
|
||||
* 75 | PC31 | LED GREEN "RX"
|
||||
* 76 | PC30 | LED GREEN "TX"
|
||||
* 77 | PA27 | USB: Host enable
|
||||
* 78 | PA24 | USB: D-
|
||||
* 79 | PA25 | USB: D+
|
||||
* 80 | PB29 | SD: MISO
|
||||
* 81 | PB27 | SD: SCK
|
||||
* 82 | PB26 | SD: MOSI
|
||||
* 83 | PB28 | SD: CS
|
||||
* 84 | PA3 | AREF
|
||||
* 85 | PA2 | DAC0 (Duplicate)
|
||||
* 86 | PA5 | DAC1 (Duplicate)
|
||||
* 87 | PB1 | LED AMBER "L" (Duplicate)
|
||||
* 88 | PC24 | NeoPixel
|
||||
* 89 | PB10 | QSPI: SCK
|
||||
* 90 | PB11 | QSPI: CS
|
||||
* 91 | PA8 | QSPI: IO0
|
||||
* 92 | PA9 | QSPI: IO1
|
||||
* 93 | PA10 | QSPI: IO2
|
||||
* 94 | PA11 | QSPI: IO3
|
||||
* 95 | PB31 | SD: DETECT
|
||||
*/
|
54
Marlin/src/HAL/SAMD21/spi_pins.h
Normal file
54
Marlin/src/HAL/SAMD21/spi_pins.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 Default SPI Pins
|
||||
*
|
||||
* SS SCK MISO MOSI
|
||||
* +-------------------------+
|
||||
* SPI | 53 52 50 51 |
|
||||
* SPI1 | 83 81 80 82 |
|
||||
* +-------------------------+
|
||||
* Any pin can be used for Chip Select (SD_SS_PIN)
|
||||
*/
|
||||
#ifndef SD_SCK_PIN
|
||||
#define SD_SCK_PIN 38
|
||||
#endif
|
||||
#ifndef SD_MISO_PIN
|
||||
#define SD_MISO_PIN 36
|
||||
#endif
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 37
|
||||
#endif
|
||||
#ifndef SDSS
|
||||
#define SDSS 18
|
||||
#endif
|
||||
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN SDSS
|
||||
#endif
|
217
Marlin/src/HAL/SAMD21/timers.cpp
Normal file
217
Marlin/src/HAL/SAMD21/timers.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#ifdef __SAMD21__
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "ServoTimers.h" // for SERVO_TC
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 9
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
|
||||
{ {.pTcc=TCC0}, TimerType::tcc, TCC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
|
||||
{ {.pTcc=TCC1}, TimerType::tcc, TCC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
|
||||
{ {.pTcc=TCC2}, TimerType::tcc, TCC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
|
||||
{ {.pTc=TC3}, TimerType::tc, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1)
|
||||
{ {.pTc=TC4}, TimerType::tc, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used)
|
||||
{ {.pTc=TC5}, TimerType::tc, TC5_IRQn, TC_PRIORITY(5) },
|
||||
{ {.pTc=TC6}, TimerType::tc, TC6_IRQn, TC_PRIORITY(6) },
|
||||
{ {.pTc=TC7}, TimerType::tc, TC7_IRQn, TC_PRIORITY(7) },
|
||||
{ {.pRtc=RTC}, TimerType::rtc, RTC_IRQn, TC_PRIORITY(8) } // 8 - temperature (assigned priority 6)
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
FORCE_INLINE void Disable_Irq(IRQn_Type irq) {
|
||||
NVIC_DisableIRQ(irq);
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
static bool tcIsSyncing(Tc * tc) {
|
||||
return tc->COUNT32.STATUS.reg & TC_STATUS_SYNCBUSY;
|
||||
}
|
||||
|
||||
static void tcReset( Tc * tc) {
|
||||
tc->COUNT32.CTRLA.reg = TC_CTRLA_SWRST;
|
||||
while (tcIsSyncing(tc)) {}
|
||||
while (tc->COUNT32.CTRLA.bit.SWRST) {}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
|
||||
// Disable interrupt, just in case it was already enabled
|
||||
NVIC_DisableIRQ(irq);
|
||||
NVIC_ClearPendingIRQ(irq);
|
||||
|
||||
if (timer_num == MF_TIMER_RTC) {
|
||||
|
||||
// https://github.com/arduino-libraries/RTCZero
|
||||
Rtc * const rtc = timer_config[timer_num].pRtc;
|
||||
PM->APBAMASK.reg |= PM_APBAMASK_RTC;
|
||||
|
||||
GCLK->CLKCTRL.reg = (uint32_t)((GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK4 | (RTC_GCLK_ID << GCLK_CLKCTRL_ID_Pos)));
|
||||
while (GCLK->STATUS.bit.SYNCBUSY) {}
|
||||
|
||||
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(4) | GCLK_GENCTRL_DIVSEL );
|
||||
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {}
|
||||
|
||||
GCLK->GENDIV.reg = GCLK_GENDIV_ID(4);
|
||||
GCLK->GENDIV.bit.DIV=4;
|
||||
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {}
|
||||
|
||||
// Disable timer interrupt
|
||||
rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
|
||||
SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY);
|
||||
|
||||
while(rtc->MODE0.STATUS.bit.SYNCBUSY) {}
|
||||
|
||||
// Stop timer, just in case, to be able to reconfigure it
|
||||
rtc->MODE0.CTRL.reg =
|
||||
RTC_MODE0_CTRL_MODE_COUNT32 | // Mode 0 = 32-bits counter
|
||||
RTC_MODE0_CTRL_PRESCALER_DIV1024; // Divisor = 1024
|
||||
|
||||
while(rtc->MODE0.STATUS.bit.SYNCBUSY) {}
|
||||
|
||||
// Mode, reset counter on match
|
||||
rtc->MODE0.CTRL.reg = RTC_MODE0_CTRL_MODE_COUNT32 | RTC_MODE0_CTRL_MATCHCLR;
|
||||
|
||||
// Set compare value
|
||||
rtc->MODE0.COMP[0].reg = (32768 + frequency / 2) / frequency;
|
||||
SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY);
|
||||
|
||||
// Enable interrupt on compare
|
||||
rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0; // reset pending interrupt
|
||||
rtc->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0; // enable compare 0 interrupt
|
||||
|
||||
// And start timer
|
||||
rtc->MODE0.CTRL.bit.ENABLE = true;
|
||||
SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY);
|
||||
|
||||
}
|
||||
else if (timer_config[timer_num].type==TimerType::tcc) {
|
||||
|
||||
Tcc * const tc = timer_config[timer_num].pTcc;
|
||||
|
||||
PM->APBCMASK.reg |= PM_APBCMASK_TCC0;
|
||||
GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID));
|
||||
SYNC (GCLK->STATUS.bit.SYNCBUSY);
|
||||
|
||||
tc->CTRLA.reg = TCC_CTRLA_SWRST;
|
||||
SYNC (tc->SYNCBUSY.reg & TCC_SYNCBUSY_SWRST) {}
|
||||
|
||||
SYNC (tc->CTRLA.bit.SWRST);
|
||||
|
||||
tc->CTRLA.reg &= ~(TCC_CTRLA_ENABLE); // disable TC module
|
||||
|
||||
tc->CTRLA.reg |= TCC_WAVE_WAVEGEN_MFRQ;
|
||||
tc->CTRLA.reg |= TCC_CTRLA_PRESCALER_DIV2;
|
||||
tc->CC[0].reg = (HAL_TIMER_RATE) / frequency;
|
||||
tc->INTENSET.reg = TCC_INTFLAG_MC0;
|
||||
tc->CTRLA.reg |= TCC_CTRLA_ENABLE;
|
||||
tc->INTFLAG.reg = 0xFF;
|
||||
SYNC ( tc->STATUS.reg & TC_STATUS_SYNCBUSY);
|
||||
|
||||
}
|
||||
else {
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
|
||||
// Disable timer interrupt
|
||||
tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt
|
||||
|
||||
// TCn clock setup
|
||||
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TC4_TC5)) ;
|
||||
SYNC (GCLK->STATUS.bit.SYNCBUSY);
|
||||
|
||||
tcReset(tc); // reset TC
|
||||
|
||||
// Set Timer counter 5 Mode to 16 bits, it will become a 16bit counter ('mode1' in the datasheet)
|
||||
tc->COUNT32.CTRLA.reg |= TC_CTRLA_MODE_COUNT32;
|
||||
// Set TC waveform generation mode to 'match frequency'
|
||||
tc->COUNT32.CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ;
|
||||
//set prescaler
|
||||
//the clock normally counts at the GCLK_TC frequency, but we can set it to divide that frequency to slow it down
|
||||
//you can use different prescaler divisons here like TC_CTRLA_PRESCALER_DIV1 to get a different range
|
||||
tc->COUNT32.CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1 | TC_CTRLA_ENABLE; //it will divide GCLK_TC frequency by 1024
|
||||
//set the compare-capture register.
|
||||
//The counter will count up to this value (it's a 16bit counter so we use uint16_t)
|
||||
//this is how we fine-tune the frequency, make it count to a lower or higher value
|
||||
//system clock should be 1MHz (8MHz/8) at Reset by default
|
||||
tc->COUNT32.CC[0].reg = (uint16_t) (HAL_TIMER_RATE / frequency);
|
||||
while (tcIsSyncing(tc)) {}
|
||||
|
||||
// Enable the TC interrupt request
|
||||
tc->COUNT32.INTENSET.bit.MC0 = 1;
|
||||
while (tcIsSyncing(tc)) {}
|
||||
}
|
||||
|
||||
NVIC_SetPriority(irq, timer_config[timer_num].priority);
|
||||
NVIC_EnableIRQ(irq);
|
||||
}
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
NVIC_EnableIRQ(irq);
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
Disable_Irq(irq);
|
||||
}
|
||||
|
||||
// missing from CMSIS: Check if interrupt is enabled or not
|
||||
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
||||
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
|
||||
}
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
return NVIC_GetEnabledIRQ(irq);
|
||||
}
|
||||
|
||||
#endif // __SAMD21__
|
160
Marlin/src/HAL/SAMD21/timers.h
Normal file
160
Marlin/src/HAL/SAMD21/timers.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
typedef uint32_t hal_timer_t;
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
|
||||
|
||||
#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals
|
||||
|
||||
#define MF_TIMER_RTC 8 // This is not a TC but a RTC
|
||||
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 4 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
||||
|
||||
#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
|
||||
#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000) // stepper timer ticks per µs
|
||||
#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
|
||||
|
||||
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE
|
||||
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
|
||||
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
|
||||
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
|
||||
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
|
||||
|
||||
#define TC_PRIORITY(t) ( t == SERVO_TC ? 1 \
|
||||
: (t == MF_TIMER_STEP || t == MF_TIMER_PULSE) ? 2 \
|
||||
: (t == MF_TIMER_TEMP) ? 6 : 7 )
|
||||
|
||||
#define _TC_HANDLER(t) void TC##t##_Handler()
|
||||
#define TC_HANDLER(t) _TC_HANDLER(t)
|
||||
#ifndef HAL_STEP_TIMER_ISR
|
||||
#define HAL_STEP_TIMER_ISR() TC_HANDLER(MF_TIMER_STEP)
|
||||
#endif
|
||||
#if MF_TIMER_STEP != MF_TIMER_PULSE
|
||||
#define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE)
|
||||
#endif
|
||||
#if MF_TIMER_TEMP == MF_TIMER_RTC
|
||||
#define HAL_TEMP_TIMER_ISR() void RTC_Handler()
|
||||
#else
|
||||
#define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP)
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
typedef enum { tcc, tc, rtc } TimerType;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
Tc *pTc;
|
||||
Tcc *pTcc;
|
||||
Rtc *pRtc;
|
||||
};
|
||||
TimerType type;
|
||||
IRQn_Type IRQ_Id;
|
||||
uint8_t priority;
|
||||
} tTimerConfig;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
extern const tTimerConfig timer_config[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
|
||||
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
|
||||
// Should never be called with timer MF_TIMER_RTC
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
tc->COUNT32.CC[0].reg = compare;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
// Should never be called with timer MF_TIMER_RTC
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
return (hal_timer_t)tc->COUNT32.CC[0].reg;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
// Should never be called with timer MF_TIMER_RTC
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
tc->COUNT32.READREQ.reg = TC_READREQ_RREQ;
|
||||
// Request a read synchronization
|
||||
SYNC (tc->COUNT32.STATUS.bit.SYNCBUSY);
|
||||
//SYNC(tc->COUNT32.STATUS.bit.SYNCBUSY );
|
||||
return tc->COUNT32.COUNT.reg;
|
||||
}
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
if (timer_num == MF_TIMER_RTC) {
|
||||
Rtc * const rtc = timer_config[timer_num].pRtc;
|
||||
// Clear interrupt flag
|
||||
rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0| RTC_MODE0_INTFLAG_OVF;
|
||||
|
||||
}
|
||||
else if (timer_config[timer_num].type == TimerType::tcc){
|
||||
Tcc * const tc = timer_config[timer_num].pTcc;
|
||||
// Clear interrupt flag
|
||||
tc->INTFLAG.reg = TCC_INTFLAG_OVF;
|
||||
}
|
||||
else {
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
// Clear interrupt flag
|
||||
tc->COUNT32.INTFLAG.bit.MC0 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(timer_num)
|
32
Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp
Normal file
32
Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
// adapted from I2C/master/master.c example
|
||||
// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
|
||||
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#endif // __SAMD21__
|
27
Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h
Normal file
27
Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
41
Marlin/src/HAL/SAMD21/u8g/LCD_defines.h
Normal file
41
Marlin/src/HAL/SAMD21/u8g/LCD_defines.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SAMD21 LCD-specific defines
|
||||
*/
|
||||
|
||||
// The following are optional depending on the platform.
|
||||
|
||||
// definitions of HAL specific com and device drivers.
|
||||
uint8_t u8g_com_samd21_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
|
||||
// connect U8g com generic com names to the desired driver
|
||||
#define U8G_COM_HW_SPI u8g_com_samd21_st7920_hw_spi_fn // use SAMD21 specific hardware SPI routine
|
||||
#define U8G_COM_ST7920_HW_SPI u8g_com_samd21_st7920_hw_spi_fn
|
42
Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c
Normal file
42
Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Low level pin manipulation routines - used by all the drivers.
|
||||
*
|
||||
* These are based on the SAMD51 pinMode, digitalRead & digitalWrite routines.
|
||||
*
|
||||
* Couldn't just call exact copies because the overhead killed the LCD update speed
|
||||
* With an intermediate level the softspi was running in the 10-20kHz range which
|
||||
* resulted in using about about 25% of the CPU's time.
|
||||
*/
|
||||
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#endif // __SAMD21__
|
42
Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h
Normal file
42
Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Low level pin manipulation routines - used by all the drivers.
|
||||
*
|
||||
* These are based on the SAMD51 pinMode, digitalRead & digitalWrite routines.
|
||||
*
|
||||
* Couldn't just call exact copies because the overhead killed the LCD update speed
|
||||
* With an intermediate level the softspi was running in the 10-20kHz range which
|
||||
* resulted in using about about 25% of the CPU's time.
|
||||
*/
|
||||
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number);
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number);
|
||||
void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status);
|
||||
uint8_t u8g_GetPinLevel(uint8_t pin);
|
154
Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp
Normal file
154
Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Based on u8g_com_msp430_hw_spi.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2012, olikraus@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __SAMD21__
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
#include "SPI.h"
|
||||
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SPI_QUARTER_SPEED
|
||||
#endif
|
||||
|
||||
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) {
|
||||
if (u8g->pin_list[pin_index]!= U8G_PIN_NONE)
|
||||
pinMode(u8g->pin_list[pin_index],OUTPUT);
|
||||
}
|
||||
|
||||
void u8g_SetPILevel(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
|
||||
if (u8g->pin_list[pin_index]!= U8G_PIN_NONE)
|
||||
digitalWrite(u8g->pin_list[pin_index],level);
|
||||
}
|
||||
|
||||
uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
|
||||
static SPISettings lcdSPIConfig;
|
||||
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_A0);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
|
||||
|
||||
spiBegin();
|
||||
lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0);
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1)
|
||||
u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT: // arg_val == 1 means chip selected, but ST7920 is active high, so needs inverting
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, arg_val ? HIGH : LOW);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
SPI.beginTransaction(lcdSPIConfig);
|
||||
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command
|
||||
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
}
|
||||
else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data
|
||||
SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
}
|
||||
|
||||
SPI.transfer(arg_val & 0x0f0);
|
||||
SPI.transfer(arg_val << 4);
|
||||
SPI.endTransaction();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
SPI.beginTransaction(lcdSPIConfig);
|
||||
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command
|
||||
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
}
|
||||
else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data
|
||||
SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
}
|
||||
|
||||
uint8_t *ptr = (uint8_t*)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
SPI.transfer((*ptr) & 0x0f0);
|
||||
SPI.transfer((*ptr) << 4);
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
|
||||
SPI.endTransaction();
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // __SAMD21__
|
85
Marlin/src/gcode/feature/input_shaping/M593.cpp
Normal file
85
Marlin/src/gcode/feature/input_shaping/M593.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SHAPING
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../module/stepper.h"
|
||||
|
||||
void GcodeSuite::M593_report(const bool forReplay/*=true*/) {
|
||||
report_heading_etc(forReplay, F("Input Shaping"));
|
||||
#if ENABLED(INPUT_SHAPING_X)
|
||||
SERIAL_ECHOLNPGM(" M593 X"
|
||||
" F", stepper.get_shaping_frequency(X_AXIS),
|
||||
" D", stepper.get_shaping_damping_ratio(X_AXIS)
|
||||
);
|
||||
#endif
|
||||
#if ENABLED(INPUT_SHAPING_Y)
|
||||
TERN_(INPUT_SHAPING_X, report_echo_start(forReplay));
|
||||
SERIAL_ECHOLNPGM(" M593 Y"
|
||||
" F", stepper.get_shaping_frequency(Y_AXIS),
|
||||
" D", stepper.get_shaping_damping_ratio(Y_AXIS)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* M593: Get or Set Input Shaping Parameters
|
||||
* D<factor> Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes.
|
||||
* F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes.
|
||||
* T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet)
|
||||
* X<1> Set the given parameters only for the X axis.
|
||||
* Y<1> Set the given parameters only for the Y axis.
|
||||
*/
|
||||
void GcodeSuite::M593() {
|
||||
if (!parser.seen_any()) return M593_report();
|
||||
|
||||
const bool seen_X = TERN0(INPUT_SHAPING_X, parser.seen_test('X')),
|
||||
seen_Y = TERN0(INPUT_SHAPING_Y, parser.seen_test('Y')),
|
||||
for_X = seen_X || TERN0(INPUT_SHAPING_X, (!seen_X && !seen_Y)),
|
||||
for_Y = seen_Y || TERN0(INPUT_SHAPING_Y, (!seen_X && !seen_Y));
|
||||
|
||||
if (parser.seen('D')) {
|
||||
const float zeta = parser.value_float();
|
||||
if (WITHIN(zeta, 0, 1)) {
|
||||
if (for_X) stepper.set_shaping_damping_ratio(X_AXIS, zeta);
|
||||
if (for_Y) stepper.set_shaping_damping_ratio(Y_AXIS, zeta);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHO_MSG("?Zeta (D) value out of range (0-1)");
|
||||
}
|
||||
|
||||
if (parser.seen('F')) {
|
||||
const float freq = parser.value_float();
|
||||
constexpr float min_freq = float(uint32_t(STEPPER_TIMER_RATE) / 2) / shaping_time_t(-2);
|
||||
if (freq == 0.0f || freq > min_freq) {
|
||||
if (for_X) stepper.set_shaping_frequency(X_AXIS, freq);
|
||||
if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM("?Frequency (F) must be greater than ", min_freq, " or 0 to disable");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
45
Marlin/src/module/thermistor/thermistor_1022.h
Normal file
45
Marlin/src/module/thermistor/thermistor_1022.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define REVERSE_TEMP_SENSOR_RANGE_1022 1
|
||||
|
||||
// Pt1000 with 1k0 pullup
|
||||
constexpr temp_entry_t temptable_1022[] PROGMEM = {
|
||||
PtLine( 0, 1000, 2200),
|
||||
PtLine( 25, 1000, 2200),
|
||||
PtLine( 50, 1000, 2200),
|
||||
PtLine( 75, 1000, 2200),
|
||||
PtLine(100, 1000, 2200),
|
||||
PtLine(125, 1000, 2200),
|
||||
PtLine(150, 1000, 2200),
|
||||
PtLine(175, 1000, 2200),
|
||||
PtLine(200, 1000, 2200),
|
||||
PtLine(225, 1000, 2200),
|
||||
PtLine(250, 1000, 2200),
|
||||
PtLine(275, 1000, 2200),
|
||||
PtLine(300, 1000, 2200),
|
||||
PtLine(350, 1000, 2200),
|
||||
PtLine(400, 1000, 2200),
|
||||
PtLine(450, 1000, 2200),
|
||||
PtLine(500, 1000, 2200)
|
||||
};
|
155
Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h
Normal file
155
Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Tenlog pin assignments
|
||||
*/
|
||||
|
||||
#define REQUIRE_MEGA2560
|
||||
#include "env_validate.h"
|
||||
|
||||
#if HOTENDS > 2 || E_STEPPERS > 2
|
||||
#error "Tenlog supports up to 2 hotends / E steppers."
|
||||
#endif
|
||||
|
||||
#define BOARD_INFO_NAME "Tenlog MB1 V2.3"
|
||||
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_MIN_PIN 3
|
||||
#define X_MAX_PIN 2
|
||||
#define Y_MIN_PIN 14
|
||||
//#define Y_MAX_PIN 15 // Connected to "DJ" plug on extruder heads
|
||||
#define Z_MIN_PIN 18
|
||||
#if ENABLED(BLTOUCH)
|
||||
#define SERVO0_PIN 19
|
||||
#else
|
||||
#define Z_MAX_PIN 19
|
||||
#endif
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_STEP_PIN 54
|
||||
#define X_DIR_PIN 55
|
||||
#define X_ENABLE_PIN 38
|
||||
|
||||
#define X2_STEP_PIN 36
|
||||
#define X2_DIR_PIN 34
|
||||
#define X2_ENABLE_PIN 30
|
||||
|
||||
#define Y_STEP_PIN 60
|
||||
#define Y_DIR_PIN 61
|
||||
#define Y_ENABLE_PIN 56
|
||||
|
||||
#define Z_STEP_PIN 46
|
||||
#define Z_DIR_PIN 48
|
||||
#define Z_ENABLE_PIN 62
|
||||
|
||||
#define Z2_STEP_PIN 65
|
||||
#define Z2_DIR_PIN 66
|
||||
#define Z2_ENABLE_PIN 64
|
||||
|
||||
#define E0_STEP_PIN 57
|
||||
#define E0_DIR_PIN 58
|
||||
#define E0_ENABLE_PIN 59
|
||||
|
||||
#define E1_STEP_PIN 26
|
||||
#define E1_DIR_PIN 28
|
||||
#define E1_ENABLE_PIN 24
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN 15 // Analog Input
|
||||
#define TEMP_1_PIN 13 // Analog Input
|
||||
#define TEMP_BED_PIN 14 // Analog Input
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN 11
|
||||
#define HEATER_1_PIN 10
|
||||
#define HEATER_BED_PIN 8
|
||||
|
||||
#define FAN_PIN 9
|
||||
#define FAN2_PIN 5 // Normally this would be a servo pin
|
||||
|
||||
//#define NUM_RUNOUT_SENSORS 0
|
||||
#define FIL_RUNOUT_PIN 15
|
||||
//#define FIL_RUNOUT2_PIN 21
|
||||
|
||||
//
|
||||
// PSU and Powerloss Recovery
|
||||
//
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
#define PS_ON_PIN 40 // The M80/M81 PSU pin for boards v2.1-2.3
|
||||
#endif
|
||||
|
||||
//
|
||||
// Misc. Functions
|
||||
//
|
||||
//#define CASE_LIGHT_PIN 5
|
||||
//#ifndef LED_PIN
|
||||
// #define LED_PIN 13
|
||||
//#endif
|
||||
|
||||
#if HAS_CUTTER
|
||||
//#define SPINDLE_LASER_PWM_PIN -1 // Hardware PWM
|
||||
//#define SPINDLE_LASER_ENA_PIN 4 // Pullup!
|
||||
#endif
|
||||
|
||||
// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector
|
||||
//#define FILWIDTH_PIN 5 // Analog Input
|
||||
|
||||
#define SDSS 53
|
||||
#define SD_DETECT_PIN 49
|
||||
|
||||
//
|
||||
// LCD / Controller
|
||||
//
|
||||
|
||||
//#if IS_RRD_SC
|
||||
|
||||
//#ifndef BEEPER_PIN
|
||||
// #define BEEPER_PIN -1
|
||||
//#endif
|
||||
|
||||
#define LCD_PINS_RS -1
|
||||
#define LCD_PINS_ENABLE -1
|
||||
#define LCD_PINS_D4 -1
|
||||
#define LCD_PINS_D5 -1
|
||||
#define LCD_PINS_D6 -1
|
||||
#define LCD_PINS_D7 -1
|
||||
|
||||
//#define BTN_EN1 31
|
||||
//#define BTN_EN2 33
|
||||
//#define BTN_ENC 35
|
||||
|
||||
//#ifndef KILL_PIN
|
||||
// #define KILL_PIN 41
|
||||
//#endif
|
||||
|
||||
//#endif // IS_RRD_SC
|
556
Marlin/src/pins/samd/pins_MINITRONICS20.h
Normal file
556
Marlin/src/pins/samd/pins_MINITRONICS20.h
Normal file
@@ -0,0 +1,556 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* ReprapWorld's Minitronics v2.0
|
||||
*/
|
||||
|
||||
#if NOT_TARGET(__SAMD21__)
|
||||
#error "Oops! Select 'Minitronics v2.0' in 'Tools > Board.'"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_INFO_NAME
|
||||
#define BOARD_INFO_NAME "Minitronics V2.0"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1
|
||||
*/
|
||||
|
||||
/**
|
||||
* EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on.
|
||||
*/
|
||||
//#define FLASH_EEPROM_EMULATION
|
||||
//#define I2C_EEPROM // EEPROM on I2C-0
|
||||
#define MARLIN_EEPROM_SIZE 500 // 4000 bytes
|
||||
|
||||
//This its another option to emulate an EEPROM, but its more efficient to dont loose the data the first One.
|
||||
//#define SDCARD_EEPROM_EMULATION
|
||||
|
||||
//
|
||||
// BLTouch
|
||||
//
|
||||
#define SERVO0_PIN 33 // BLTouch PWM
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_STOP_PIN 54
|
||||
#define Y_STOP_PIN 55
|
||||
#define Z_STOP_PIN 4
|
||||
|
||||
/**
|
||||
* NOTE: Useful if extra TMC2209 are to be used as independent axes.
|
||||
* We need to configure the new digital PIN, for this we could configure on the board the extra pin of this stepper, for example as a MIN_PIN/MAX_PIN. This pin is the D14.
|
||||
*/
|
||||
//#define Z2_STOP_PIN 14
|
||||
//#define X2_STOP_PIN 14
|
||||
//#define Y2_STOP_PIN 14
|
||||
|
||||
//
|
||||
// Z Probe (when not Z_MIN_PIN)
|
||||
//
|
||||
#ifndef Z_MIN_PROBE_PIN
|
||||
#define Z_MIN_PROBE_PIN 12
|
||||
#endif
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_STEP_PIN 1
|
||||
#define X_DIR_PIN 3
|
||||
#define X_ENABLE_PIN 0
|
||||
|
||||
#define Y_STEP_PIN 29
|
||||
#define Y_DIR_PIN 28
|
||||
#define Y_ENABLE_PIN 0
|
||||
|
||||
#define Z_STEP_PIN 16
|
||||
#define Z_DIR_PIN 17
|
||||
#define Z_ENABLE_PIN 0
|
||||
|
||||
#define E0_STEP_PIN 14
|
||||
#define E0_DIR_PIN 15
|
||||
#define E0_ENABLE_PIN 0
|
||||
|
||||
#define E1_STEP_PIN 20
|
||||
#define E1_DIR_PIN 13
|
||||
#define E1_ENABLE_PIN 21
|
||||
|
||||
// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O.
|
||||
// For example, a switch to detect any kind of behavior, Power supply pin .... etc.
|
||||
#ifndef FIL_RUNOUT_PIN
|
||||
#define FIL_RUNOUT_PIN 44
|
||||
#endif
|
||||
|
||||
// This board have the option to use an extra TMC2209 stepper, one of the use could be as a second extruder.
|
||||
#if EXTRUDERS < 2
|
||||
// TODO: Corregir aquí que cuando tenemos dos extrusores o lo que sea, utiliza los endstop que le sobran, osea los max, no hay Z2_endstop
|
||||
#if NUM_Z_STEPPERS > 1
|
||||
#define Z2_STOP_PIN 14
|
||||
#endif
|
||||
#else
|
||||
// If we want to configure the extra stepper as a Extruder, we should have undef all of the extra motors.
|
||||
#undef X2_DRIVER_TYPE
|
||||
#undef Y2_DRIVER_TYPE
|
||||
#undef Z2_DRIVER_TYPE
|
||||
#undef Z3_DRIVER_TYPE
|
||||
#undef Z4_DRIVER_TYPE
|
||||
|
||||
// Si tenemos más de un extrusor lo que hacemos es definir el nuevo extrusor así como sus pines
|
||||
// Acordarse de definir el #define TEMP_SENSOR_1, ya que este contiene el tipo de sonda del extrusor E1
|
||||
|
||||
#define FIL_RUNOUT2_PIN 14
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Extruder / Bed
|
||||
//
|
||||
|
||||
// Temperature Sensors
|
||||
#define TEMP_0_PIN 4 // T1
|
||||
|
||||
// You could use one of the ADC for a temp chamber if you don't use the second extruder, for example.
|
||||
#if TEMP_SENSOR_CHAMBER > 0
|
||||
#define TEMP_CHAMBER_PIN 3
|
||||
#else
|
||||
#define TEMP_1_PIN 2 // T3
|
||||
#endif
|
||||
|
||||
#define TEMP_BED_PIN 3 // T2
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN 10
|
||||
#define HEATER_1_PIN 11
|
||||
#define HEATER_BED_PIN 6
|
||||
#define SPINDLE_LASER_PWM_PIN 6
|
||||
|
||||
// The board has 4 PWM fans, use and configure as desired
|
||||
#define FAN_PIN 24
|
||||
|
||||
//
|
||||
// LCD / Controller
|
||||
//
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
#define EXP3_01_PIN EXP1_01_PIN
|
||||
#define EXP3_02_PIN EXP1_02_PIN
|
||||
#define EXP3_03_PIN EXP1_03_PIN
|
||||
#define EXP3_04_PIN EXP1_04_PIN
|
||||
#define EXP3_05_PIN EXP1_05_PIN
|
||||
#define EXP3_06_PIN EXP1_06_PIN
|
||||
#define EXP3_07_PIN EXP1_07_PIN
|
||||
#define EXP3_08_PIN EXP1_08_PIN
|
||||
#endif
|
||||
|
||||
/************************************/
|
||||
/***** Configurations Section ******/
|
||||
/************************************/
|
||||
|
||||
/**
|
||||
* This sections starts with the pins_RAMPS_144.h as example, after if you need any new
|
||||
* display, you could use normal duponts and connect it with with the scheme showed before.
|
||||
* Tested:
|
||||
* - Ender 3 Old display (Character LCD)
|
||||
* - Ender 3 New Serial DWING Display
|
||||
* - Reprap Display
|
||||
* - Ender 5 New Serial Display
|
||||
* - Any Reprap character display like
|
||||
*/
|
||||
|
||||
#if HAS_WIRED_LCD
|
||||
|
||||
//
|
||||
// LCD Display output pins
|
||||
//
|
||||
|
||||
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
|
||||
|
||||
#define LCD_PINS_RS 18 // CS chip select /SS chip slave select
|
||||
#define LCD_PINS_ENABLE MOSI // SID (MOSI)
|
||||
#define LCD_PINS_D4 SCK // SCK (CLK) clock
|
||||
|
||||
#define BTN_ENC 23
|
||||
#define BTN_EN1 27
|
||||
#define BTN_EN2 33
|
||||
|
||||
#elif BOTH(IS_NEWPANEL, PANEL_ONE)
|
||||
|
||||
// TO TEST
|
||||
//#define LCD_PINS_RS EXP1_02_PIN
|
||||
//#define LCD_PINS_ENABLE EXP2_05_PIN
|
||||
//#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57
|
||||
//#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58
|
||||
//#define LCD_PINS_D6 EXP2_07_PIN
|
||||
//#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56
|
||||
|
||||
#else
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
|
||||
// TO TEST
|
||||
//#define LCD_PINS_RS EXP3_04_PIN
|
||||
//#define LCD_PINS_ENABLE EXP3_03_PIN
|
||||
//#define LCD_PINS_D4 EXP3_05_PIN
|
||||
|
||||
#if !IS_NEWPANEL
|
||||
// TO TEST
|
||||
//#define BEEPER_PIN EXP3_05_PIN
|
||||
#endif
|
||||
|
||||
#elif ENABLED(ZONESTAR_LCD)
|
||||
|
||||
// TO TEST
|
||||
//#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56
|
||||
//#define LCD_PINS_ENABLE EXP2_07_PIN
|
||||
//#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55
|
||||
//#define LCD_PINS_D5 EXP1_02_PIN
|
||||
//#define LCD_PINS_D6 EXP2_05_PIN
|
||||
//#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57
|
||||
|
||||
#else
|
||||
|
||||
#if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
|
||||
// TO TEST
|
||||
//#define LCD_PINS_DC 25 // Set as output on init
|
||||
//#define LCD_PINS_RS 27 // Pull low for 1s to init
|
||||
// DOGM SPI LCD Support
|
||||
//#define DOGLCD_CS 16
|
||||
//#define DOGLCD_MOSI 17
|
||||
//#define DOGLCD_SCK 23
|
||||
//#define DOGLCD_A0 LCD_PINS_DC
|
||||
|
||||
#else
|
||||
// Definitions for any standard Display
|
||||
#define LCD_PINS_RS EXP1_04_PIN
|
||||
#define LCD_PINS_ENABLE EXP1_03_PIN
|
||||
#define LCD_PINS_D4 EXP1_05_PIN
|
||||
#define LCD_PINS_D5 EXP1_06_PIN
|
||||
#define LCD_PINS_D6 EXP1_07_PIN
|
||||
#endif
|
||||
|
||||
#define LCD_PINS_D7 EXP1_08_PIN
|
||||
|
||||
#if !IS_NEWPANEL
|
||||
#define BEEPER_PIN EXP1_01_PIN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !IS_NEWPANEL
|
||||
// Buttons attached to a shift register
|
||||
// Not wired yet
|
||||
//#define SHIFT_CLK_PIN EXP1_07_PIN
|
||||
//#define SHIFT_LD_PIN EXP2_05_PIN
|
||||
//#define SHIFT_OUT_PIN EXP1_02_PIN
|
||||
//#define SHIFT_EN_PIN 17
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCD Display input pins
|
||||
//
|
||||
#if IS_NEWPANEL
|
||||
|
||||
#if IS_RRD_SC
|
||||
|
||||
//#define BEEPER_PIN EXP1_01_PIN
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
// TO TEST
|
||||
#define BTN_EN1 EXP1_03_PIN
|
||||
#define BTN_EN2 EXP1_05_PIN
|
||||
#else
|
||||
// Definitions fpr any standard Display
|
||||
#define BTN_EN1 EXP2_05_PIN
|
||||
#define BTN_EN2 EXP2_03_PIN
|
||||
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
|
||||
#define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BTN_ENC EXP1_02_PIN
|
||||
#ifndef SD_DETECT_PIN
|
||||
#define SD_DETECT_PIN EXP2_07_PIN
|
||||
#endif
|
||||
//#define KILL_PIN EXP2_10_PIN
|
||||
|
||||
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
|
||||
//#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST
|
||||
#endif
|
||||
|
||||
#elif ENABLED(LCD_I2C_PANELOLU2)
|
||||
|
||||
// TO TEST
|
||||
//#define BTN_EN1 47
|
||||
//#define BTN_EN2 EXP2_03_PIN
|
||||
//#define BTN_ENC 32
|
||||
//#define LCD_SDSS SDSS
|
||||
//#define KILL_PIN EXP1_01_PIN
|
||||
|
||||
#elif ENABLED(LCD_I2C_VIKI)
|
||||
|
||||
// TO TEST
|
||||
//#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
|
||||
//#define BTN_EN2 EXP2_05_PIN
|
||||
//#define BTN_ENC -1
|
||||
|
||||
//#define LCD_SDSS SDSS
|
||||
//#define SD_DETECT_PIN EXP2_10_PIN
|
||||
|
||||
#elif EITHER(VIKI2, miniVIKI)
|
||||
|
||||
// TO TEST
|
||||
//#define DOGLCD_CS 45
|
||||
//#define DOGLCD_A0 EXP2_07_PIN
|
||||
//#define LCD_SCREEN_ROT_180
|
||||
|
||||
//#define BEEPER_PIN 33
|
||||
//#define STAT_LED_RED_PIN 32
|
||||
//#define STAT_LED_BLUE_PIN EXP1_03_PIN
|
||||
|
||||
//#define BTN_EN1 22
|
||||
//#define BTN_EN2 7
|
||||
//#define BTN_ENC EXP1_08_PIN
|
||||
|
||||
//#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board
|
||||
//#define KILL_PIN 31
|
||||
|
||||
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
|
||||
|
||||
// TO TEST
|
||||
//#define DOGLCD_CS 29
|
||||
//#define DOGLCD_A0 27
|
||||
|
||||
//#define BEEPER_PIN 23
|
||||
//#define LCD_BACKLIGHT_PIN 33
|
||||
|
||||
//#define BTN_EN1 EXP1_03_PIN
|
||||
//#define BTN_EN2 EXP1_06_PIN
|
||||
//#define BTN_ENC 31
|
||||
|
||||
//#define LCD_SDSS SDSS
|
||||
//#define SD_DETECT_PIN EXP2_10_PIN
|
||||
//#define KILL_PIN EXP1_01_PIN
|
||||
|
||||
#elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864)
|
||||
|
||||
// TO TEST
|
||||
//#define BEEPER_PIN EXP1_06_PIN
|
||||
//#define BTN_ENC EXP1_03_PIN
|
||||
//#define SD_DETECT_PIN EXP2_10_PIN
|
||||
|
||||
//#ifndef KILL_PIN
|
||||
// #define KILL_PIN EXP1_01_PIN
|
||||
//#endif
|
||||
|
||||
#if ENABLED(MKS_MINI_12864)
|
||||
|
||||
// TO TEST
|
||||
//#define DOGLCD_A0 27
|
||||
//#define DOGLCD_CS 25
|
||||
|
||||
// GLCD features
|
||||
// Uncomment screen orientation
|
||||
//#define LCD_SCREEN_ROT_90
|
||||
//#define LCD_SCREEN_ROT_180
|
||||
//#define LCD_SCREEN_ROT_270
|
||||
|
||||
// not connected to a pin
|
||||
//#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57)
|
||||
|
||||
//#define BTN_EN1 31
|
||||
//#define BTN_EN2 33
|
||||
|
||||
#elif ENABLED(FYSETC_MINI_12864)
|
||||
|
||||
// From https://wiki.fysetc.com/Mini12864_Panel/
|
||||
|
||||
// TO TEST
|
||||
//#define DOGLCD_A0 16
|
||||
//#define DOGLCD_CS 17
|
||||
|
||||
//#define BTN_EN1 33
|
||||
//#define BTN_EN2 31
|
||||
|
||||
//#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems
|
||||
// results in LCD soft SPI mode 3, SD soft SPI mode 0
|
||||
|
||||
//#define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally.
|
||||
|
||||
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
|
||||
#ifndef RGB_LED_R_PIN
|
||||
// TO TEST
|
||||
//#define RGB_LED_R_PIN 25
|
||||
#endif
|
||||
#ifndef RGB_LED_G_PIN
|
||||
// TO TEST
|
||||
//#define RGB_LED_G_PIN 27
|
||||
#endif
|
||||
#ifndef RGB_LED_B_PIN
|
||||
// TO TEST
|
||||
//#define RGB_LED_B_PIN 29
|
||||
#endif
|
||||
#elif ENABLED(FYSETC_MINI_12864_2_1)
|
||||
// TO TEST
|
||||
//#define NEOPIXEL_PIN 25
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#elif ENABLED(MINIPANEL)
|
||||
|
||||
// TO TEST
|
||||
//#define BEEPER_PIN EXP2_05_PIN
|
||||
// not connected to a pin
|
||||
//#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57)
|
||||
|
||||
//#define DOGLCD_A0 EXP2_07_PIN
|
||||
//#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58
|
||||
|
||||
// GLCD features
|
||||
// Uncomment screen orientation
|
||||
//#define LCD_SCREEN_ROT_90
|
||||
//#define LCD_SCREEN_ROT_180
|
||||
//#define LCD_SCREEN_ROT_270
|
||||
|
||||
//#define BTN_EN1 EXP1_02_PIN
|
||||
//#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55
|
||||
//#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72
|
||||
|
||||
//#define SD_DETECT_PIN EXP2_10_PIN
|
||||
//#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56
|
||||
|
||||
#elif ENABLED(ZONESTAR_LCD)
|
||||
|
||||
// TO TEST
|
||||
//#define ADC_KEYPAD_PIN 12
|
||||
|
||||
#elif ENABLED(AZSMZ_12864)
|
||||
|
||||
// TO TEST
|
||||
|
||||
#else
|
||||
|
||||
// Beeper on AUX-4
|
||||
//#define BEEPER_PIN 33
|
||||
|
||||
// Buttons are directly attached to AUX-2
|
||||
#if IS_RRW_KEYPAD
|
||||
// TO TEST
|
||||
//#define SHIFT_OUT_PIN EXP1_02_PIN
|
||||
//#define SHIFT_CLK_PIN EXP2_07_PIN
|
||||
//#define SHIFT_LD_PIN EXP2_05_PIN
|
||||
//#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56
|
||||
//#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72
|
||||
//#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55
|
||||
#elif ENABLED(PANEL_ONE)
|
||||
// TO TEST
|
||||
//#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72)
|
||||
//#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55)
|
||||
//#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7
|
||||
#else
|
||||
// TO TEST
|
||||
//#define BTN_EN1 EXP1_06_PIN
|
||||
//#define BTN_EN2 EXP1_03_PIN
|
||||
//#define BTN_ENC 31
|
||||
#endif
|
||||
|
||||
#if ENABLED(G3D_PANEL)
|
||||
// TO TEST
|
||||
//#define SD_DETECT_PIN EXP2_10_PIN
|
||||
//#define KILL_PIN EXP1_01_PIN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // IS_NEWPANEL
|
||||
|
||||
#endif // HAS_WIRED_LCD
|
||||
|
||||
//
|
||||
// SD Support
|
||||
//
|
||||
|
||||
#define SDSS 2
|
||||
#undef SD_DETECT_PIN
|
||||
#define SD_DETECT_PIN 22
|
||||
|
||||
#if HAS_TMC_UART
|
||||
|
||||
/**
|
||||
* Address for the UART Configuration of the TMC2209. Override in Configuration files.
|
||||
* To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers.
|
||||
*/
|
||||
#ifndef X_SLAVE_ADDRESS
|
||||
#define X_SLAVE_ADDRESS 0b00
|
||||
#endif
|
||||
#ifndef Y_SLAVE_ADDRESS
|
||||
#define Y_SLAVE_ADDRESS 0b01
|
||||
#endif
|
||||
#ifndef Z_SLAVE_ADDRESS
|
||||
#define Z_SLAVE_ADDRESS 0b10
|
||||
#endif
|
||||
#ifndef E0_SLAVE_ADDRESS
|
||||
#define E0_SLAVE_ADDRESS 0b11
|
||||
#endif
|
||||
#ifndef E1_SLAVE_ADDRESS
|
||||
#define E1_SLAVE_ADDRESS 0b00
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TMC2208/TMC2209 stepper drivers
|
||||
* It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations.
|
||||
* Steppers 1,2,3,4 (X,Y,Z,E0) are on the Serial1, Sercom (RX = 0, TX = 1), extra stepper 5 (E1 or any axis you want) is on Serial2, Sercom (RX = 17, TX = 16)
|
||||
*/
|
||||
|
||||
//#define X_HARDWARE_SERIAL Serial1
|
||||
//#define Y_HARDWARE_SERIAL Serial1
|
||||
//#define Z_HARDWARE_SERIAL Serial1
|
||||
//#define E0_HARDWARE_SERIAL Serial1
|
||||
//#define E1_HARDWARE_SERIAL Serial2
|
||||
|
||||
#define TMC_BAUD_RATE 250000
|
||||
|
||||
//
|
||||
// Software serial
|
||||
//
|
||||
#define X_SERIAL_TX_PIN 0
|
||||
#define X_SERIAL_RX_PIN 1
|
||||
|
||||
#define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN
|
||||
#define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN
|
||||
|
||||
#define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN
|
||||
#define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN
|
||||
|
||||
#define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN
|
||||
#define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN
|
||||
|
||||
#define E1_SERIAL_TX_PIN 17
|
||||
#define E1_SERIAL_RX_PIN 16
|
||||
|
||||
#endif
|
226
Marlin/src/pins/stm32f1/pins_CREALITY_V521.h
Normal file
226
Marlin/src/pins/stm32f1/pins_CREALITY_V521.h
Normal file
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Creality 5.2.1 (STM32F103RE) board pin assignments
|
||||
*/
|
||||
|
||||
#include "env_validate.h"
|
||||
|
||||
#if HOTENDS > 2 || E_STEPPERS > 2
|
||||
#error "Creality v5.2.1 supports up to 2 hotends / E steppers."
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_INFO_NAME
|
||||
#define BOARD_INFO_NAME "Creality V521"
|
||||
#endif
|
||||
#ifndef DEFAULT_MACHINE_NAME
|
||||
#define DEFAULT_MACHINE_NAME "Creality V5.2.1"
|
||||
#endif
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
#if NO_EEPROM_SELECTED
|
||||
// FLASH
|
||||
//#define FLASH_EEPROM_EMULATION
|
||||
|
||||
// I2C
|
||||
#define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 used only for display settings
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
#define IIC_EEPROM_SDA PC2
|
||||
#define IIC_EEPROM_SCL PC3
|
||||
#define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16)
|
||||
#else
|
||||
#define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX
|
||||
#define MARLIN_EEPROM_SIZE 0x800 // 2K
|
||||
#endif
|
||||
|
||||
#undef NO_EEPROM_SELECTED
|
||||
#endif
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PD13 // BLTouch OUT
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_STOP_PIN PD10 // X
|
||||
#define X2_STOP_PIN PE15 // X2
|
||||
#define Y_STOP_PIN PE0 // Y
|
||||
#define Z_STOP_PIN PE1 // Z
|
||||
#define Z2_STOP_PIN PE2 // Z2
|
||||
|
||||
#ifndef Z_MIN_PROBE_PIN
|
||||
#define Z_MIN_PROBE_PIN PD12 // BLTouch IN
|
||||
#endif
|
||||
|
||||
//
|
||||
// Filament Runout Sensor
|
||||
//
|
||||
#define FIL_RUNOUT_PIN PE5 // "Pulled-high"
|
||||
#define FIL_RUNOUT2_PIN PE6 // "Pulled-high"
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_ENABLE_PIN PC7
|
||||
#define X_STEP_PIN PD15
|
||||
#define X_DIR_PIN PD14
|
||||
|
||||
#define Y_ENABLE_PIN PB9
|
||||
#define Y_STEP_PIN PB7
|
||||
#define Y_DIR_PIN PB6
|
||||
|
||||
#define Z_ENABLE_PIN PB5
|
||||
#define Z_STEP_PIN PB3
|
||||
#define Z_DIR_PIN PD7
|
||||
|
||||
#define E0_ENABLE_PIN PD4
|
||||
#define E0_STEP_PIN PD1
|
||||
#define E0_DIR_PIN PD0
|
||||
|
||||
#define E1_ENABLE_PIN PE7
|
||||
#define E1_STEP_PIN PB1
|
||||
#define E1_DIR_PIN PB0
|
||||
|
||||
#define X2_ENABLE_PIN PE11
|
||||
#define X2_STEP_PIN PE9
|
||||
#define X2_DIR_PIN PE8
|
||||
|
||||
#define Z2_ENABLE_PIN PC5
|
||||
#define Z2_STEP_PIN PA7
|
||||
#define Z2_DIR_PIN PA6
|
||||
|
||||
//
|
||||
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
|
||||
//
|
||||
#define DISABLE_JTAG
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN PA4 // TH0
|
||||
#define TEMP_1_PIN PA5 // TH1
|
||||
#define TEMP_BED_PIN PA3 // TB1
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN PA1 // HEATER0
|
||||
#define HEATER_1_PIN PA0 // HEATER1
|
||||
#define HEATER_BED_PIN PA2 // HOT BED
|
||||
|
||||
#define FAN_PIN PB14 // FAN
|
||||
#define FAN1_PIN PB12 // FAN
|
||||
#define FAN_SOFT_PWM
|
||||
|
||||
//
|
||||
// SD Card
|
||||
//
|
||||
#define SD_DETECT_PIN PA8
|
||||
#define SDCARD_CONNECTION ONBOARD
|
||||
#define ONBOARD_SPI_DEVICE 1
|
||||
#define ONBOARD_SD_CS_PIN PC11 // SDSS
|
||||
#define SDIO_SUPPORT
|
||||
#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer
|
||||
|
||||
#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||
|
||||
/**
|
||||
* RET6 12864 LCD
|
||||
* ------
|
||||
* PC6 | 1 2 | PB2
|
||||
* PB10 | 3 4 | PE8
|
||||
* PB14 5 6 | PB13
|
||||
* PB12 | 7 8 | PB15
|
||||
* GND | 9 10 | 5V
|
||||
* ------
|
||||
*/
|
||||
#define EXP3_01_PIN PC6
|
||||
#define EXP3_02_PIN PB2
|
||||
#define EXP3_03_PIN PB10
|
||||
#define EXP3_04_PIN PE8
|
||||
#define EXP3_05_PIN PB14
|
||||
#define EXP3_06_PIN PB13
|
||||
#define EXP3_07_PIN PB12
|
||||
#define EXP3_08_PIN PB15
|
||||
|
||||
#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD)
|
||||
|
||||
/**
|
||||
* VET6 12864 LCD
|
||||
* ------
|
||||
* ? | 1 2 | PC5
|
||||
* PB10 | 3 4 | ?
|
||||
* PA6 5 6 | PA5
|
||||
* PA4 | 7 8 | PA7
|
||||
* GND | 9 10 | 5V
|
||||
* ------
|
||||
*/
|
||||
#define EXP3_01_PIN -1
|
||||
#define EXP3_02_PIN PC5
|
||||
#define EXP3_03_PIN PB10
|
||||
#define EXP3_04_PIN -1
|
||||
#define EXP3_05_PIN PA6
|
||||
#define EXP3_06_PIN PA5
|
||||
#define EXP3_07_PIN PA4
|
||||
#define EXP3_08_PIN PA7
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
#if NONE(RET6_12864_LCD, VET6_12864_LCD)
|
||||
#error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller."
|
||||
#endif
|
||||
|
||||
#define LCD_PINS_RS EXP3_07_PIN
|
||||
#define LCD_PINS_ENABLE EXP3_08_PIN
|
||||
#define LCD_PINS_D4 EXP3_06_PIN
|
||||
|
||||
#define BTN_ENC EXP3_02_PIN
|
||||
#define BTN_EN1 EXP3_03_PIN
|
||||
#define BTN_EN2 EXP3_05_PIN
|
||||
|
||||
#define BEEPER_PIN EXP3_01_PIN
|
||||
|
||||
#elif ANY(DWIN_VET6_CREALITY_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||
|
||||
// RET6 / VET6 DWIN ENCODER LCD
|
||||
#define BTN_ENC EXP3_05_PIN
|
||||
#define BTN_EN1 EXP3_08_PIN
|
||||
#define BTN_EN2 EXP3_07_PIN
|
||||
|
||||
//#define LCD_LED_PIN EXP3_02_PIN
|
||||
#ifndef BEEPER_PIN
|
||||
#define BEEPER_PIN EXP3_06_PIN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// DGUS LCDs
|
||||
#if HAS_DGUS_LCD
|
||||
#define LCD_SERIAL_PORT 3
|
||||
#endif
|
350
Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h
Normal file
350
Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h
Normal file
@@ -0,0 +1,350 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4
|
||||
|
||||
#include "env_validate.h"
|
||||
|
||||
#if HOTENDS > 1 || E_STEPPERS > 1
|
||||
#error "BTT SKR Mini E3 V3.0.1 supports up to 1 hotend / E stepper."
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_INFO_NAME
|
||||
#define BOARD_INFO_NAME "BTT SKR Mini E3 V3.0.1"
|
||||
#endif
|
||||
|
||||
#define USES_DIAG_JUMPERS
|
||||
|
||||
// Ignore temp readings during development.
|
||||
//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000
|
||||
|
||||
#ifndef NEOPIXEL_LED
|
||||
#define LED_PIN PA14
|
||||
#endif
|
||||
|
||||
// Onboard I2C EEPROM
|
||||
#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM)
|
||||
#undef NO_EEPROM_SELECTED
|
||||
#define I2C_EEPROM
|
||||
#define SOFT_I2C_EEPROM // Force the use of Software I2C
|
||||
#define I2C_SCL_PIN PB8
|
||||
#define I2C_SDA_PIN PB9
|
||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4K
|
||||
#endif
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PA0 // SERVOS
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_STOP_PIN PB5 // X-STOP
|
||||
#define Y_STOP_PIN PB6 // Y-STOP
|
||||
#define Z_STOP_PIN PB7 // Z-STOP
|
||||
|
||||
//
|
||||
// Z Probe must be this pin
|
||||
//
|
||||
#define Z_MIN_PROBE_PIN PA1 // PROBE
|
||||
|
||||
//
|
||||
// Filament Runout Sensor
|
||||
//
|
||||
#ifndef FIL_RUNOUT_PIN
|
||||
#define FIL_RUNOUT_PIN PC15 // E0-STOP
|
||||
#endif
|
||||
|
||||
//
|
||||
// Power-loss Detection
|
||||
//
|
||||
#ifndef POWER_LOSS_PIN
|
||||
#define POWER_LOSS_PIN PC13 // Power Loss Detection: PWR-DET
|
||||
#endif
|
||||
|
||||
#ifndef NEOPIXEL_PIN
|
||||
#define NEOPIXEL_PIN PA14 // LED driving pin
|
||||
#endif
|
||||
|
||||
#ifndef PS_ON_PIN
|
||||
#define PS_ON_PIN PC14 // Power Supply Control
|
||||
#endif
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_ENABLE_PIN PC10
|
||||
#define X_STEP_PIN PC11
|
||||
#define X_DIR_PIN PC12
|
||||
|
||||
#define Y_ENABLE_PIN PB13
|
||||
#define Y_STEP_PIN PB12
|
||||
#define Y_DIR_PIN PB10
|
||||
|
||||
#define Z_ENABLE_PIN PB2
|
||||
#define Z_STEP_PIN PB1
|
||||
#define Z_DIR_PIN PB0
|
||||
|
||||
#define E0_ENABLE_PIN PC3
|
||||
#define E0_STEP_PIN PC2
|
||||
#define E0_DIR_PIN PC1
|
||||
|
||||
#if HAS_TMC_UART
|
||||
/**
|
||||
* TMC220x stepper drivers
|
||||
* Hardware serial communication ports
|
||||
*/
|
||||
#define X_HARDWARE_SERIAL MSerial6
|
||||
#define Y_HARDWARE_SERIAL MSerial6
|
||||
#define Z_HARDWARE_SERIAL MSerial6
|
||||
#define E0_HARDWARE_SERIAL MSerial6
|
||||
|
||||
// Default TMC slave addresses
|
||||
#ifndef X_SLAVE_ADDRESS
|
||||
#define X_SLAVE_ADDRESS 0
|
||||
#endif
|
||||
#ifndef Y_SLAVE_ADDRESS
|
||||
#define Y_SLAVE_ADDRESS 2
|
||||
#endif
|
||||
#ifndef Z_SLAVE_ADDRESS
|
||||
#define Z_SLAVE_ADDRESS 1
|
||||
#endif
|
||||
#ifndef E0_SLAVE_ADDRESS
|
||||
#define E0_SLAVE_ADDRESS 3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN PC5 // Analog Input "TH0"
|
||||
#define TEMP_BED_PIN PC4 // Analog Input "TB0"
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN PA15 // "HE"
|
||||
#define HEATER_BED_PIN PB3 // "HB"
|
||||
#define FAN_PIN PC9 // "FAN0"
|
||||
#define FAN1_PIN PA8 // "FAN1"
|
||||
#define FAN2_PIN PC8 // "FAN2"
|
||||
|
||||
/**
|
||||
* SKR Mini E3 V3.0.1
|
||||
* ------
|
||||
* (BEEPER) PB15 | 1 2 | PB14 (BTN_ENC)
|
||||
* (BTN_EN1) PA9 | 3 4 | RESET
|
||||
* (BTN_EN2) PA10 5 6 | PB4 (LCD_D4)
|
||||
* (LCD_RS) PD2 | 7 8 | PC0 (LCD_EN)
|
||||
* GND | 9 10 | 5V
|
||||
* ------
|
||||
* EXP1
|
||||
*/
|
||||
#define EXP1_01_PIN PB15
|
||||
#define EXP1_02_PIN PB14
|
||||
#define EXP1_03_PIN PA9
|
||||
#define EXP1_04_PIN -1 // RESET
|
||||
#define EXP1_05_PIN PA10
|
||||
#define EXP1_06_PIN PB4
|
||||
#define EXP1_07_PIN PD2
|
||||
#define EXP1_08_PIN PC0
|
||||
|
||||
#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI
|
||||
/**
|
||||
* ------ ------ ------
|
||||
* (ENT) | 1 2 | (BEEP) |10 9 | |10 9 |
|
||||
* (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX
|
||||
* (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP
|
||||
* (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A
|
||||
* GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC
|
||||
* ------ ------ ------
|
||||
* EXP1 DWIN DWIN (plug)
|
||||
*
|
||||
* All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on.
|
||||
*/
|
||||
|
||||
#error "DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. Comment out this line to continue."
|
||||
|
||||
#define BEEPER_PIN EXP1_02_PIN
|
||||
#define BTN_EN1 EXP1_08_PIN
|
||||
#define BTN_EN2 EXP1_07_PIN
|
||||
#define BTN_ENC EXP1_01_PIN
|
||||
|
||||
#elif HAS_WIRED_LCD
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
|
||||
#define BEEPER_PIN EXP1_01_PIN
|
||||
#define BTN_ENC EXP1_02_PIN
|
||||
|
||||
#define BTN_EN1 EXP1_03_PIN
|
||||
#define BTN_EN2 EXP1_05_PIN
|
||||
|
||||
#define LCD_PINS_RS EXP1_07_PIN
|
||||
#define LCD_PINS_ENABLE EXP1_08_PIN
|
||||
#define LCD_PINS_D4 EXP1_06_PIN
|
||||
|
||||
#elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD!
|
||||
|
||||
#ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING
|
||||
#error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)"
|
||||
#endif
|
||||
|
||||
#define LCD_PINS_RS EXP1_06_PIN
|
||||
#define LCD_PINS_ENABLE EXP1_02_PIN
|
||||
#define LCD_PINS_D4 EXP1_07_PIN
|
||||
#define LCD_PINS_D5 EXP1_05_PIN
|
||||
#define LCD_PINS_D6 EXP1_03_PIN
|
||||
#define LCD_PINS_D7 EXP1_01_PIN
|
||||
#define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD!
|
||||
|
||||
#elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY)
|
||||
|
||||
#define BTN_ENC EXP1_02_PIN
|
||||
#define BTN_EN1 EXP1_03_PIN
|
||||
#define BTN_EN2 EXP1_05_PIN
|
||||
|
||||
#define DOGLCD_CS EXP1_07_PIN
|
||||
#define DOGLCD_A0 EXP1_06_PIN
|
||||
#define DOGLCD_SCK EXP1_01_PIN
|
||||
#define DOGLCD_MOSI EXP1_08_PIN
|
||||
|
||||
#define FORCE_SOFT_SPI
|
||||
#define LCD_BACKLIGHT_PIN -1
|
||||
|
||||
#elif IS_TFTGLCD_PANEL
|
||||
|
||||
#if ENABLED(TFTGLCD_PANEL_SPI)
|
||||
|
||||
#ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING
|
||||
#error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTGLCD_PANEL_SPI display pinout
|
||||
*
|
||||
* Board Display
|
||||
* ------ ------
|
||||
* (BEEPER) PB6 | 1 2 | PB15 (SD_DET) 5V |10 9 | GND
|
||||
* RESET | 3 4 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET)
|
||||
* PB4 5 6 | PA10 (SD_CS) (MOSI) | 6 5 | --
|
||||
* PB7 | 7 8 | PD2 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS)
|
||||
* GND | 9 10 | 5V (SCK) | 2 1 | (MISO)
|
||||
* ------ ------
|
||||
* EXP1 EXP1
|
||||
*
|
||||
* Needs custom cable:
|
||||
*
|
||||
* Board Display
|
||||
*
|
||||
* EXP1-10 ---------- EXP1-10
|
||||
* EXP1-9 ----------- EXP1-9
|
||||
* SPI1-4 ----------- EXP1-6
|
||||
* EXP1-7 ----------- FREE
|
||||
* SPI1-3 ----------- EXP1-2
|
||||
* EXP1-5 ----------- EXP1-4
|
||||
* EXP1-4 ----------- FREE
|
||||
* EXP1-3 ----------- EXP1-3
|
||||
* SPI1-1 ----------- EXP1-1
|
||||
* EXP1-1 ----------- EXP1-7
|
||||
*/
|
||||
|
||||
#define TFTGLCD_CS EXP1_03_PIN
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3."
|
||||
#endif
|
||||
|
||||
#endif // HAS_WIRED_LCD
|
||||
|
||||
#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050)
|
||||
|
||||
#ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING
|
||||
#error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* FYSETC TFT TFT81050 display pinout
|
||||
*
|
||||
* Board Display
|
||||
* ------ ------
|
||||
* (SD_DET) PB15 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND
|
||||
* (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET)
|
||||
* (SD_CS) PA10 5 6 | PB4 (FREE) (MOSI) | 6 5 | (LCD_CS)
|
||||
* (LCD_CS) PD2 | 7 8 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET)
|
||||
* 5V | 9 10 | GND (SCK) | 2 1 | (MISO)
|
||||
* ------ ------
|
||||
* EXP1 EXP1
|
||||
*
|
||||
* Needs custom cable:
|
||||
*
|
||||
* Board Adapter Display
|
||||
* _________
|
||||
* EXP1-10 ---------- EXP1-10
|
||||
* EXP1-9 ----------- EXP1-9
|
||||
* SPI1-4 ----------- EXP1-6
|
||||
* EXP1-7 ----------- EXP1-5
|
||||
* SPI1-3 ----------- EXP1-2
|
||||
* EXP1-5 ----------- EXP1-4
|
||||
* EXP1-4 ----------- EXP1-8
|
||||
* EXP1-3 ----------- EXP1-3
|
||||
* SPI1-1 ----------- EXP1-1
|
||||
* EXP1-1 ----------- EXP1-7
|
||||
*/
|
||||
|
||||
#define CLCD_SPI_BUS 1 // SPI1 connector
|
||||
|
||||
#define BEEPER_PIN EXP1_02_PIN
|
||||
|
||||
#define CLCD_MOD_RESET EXP1_03_PIN
|
||||
#define CLCD_SPI_CS EXP1_07_PIN
|
||||
|
||||
#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050
|
||||
|
||||
//
|
||||
// SD Support
|
||||
//
|
||||
|
||||
#ifndef SDCARD_CONNECTION
|
||||
#define SDCARD_CONNECTION ONBOARD
|
||||
#endif
|
||||
|
||||
#if SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL)
|
||||
#define SD_DETECT_PIN EXP1_01_PIN
|
||||
#define SD_SS_PIN EXP1_05_PIN
|
||||
#elif SD_CONNECTION_IS(CUSTOM_CABLE)
|
||||
#error "SD CUSTOM_CABLE is not compatible with SKR Mini E3."
|
||||
#endif
|
||||
|
||||
#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1...
|
||||
#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card
|
||||
|
||||
#define ENABLE_SPI1
|
||||
#define SDSS ONBOARD_SD_CS_PIN
|
||||
#define SD_SS_PIN ONBOARD_SD_CS_PIN
|
||||
#define SD_SCK_PIN PA5
|
||||
#define SD_MISO_PIN PA6
|
||||
#define SD_MOSI_PIN PA7
|
381
Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h
Normal file
381
Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h
Normal file
@@ -0,0 +1,381 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "env_validate.h"
|
||||
|
||||
#if HOTENDS > 4 || E_STEPPERS > 4
|
||||
#error "MKS SKIPR supports up to 4 hotends / E steppers."
|
||||
#endif
|
||||
|
||||
#define BOARD_INFO_NAME "MKS SKIPR V1.0"
|
||||
|
||||
// Valid SERIAL_PORT values: -1 (USB-C), 1 (direct to RK3328), 3 (USART3 header)
|
||||
|
||||
#define USES_DIAG_JUMPERS
|
||||
|
||||
// Onboard I2C EEPROM
|
||||
#define I2C_EEPROM
|
||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32)
|
||||
#define I2C_SCL_PIN PB8
|
||||
#define I2C_SDA_PIN PB9
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PA8
|
||||
|
||||
//
|
||||
// Trinamic Stallguard pins // Connector labels
|
||||
#define X_DIAG_PIN PA14 // X-
|
||||
#define Y_DIAG_PIN PA15 // Y-
|
||||
#define Z_DIAG_PIN PB15 // Z-
|
||||
#define E0_DIAG_PIN PA13 // MT-DET
|
||||
#define E1_DIAG_PIN PC5 // NEOPIXEL
|
||||
#define E2_DIAG_PIN PB14 // Z+
|
||||
|
||||
//
|
||||
// Check for additional used endstop pins
|
||||
//
|
||||
#if HAS_EXTRA_ENDSTOPS
|
||||
#define _ENDSTOP_IS_ANY(ES) X2_USE_ENDSTOP == ES || Y2_USE_ENDSTOP == ES || Z2_USE_ENDSTOP == ES || Z3_USE_ENDSTOP == ES || Z4_USE_ENDSTOP == ES
|
||||
#if _ENDSTOP_IS_ANY(_XMIN_) || _ENDSTOP_IS_ANY(_XMAX_)
|
||||
#define NEEDS_X_MINMAX 1
|
||||
#endif
|
||||
#if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_)
|
||||
#define NEEDS_Y_MINMAX 1
|
||||
#endif
|
||||
#if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_)
|
||||
#define NEEDS_Z_MINMAX 1
|
||||
#endif
|
||||
#undef _ENDSTOP_IS_ANY
|
||||
#endif
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#ifdef X_STALL_SENSITIVITY
|
||||
#define X_STOP_PIN X_DIAG_PIN // X-
|
||||
#elif EITHER(DUAL_X_CARRIAGE, NEEDS_X_MINMAX)
|
||||
#ifndef X_MIN_PIN
|
||||
#define X_MIN_PIN X_DIAG_PIN // X-
|
||||
#endif
|
||||
#ifndef X_MAX_PIN
|
||||
#define X_MAX_PIN E0_DIAG_PIN // MT-DET
|
||||
#endif
|
||||
#else
|
||||
#define X_STOP_PIN X_DIAG_PIN // X-
|
||||
#endif
|
||||
|
||||
#ifdef Y_STALL_SENSITIVITY
|
||||
#define Y_STOP_PIN Y_DIAG_PIN // Y-
|
||||
#elif NEEDS_Y_MINMAX
|
||||
#ifndef Y_MIN_PIN
|
||||
#define Y_MIN_PIN Y_DIAG_PIN // Y-
|
||||
#endif
|
||||
#ifndef Y_MAX_PIN
|
||||
#define Y_MAX_PIN E1_DIAG_PIN // NEOPIXEL
|
||||
#endif
|
||||
#else
|
||||
#define Y_STOP_PIN Y_DIAG_PIN // Y-
|
||||
#endif
|
||||
|
||||
#ifdef Z_STALL_SENSITIVITY
|
||||
#define Z_STOP_PIN Z_DIAG_PIN // Z-
|
||||
#elif NEEDS_Z_MINMAX
|
||||
#ifndef Z_MIN_PIN
|
||||
#define Z_MIN_PIN Z_DIAG_PIN // Z-
|
||||
#endif
|
||||
#ifndef Z_MAX_PIN
|
||||
#define Z_MAX_PIN E2_DIAG_PIN // Z+
|
||||
#endif
|
||||
#else
|
||||
#define Z_STOP_PIN Z_DIAG_PIN // Z-
|
||||
#endif
|
||||
|
||||
#if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) || ENABLED(USE_PROBE_FOR_Z_HOMING)
|
||||
#ifndef Z_MIN_PROBE
|
||||
#define Z_MIN_PROBE_PIN E2_DIAG_PIN // defaults to 'Z+' connector
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef NEEDS_X_MINMAX
|
||||
#undef NEEDS_Y_MINMAX
|
||||
#undef NEEDS_Z_MINMAX
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_STEP_PIN PC14
|
||||
#define X_DIR_PIN PC13
|
||||
#define X_ENABLE_PIN PC15
|
||||
#ifndef X_CS_PIN
|
||||
#define X_CS_PIN PE6
|
||||
#endif
|
||||
|
||||
#define Y_STEP_PIN PE5
|
||||
#define Y_DIR_PIN PE4
|
||||
#define Y_ENABLE_PIN PD14
|
||||
#ifndef Y_CS_PIN
|
||||
#define Y_CS_PIN PE3
|
||||
#endif
|
||||
|
||||
#define Z_STEP_PIN PE1 // "Z1"
|
||||
#define Z_DIR_PIN PE0
|
||||
#define Z_ENABLE_PIN PE2
|
||||
#ifndef Z_CS_PIN
|
||||
#define Z_CS_PIN PB7
|
||||
#endif
|
||||
|
||||
#define E0_STEP_PIN PB5
|
||||
#define E0_DIR_PIN PB4
|
||||
#define E0_ENABLE_PIN PB6
|
||||
#ifndef E0_CS_PIN
|
||||
#define E0_CS_PIN PB3
|
||||
#endif
|
||||
|
||||
#define E1_STEP_PIN PD6 // "Z2"
|
||||
#define E1_DIR_PIN PD5
|
||||
#define E1_ENABLE_PIN PD7
|
||||
#ifndef E1_CS_PIN
|
||||
#define E1_CS_PIN PD4
|
||||
#endif
|
||||
|
||||
#define E2_STEP_PIN PD2 // "Z3"
|
||||
#define E2_DIR_PIN PD1
|
||||
#define E2_ENABLE_PIN PD3
|
||||
#ifndef E2_CS_PIN
|
||||
#define E2_CS_PIN PD0
|
||||
#endif
|
||||
|
||||
#define E3_STEP_PIN PC7 // "Z4"
|
||||
#define E3_DIR_PIN PC6
|
||||
#define E3_ENABLE_PIN PC8
|
||||
#ifndef E3_CS_PIN
|
||||
#define E3_CS_PIN PD15
|
||||
#endif
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_BED_PIN PC0 // TB
|
||||
#define TEMP_0_PIN PC1 // TH0
|
||||
#define TEMP_1_PIN PC2 // TH1
|
||||
#define TEMP_2_PIN PC3 // TH2
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_BED_PIN PD12 // Hotbed
|
||||
#define HEATER_0_PIN PB1 // Heater0
|
||||
#define HEATER_1_PIN PB0 // Heater1
|
||||
#define HEATER_2_PIN PA3 // Heater2
|
||||
|
||||
#define FAN_PIN PA2 // Fan0
|
||||
#define FAN1_PIN PA1 // Fan1
|
||||
#define FAN2_PIN PA0 // Fan2
|
||||
|
||||
//
|
||||
// Software SPI pins for TMC2130 stepper drivers
|
||||
// This board doesn't support hardware SPI there
|
||||
//
|
||||
#if HAS_TMC_SPI
|
||||
#define TMC_USE_SW_SPI
|
||||
#define TMC_SW_MOSI PE14
|
||||
#define TMC_SW_MISO PE13
|
||||
#define TMC_SW_SCK PE12
|
||||
#endif
|
||||
|
||||
//
|
||||
// TMC2208/TMC2209 stepper drivers
|
||||
// This board is routed for one-wire software serial
|
||||
//
|
||||
#if HAS_TMC_UART
|
||||
#define X_SERIAL_TX_PIN PE6
|
||||
#define X_SERIAL_RX_PIN X_SERIAL_TX_PIN
|
||||
|
||||
#define Y_SERIAL_TX_PIN PE3
|
||||
#define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN
|
||||
|
||||
#define Z_SERIAL_TX_PIN PB7
|
||||
#define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN
|
||||
|
||||
#define E0_SERIAL_TX_PIN PB3
|
||||
#define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN
|
||||
|
||||
#define E1_SERIAL_TX_PIN PD4
|
||||
#define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN
|
||||
|
||||
#define E2_SERIAL_TX_PIN PD0
|
||||
#define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN
|
||||
|
||||
#define E3_SERIAL_TX_PIN PD15
|
||||
#define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN
|
||||
|
||||
// Reduce baud rate to improve software serial reliability
|
||||
#define TMC_BAUD_RATE 19200
|
||||
#endif
|
||||
|
||||
/** ------ ------
|
||||
* (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK)
|
||||
* (LCD_EN) PE11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PE9 | 3 4 | PA4 (SD_SS)
|
||||
* (LCD_D4) PD9 | 5 6 PD8 (LCD_D5) (BTN_EN2) PE8 | 5 6 PA7 (MOSI)
|
||||
* (LCD_D6) PE15 | 7 8 | PE7 (LCD_D7) (SD_DETECT) PD13 | 7 8 | RESET
|
||||
* GND | 9 10 | 5V GND | 9 10 | --
|
||||
* ------ ------
|
||||
* EXP1 EXP2
|
||||
*/
|
||||
#define EXP1_01_PIN PB2
|
||||
#define EXP1_02_PIN PE10
|
||||
#define EXP1_03_PIN PE11
|
||||
#define EXP1_04_PIN PD10
|
||||
#define EXP1_05_PIN PD9
|
||||
#define EXP1_06_PIN PD8
|
||||
#define EXP1_07_PIN PE15
|
||||
#define EXP1_08_PIN PE7
|
||||
|
||||
#define EXP2_01_PIN PA6
|
||||
#define EXP2_02_PIN PA5
|
||||
#define EXP2_03_PIN PE9
|
||||
#define EXP2_04_PIN PA4
|
||||
#define EXP2_05_PIN PE8
|
||||
#define EXP2_06_PIN PA7
|
||||
#define EXP2_07_PIN PD13
|
||||
#define EXP2_08_PIN -1 // connected to MCU reset
|
||||
|
||||
//
|
||||
// SD Support
|
||||
// Onboard SD card use hardware SPI3 (defined in variant), LCD SD card use hardware SPI1
|
||||
//
|
||||
#if ENABLED(SDSUPPORT)
|
||||
#ifndef SDCARD_CONNECTION
|
||||
#define SDCARD_CONNECTION LCD
|
||||
#endif
|
||||
#if SD_CONNECTION_IS(ONBOARD)
|
||||
//#define SOFTWARE_SPI
|
||||
//#define SD_SPI_SPEED SPI_HALF_SPEED
|
||||
#undef SD_DETECT_STATE
|
||||
#define SD_DETECT_STATE LOW
|
||||
#define SD_DETECT_PIN PC4
|
||||
#elif SD_CONNECTION_IS(LCD)
|
||||
//#define SOFTWARE_SPI
|
||||
//#define SD_SPI_SPEED SPI_QUARTER_SPEED
|
||||
#define SD_SS_PIN EXP2_04_PIN
|
||||
#define SD_SCK_PIN EXP2_02_PIN
|
||||
#define SD_MISO_PIN EXP2_01_PIN
|
||||
#define SD_MOSI_PIN EXP2_06_PIN
|
||||
#define SD_DETECT_PIN EXP2_07_PIN
|
||||
#elif SD_CONNECTION_IS(CUSTOM_CABLE)
|
||||
#error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
|
||||
#endif
|
||||
#define SDSS SD_SS_PIN
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCDs and Controllers
|
||||
//
|
||||
#if IS_TFTGLCD_PANEL
|
||||
|
||||
#if ENABLED(TFTGLCD_PANEL_SPI)
|
||||
#define TFTGLCD_CS EXP2_03_PIN
|
||||
#endif
|
||||
|
||||
#elif HAS_WIRED_LCD
|
||||
|
||||
#define BEEPER_PIN EXP1_01_PIN
|
||||
#define BTN_ENC EXP1_02_PIN
|
||||
|
||||
#if ENABLED(CR10_STOCKDISPLAY)
|
||||
|
||||
#define LCD_PINS_RS EXP1_07_PIN
|
||||
|
||||
#define BTN_EN1 EXP1_03_PIN
|
||||
#define BTN_EN2 EXP1_05_PIN
|
||||
|
||||
#define LCD_PINS_ENABLE EXP1_08_PIN
|
||||
#define LCD_PINS_D4 EXP1_06_PIN
|
||||
|
||||
#else
|
||||
|
||||
#define LCD_PINS_RS EXP1_04_PIN
|
||||
|
||||
#define BTN_EN1 EXP2_03_PIN
|
||||
#define BTN_EN2 EXP2_05_PIN
|
||||
|
||||
#define LCD_PINS_ENABLE EXP1_03_PIN
|
||||
#define LCD_PINS_D4 EXP1_05_PIN
|
||||
|
||||
#if ENABLED(FYSETC_MINI_12864)
|
||||
#define DOGLCD_CS EXP1_03_PIN
|
||||
#define DOGLCD_A0 EXP1_04_PIN
|
||||
//#define LCD_BACKLIGHT_PIN -1
|
||||
#define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally.
|
||||
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
|
||||
#ifndef RGB_LED_R_PIN
|
||||
#define RGB_LED_R_PIN EXP1_06_PIN
|
||||
#endif
|
||||
#ifndef RGB_LED_G_PIN
|
||||
#define RGB_LED_G_PIN EXP1_07_PIN
|
||||
#endif
|
||||
#ifndef RGB_LED_B_PIN
|
||||
#define RGB_LED_B_PIN EXP1_08_PIN
|
||||
#endif
|
||||
#elif ENABLED(FYSETC_MINI_12864_2_1)
|
||||
#define NEOPIXEL_PIN EXP1_06_PIN
|
||||
#endif
|
||||
#endif // !FYSETC_MINI_12864
|
||||
|
||||
#if IS_ULTIPANEL
|
||||
#define LCD_PINS_D5 EXP1_06_PIN
|
||||
#define LCD_PINS_D6 EXP1_07_PIN
|
||||
#define LCD_PINS_D7 EXP1_08_PIN
|
||||
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
|
||||
#define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // HAS_WIRED_LCD
|
||||
|
||||
// Alter timing for graphical display
|
||||
#if IS_U8GLIB_ST7920
|
||||
#define BOARD_ST7920_DELAY_1 120
|
||||
#define BOARD_ST7920_DELAY_2 80
|
||||
#define BOARD_ST7920_DELAY_3 580
|
||||
#endif
|
||||
|
||||
//
|
||||
// NeoPixel LED
|
||||
//
|
||||
#ifndef NEOPIXEL_PIN
|
||||
#define NEOPIXEL_PIN PC5
|
||||
#endif
|
||||
|
||||
//
|
||||
// MAX31865
|
||||
//
|
||||
#if HAS_MAX31865
|
||||
#define TEMP_0_CS_PIN PD11
|
||||
#define TEMP_0_SCK_PIN PE12
|
||||
#define TEMP_0_MISO_PIN PE13
|
||||
#define TEMP_0_MOSI_PIN PE14
|
||||
#endif
|
206
Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h
Normal file
206
Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* STM32F407VET6 on Opulo Lumen PnP Rev3
|
||||
* Website - https://opulo.io/
|
||||
*/
|
||||
|
||||
#define ALLOW_STM32DUINO
|
||||
#include "env_validate.h"
|
||||
|
||||
#define BOARD_INFO_NAME "LumenPnP Motherboard REV04"
|
||||
#define DEFAULT_MACHINE_NAME "LumenPnP"
|
||||
|
||||
/**
|
||||
* By default, the extra stepper motor configuration is:
|
||||
* I = Left Head
|
||||
* J = Right Head
|
||||
* K = Auxiliary (Conveyor belt)
|
||||
*/
|
||||
|
||||
#define SRAM_EEPROM_EMULATION
|
||||
#define MARLIN_EEPROM_SIZE 0x2000 // 8K
|
||||
|
||||
// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC)
|
||||
#define HAS_MCP3426_ADC
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PB10
|
||||
#define SERVO1_PIN PB11
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_STOP_PIN PC6
|
||||
#define Y_STOP_PIN PD15
|
||||
#define Z_STOP_PIN PD14
|
||||
|
||||
// None of these require limit switches by default, so we leave these commented
|
||||
// here for your reference.
|
||||
//#define I_MIN_PIN PA8
|
||||
//#define I_MAX_PIN PA8
|
||||
//#define J_MIN_PIN PD13
|
||||
//#define J_MAX_PIN PD13
|
||||
//#define K_MIN_PIN PC9
|
||||
//#define K_MAX_PIN PC9
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_STEP_PIN PB15
|
||||
#define X_DIR_PIN PB14
|
||||
#define X_ENABLE_PIN PD9
|
||||
|
||||
#define Y_STEP_PIN PE15
|
||||
#define Y_DIR_PIN PE14
|
||||
#define Y_ENABLE_PIN PB13
|
||||
|
||||
#define Z_STEP_PIN PE7
|
||||
#define Z_DIR_PIN PB1
|
||||
#define Z_ENABLE_PIN PE9
|
||||
|
||||
#define I_STEP_PIN PC4
|
||||
#define I_DIR_PIN PA4
|
||||
#define I_ENABLE_PIN PB0
|
||||
|
||||
#define J_STEP_PIN PE11
|
||||
#define J_DIR_PIN PE10
|
||||
#define J_ENABLE_PIN PE13
|
||||
|
||||
#define K_STEP_PIN PD6
|
||||
#define K_DIR_PIN PD7
|
||||
#define K_ENABLE_PIN PA3
|
||||
|
||||
#if HAS_TMC_SPI
|
||||
/**
|
||||
* Make sure to configure the jumpers on the back side of the Mobo according to
|
||||
* this diagram: https://github.com/MarlinFirmware/Marlin/pull/23851
|
||||
*/
|
||||
#error "SPI drivers require a custom jumper configuration, see comment above! Comment out this line to continue."
|
||||
|
||||
#if AXIS_HAS_SPI(X)
|
||||
#define X_CS_PIN PD8
|
||||
#endif
|
||||
#if AXIS_HAS_SPI(Y)
|
||||
#define Y_CS_PIN PB12
|
||||
#endif
|
||||
#if AXIS_HAS_SPI(Z)
|
||||
#define Z_CS_PIN PE8
|
||||
#endif
|
||||
#if AXIS_HAS_SPI(I)
|
||||
#define I_CS_PIN PC5
|
||||
#endif
|
||||
#if AXIS_HAS_SPI(J)
|
||||
#define J_CS_PIN PE12
|
||||
#endif
|
||||
#if AXIS_HAS_SPI(K)
|
||||
#define K_CS_PIN PA2
|
||||
#endif
|
||||
|
||||
#elif HAS_TMC_UART
|
||||
|
||||
#define X_SERIAL_TX_PIN PD8
|
||||
#define X_SERIAL_RX_PIN X_SERIAL_TX_PIN
|
||||
|
||||
#define Y_SERIAL_TX_PIN PB12
|
||||
#define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN
|
||||
|
||||
#define Z_SERIAL_TX_PIN PE8
|
||||
#define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN
|
||||
|
||||
#define I_SERIAL_TX_PIN PC5
|
||||
#define I_SERIAL_RX_PIN I_SERIAL_TX_PIN
|
||||
|
||||
#define J_SERIAL_TX_PIN PE12
|
||||
#define J_SERIAL_RX_PIN J_SERIAL_TX_PIN
|
||||
|
||||
#define K_SERIAL_TX_PIN PA2
|
||||
#define K_SERIAL_RX_PIN K_SERIAL_TX_PIN
|
||||
|
||||
// Reduce baud rate to improve software serial reliability
|
||||
#define TMC_BAUD_RATE 19200
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define FAN_PIN PE2
|
||||
#define FAN1_PIN PE3
|
||||
#define FAN2_PIN PE4
|
||||
#define FAN3_PIN PE5
|
||||
|
||||
#define FAN_SOFT_PWM_REQUIRED
|
||||
|
||||
//
|
||||
// Neopixel
|
||||
//
|
||||
#define NEOPIXEL_PIN PC7
|
||||
#define NEOPIXEL2_PIN PC8
|
||||
|
||||
//
|
||||
// SPI
|
||||
//
|
||||
#define MISO_PIN PB4
|
||||
#define MOSI_PIN PB5
|
||||
#define SCK_PIN PB3
|
||||
|
||||
#define TMC_SW_MISO MISO_PIN
|
||||
#define TMC_SW_MOSI MOSI_PIN
|
||||
#define TMC_SW_SCK SCK_PIN
|
||||
|
||||
//
|
||||
// I2C
|
||||
//
|
||||
#define I2C_SDA_PIN PB7
|
||||
#define I2C_SCL_PIN PB6
|
||||
|
||||
/**
|
||||
* The index mobo rev03 has 3 aux ports. We define them here so they may be used
|
||||
* in other places and to make sure someone doesn't have to go look up the pinout
|
||||
* in the board files. Each 12 pin aux port has this pinout:
|
||||
*
|
||||
* VDC 1 2 GND
|
||||
* 3.3V 3 4 SCL (I2C_SCL_PIN)
|
||||
* PWM1 5 6 SDA (I2C_SDA_PIN)
|
||||
* PWM2 7 8 CIPO (MISO_PIN)
|
||||
* A1 9 10 COPI (MOSI_PIN)
|
||||
* A2 11 12 SCK (SCK_PIN)
|
||||
*/
|
||||
#define LUMEN_AUX1_PWM1 PA15
|
||||
#define LUMEN_AUX1_PWM2 PA5
|
||||
#define LUMEN_AUX1_A1 PC0
|
||||
#define LUMEN_AUX1_A2 PC1
|
||||
|
||||
#define LUMEN_AUX2_PWM1 PA6
|
||||
#define LUMEN_AUX2_PWM2 PA7
|
||||
#define LUMEN_AUX2_A1 PC2
|
||||
#define LUMEN_AUX2_A2 PC3
|
||||
|
||||
#define LUMEN_AUX3_PWM1 PB8
|
||||
#define LUMEN_AUX3_PWM2 PB9
|
||||
#define LUMEN_AUX3_A1 PA0
|
||||
#define LUMEN_AUX3_A2 PA1
|
266
Marlin/src/pins/stm32f4/pins_TRONXY_V10.h
Normal file
266
Marlin/src/pins/stm32f4/pins_TRONXY_V10.h
Normal file
@@ -0,0 +1,266 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "env_validate.h"
|
||||
|
||||
#if HOTENDS > 3 || E_STEPPERS > 3
|
||||
#error "Tronxy V10 supports up to 3 hotends / E steppers."
|
||||
#endif
|
||||
|
||||
#define BOARD_INFO_NAME "Tronxy V10"
|
||||
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
|
||||
|
||||
#define STEP_TIMER 6
|
||||
#define TEMP_TIMER 14
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
//#define SERVO0_PIN PB10
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
#if NO_EEPROM_SELECTED
|
||||
#undef NO_EEPROM_SELECTED
|
||||
#if TRONXY_UI > 0
|
||||
#define EEPROM_AT24CXX
|
||||
#else
|
||||
#define FLASH_EEPROM_EMULATION
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(FLASH_EEPROM_EMULATION)
|
||||
// SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h)
|
||||
#define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE)
|
||||
#define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB)
|
||||
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE
|
||||
#else
|
||||
#if ENABLED(EEPROM_AT24CXX)
|
||||
#define AT24CXX_SCL PB8
|
||||
#define AT24CXX_SDA PB9
|
||||
#define AT24CXX_WP PB7
|
||||
#else
|
||||
#define I2C_EEPROM // AT24C32
|
||||
#endif
|
||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4K
|
||||
#endif
|
||||
|
||||
//
|
||||
// SPI Flash
|
||||
//
|
||||
//#define SPI_FLASH
|
||||
#if ENABLED(SPI_FLASH)
|
||||
#define SPI_FLASH_SIZE 0x200000 // 2MB
|
||||
#define W25QXX_CS_PIN PG15 // SPI2
|
||||
#define W25QXX_MOSI_PIN PB5
|
||||
#define W25QXX_MISO_PIN PB4
|
||||
#define W25QXX_SCK_PIN PB3
|
||||
#endif
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_MIN_PIN PC15
|
||||
#define X_MAX_PIN PB0
|
||||
#define Y_STOP_PIN PC14
|
||||
|
||||
#ifndef Z_MIN_PROBE_PIN
|
||||
#define Z_MIN_PROBE_PIN PE3
|
||||
#endif
|
||||
|
||||
#if ENABLED(DUAL_Z_ENDSTOP_PROBE)
|
||||
#if NUM_Z_STEPPERS > 1 && Z_HOME_TO_MAX // Swap Z1/Z2 for dual Z with max homing
|
||||
#define Z_MIN_PIN PF11
|
||||
#define Z_MAX_PIN PC13
|
||||
#else
|
||||
#define Z_MIN_PIN PC13
|
||||
#define Z_MAX_PIN PF11
|
||||
#endif
|
||||
#else
|
||||
#ifndef Z_STOP_PIN
|
||||
#define Z_STOP_PIN PC13
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
// Filament Sensors
|
||||
//
|
||||
#ifndef FIL_RUNOUT_PIN
|
||||
#define FIL_RUNOUT_PIN PE6 // MT_DET
|
||||
#endif
|
||||
#ifndef FIL_RUNOUT2_PIN
|
||||
#define FIL_RUNOUT2_PIN PF12
|
||||
#endif
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_ENABLE_PIN PF0
|
||||
#define X_STEP_PIN PE5
|
||||
#define X_DIR_PIN PF1
|
||||
|
||||
#define Y_ENABLE_PIN PF5
|
||||
#define Y_STEP_PIN PF9
|
||||
#define Y_DIR_PIN PF3
|
||||
|
||||
#define Z_ENABLE_PIN PA5
|
||||
#define Z_STEP_PIN PA6
|
||||
#define Z_DIR_PIN PF15
|
||||
|
||||
#define E0_ENABLE_PIN PF14
|
||||
#define E0_STEP_PIN PB1
|
||||
#define E0_DIR_PIN PF13
|
||||
|
||||
#define E1_ENABLE_PIN PG5
|
||||
#define E1_STEP_PIN PD12
|
||||
#define E1_DIR_PIN PG4
|
||||
|
||||
#define E2_ENABLE_PIN PF7
|
||||
#define E2_STEP_PIN PF6
|
||||
#define E2_DIR_PIN PF4
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN PC3 // TH1
|
||||
#define TEMP_BED_PIN PC2 // TB1
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN PG7 // HEATER1
|
||||
#define HEATER_BED_PIN PE2 // HOT BED
|
||||
//#define HEATER_BED_INVERTING true
|
||||
|
||||
#define FAN_PIN PG0 // FAN0
|
||||
#define FAN1_PIN PB6 // FAN1
|
||||
#define FAN2_PIN PG9 // FAN2
|
||||
#define FAN3_PIN PF10 // FAN3
|
||||
#define CONTROLLER_FAN_PIN PD7 // BOARD FAN
|
||||
#define FAN_SOFT_PWM
|
||||
|
||||
//
|
||||
// Laser / Spindle
|
||||
//
|
||||
#if HAS_CUTTER
|
||||
#define SPINDLE_LASER_ENA_PIN PB11 // wifi:TX
|
||||
#if ENABLED(SPINDLE_LASER_USE_PWM)
|
||||
#define SPINDLE_LASER_PWM_PIN PB10 // wifi:RX-TIM2_CH3
|
||||
// The PWM pin definition const PinMap PinMap_PWM[] in PeripheralPins.c must be compounded here
|
||||
// See PWM_PIN(x) definition for details
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
#define BEEPER_PIN PA8
|
||||
|
||||
//#define LED_PIN PG10
|
||||
#define PS_ON_PIN PG10 // Temporarily switch the machine with LED simulation
|
||||
|
||||
#if ENABLED(TRONXY_BACKUP_POWER)
|
||||
#define POWER_LOSS_PIN PF11 // Configure as drop-down input
|
||||
#else
|
||||
#define POWER_LOSS_PIN PE1 // Output of LM393 comparator, configured as pullup
|
||||
#endif
|
||||
//#define POWER_LM393_PIN PE0 // +V for the LM393 comparator, configured as output high
|
||||
|
||||
#if ENABLED(TFT_TRONXY_X5SA)
|
||||
#error "TFT_TRONXY_X5SA is not yet supported."
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
//
|
||||
// TFT with FSMC interface
|
||||
//
|
||||
#if HAS_FSMC_TFT
|
||||
#define TFT_RESET_PIN PB12
|
||||
#define TFT_BACKLIGHT_PIN PG8
|
||||
|
||||
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
|
||||
#define FSMC_DMA_DEV DMA2
|
||||
#define FSMC_DMA_CHANNEL DMA_CH5
|
||||
|
||||
#define TFT_CS_PIN PG12
|
||||
#define TFT_RS_PIN PG2
|
||||
|
||||
//#define TFT_WIDTH 480
|
||||
//#define TFT_HEIGHT 320
|
||||
//#define TFT_PIXEL_OFFSET_X 48
|
||||
//#define TFT_PIXEL_OFFSET_Y 32
|
||||
//#define TFT_DRIVER ILI9488
|
||||
//#define TFT_BUFFER_SIZE 14400
|
||||
|
||||
#if NEED_TOUCH_PINS
|
||||
#define TOUCH_CS_PIN PD11 // SPI1_NSS
|
||||
#define TOUCH_SCK_PIN PB13 // SPI1_SCK
|
||||
#define TOUCH_MISO_PIN PB14 // SPI1_MISO
|
||||
#define TOUCH_MOSI_PIN PB15 // SPI1_MOSI
|
||||
#endif
|
||||
|
||||
#if (LCD_CHIP_INDEX == 1 && (TRONXY_UI == 1 || TRONXY_UI == 2)) || LCD_CHIP_INDEX == 3
|
||||
#define TOUCH_CALIBRATION_X -17181
|
||||
#define TOUCH_CALIBRATION_Y 11434
|
||||
#define TOUCH_OFFSET_X 501
|
||||
#define TOUCH_OFFSET_Y -9
|
||||
#elif LCD_CHIP_INDEX == 1 && TRONXY_UI == 4
|
||||
#define TOUCH_CALIBRATION_X 11166
|
||||
#define TOUCH_CALIBRATION_Y 17162
|
||||
#define TOUCH_OFFSET_X -10
|
||||
#define TOUCH_OFFSET_Y -16
|
||||
#elif LCD_CHIP_INDEX == 4 && TRONXY_UI == 3
|
||||
//#define TOUCH_CALIBRATION_X 8781
|
||||
//#define TOUCH_CALIBRATION_Y 11773
|
||||
//#define TOUCH_OFFSET_X -17
|
||||
//#define TOUCH_OFFSET_Y -16
|
||||
// Upside-down
|
||||
#define TOUCH_CALIBRATION_X -8553
|
||||
#define TOUCH_CALIBRATION_Y -11667
|
||||
#define TOUCH_OFFSET_X 253
|
||||
#define TOUCH_OFFSET_Y 331
|
||||
#elif LCD_CHIP_INDEX == 2
|
||||
#define TOUCH_CALIBRATION_X 17184
|
||||
#define TOUCH_CALIBRATION_Y 10604
|
||||
#define TOUCH_OFFSET_X -31
|
||||
#define TOUCH_OFFSET_Y -29
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// SD Card
|
||||
//
|
||||
#define SDIO_SUPPORT
|
||||
#define SD_DETECT_PIN -1 // PF0, but not connected
|
||||
#define SDIO_CLOCK 4500000
|
||||
#define SDIO_READ_RETRIES 16
|
||||
|
||||
#define SDIO_D0_PIN PC8
|
||||
#define SDIO_D1_PIN PC9
|
||||
#define SDIO_D2_PIN PC10
|
||||
#define SDIO_D3_PIN PC11
|
||||
#define SDIO_CK_PIN PC12
|
||||
#define SDIO_CMD_PIN PD2
|
153
Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h
Normal file
153
Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/** CAUTION **
|
||||
* This board definition is to facilitate support for a Filament Extrusion
|
||||
* devices, used to convert waste plastic into 3D printable filament.
|
||||
* This board is NOT a general 3D printing controller; it is NOT supported
|
||||
* as a toolboard via CANBUS (as it was originally designed) or any device
|
||||
* that requires kinematics.
|
||||
*/
|
||||
|
||||
#ifndef BOARD_INFO_NAME
|
||||
#define BOARD_INFO_NAME "BTT EBB42 V1.1"
|
||||
#endif
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION)
|
||||
#undef NO_EEPROM_SELECTED
|
||||
#ifndef FLASH_EEPROM_EMULATION
|
||||
#define FLASH_EEPROM_EMULATION
|
||||
#endif
|
||||
#define EEPROM_PAGE_SIZE (0x800UL) // 2K
|
||||
#define EEPROM_START_ADDRESS (0x0801F800UL)
|
||||
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
//#define USES_DIAG_JUMPERS
|
||||
|
||||
// Ignore temp readings during development.
|
||||
//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000
|
||||
|
||||
#define LED_PIN PA13
|
||||
|
||||
#define I2C_SDA_PIN PB4
|
||||
#define I2C_SCL_PIN PB3
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PB9 // SERVOS
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#if !HAS_WIRED_LCD
|
||||
#define X_STOP_PIN PB6
|
||||
#define Y_STOP_PIN PB5
|
||||
#define Z_STOP_PIN PB7
|
||||
#endif
|
||||
|
||||
//
|
||||
// Z Probe must be this pin
|
||||
//
|
||||
#define Z_MIN_PROBE_PIN PB8 // PROBE
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_ENABLE_PIN -1
|
||||
#define X_STEP_PIN PA10 // Unused. Assigned so Marlin will compile
|
||||
#define X_DIR_PIN -1
|
||||
|
||||
#define Y_ENABLE_PIN -1
|
||||
#define Y_STEP_PIN PA10 // Unused. Assigned so Marlin will compile
|
||||
#define Y_DIR_PIN -1
|
||||
|
||||
#define Z_ENABLE_PIN -1
|
||||
#define Z_STEP_PIN PA10 // Unused. Assigned so Marlin will compile
|
||||
#define Z_DIR_PIN -1
|
||||
|
||||
#define E0_ENABLE_PIN PD2
|
||||
#define E0_STEP_PIN PD0
|
||||
#define E0_DIR_PIN PD1
|
||||
|
||||
#if HAS_TMC_UART
|
||||
/**
|
||||
* TMC220x stepper drivers
|
||||
* Hardware serial communication ports
|
||||
*/
|
||||
//#define E0_HARDWARE_SERIAL MSerial4
|
||||
|
||||
// This is the stable default value after testing, but, higher UART rates could be configured, remeber to test the Steppers with the M122 command to check if everything works.
|
||||
//#define TMC_BAUD_RATE 250000
|
||||
|
||||
#define E0_SERIAL_TX_PIN PA15
|
||||
#define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN
|
||||
|
||||
// Reduce baud rate to improve software serial reliability
|
||||
#define TMC_BAUD_RATE 19200
|
||||
|
||||
// Default TMC slave addresses
|
||||
#ifndef E0_SLAVE_ADDRESS
|
||||
#define E0_SLAVE_ADDRESS 0b00
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN PA3 // Analog Input "TH0"
|
||||
|
||||
// SPI for MAX Thermocouple
|
||||
// Uses a separate SPI bus
|
||||
|
||||
#define TEMP_0_CS_PIN PA4 // GTR K-TEMP
|
||||
#define TEMP_0_SCK_PIN PA5 // SCK
|
||||
#define TEMP_0_MISO_PIN PA6 // MISO
|
||||
#define TEMP_0_MOSI_PIN PA7 // For MAX31865
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN PA2 // "HE"
|
||||
#define FAN_PIN PA0 // "FAN0"
|
||||
#define FAN1_PIN PA1 // "FAN1"
|
||||
|
||||
//
|
||||
// Default NEOPIXEL_PIN
|
||||
//
|
||||
#ifndef NEOPIXEL_PIN
|
||||
#define NEOPIXEL_PIN PD3 // LED driving pin
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCD / Controller
|
||||
//
|
||||
#if HAS_WIRED_LCD
|
||||
#define BTN_EN1 PB7
|
||||
#define BTN_EN2 PB5
|
||||
#define BTN_ENC PB6
|
||||
#endif
|
Reference in New Issue
Block a user