From e561f744fa67d562d4841f4e3c418a99599b1c3d Mon Sep 17 00:00:00 2001 From: Daniel Mazurkiewicz Date: Mon, 10 Feb 2020 22:12:11 +0200 Subject: [PATCH 01/16] Update MKS BASE and v1.6 pins (#16806) --- Marlin/src/pins/pins.h | 2 +- .../{pins_MKS_BASE.h => pins_MKS_BASE_10.h} | 22 +----- Marlin/src/pins/ramps/pins_MKS_BASE_14.h | 43 +++-------- Marlin/src/pins/ramps/pins_MKS_BASE_15.h | 17 +---- Marlin/src/pins/ramps/pins_MKS_BASE_16.h | 39 ++++++---- Marlin/src/pins/ramps/pins_MKS_BASE_common.h | 75 +++++++++++++++++++ 6 files changed, 117 insertions(+), 81 deletions(-) rename Marlin/src/pins/ramps/{pins_MKS_BASE.h => pins_MKS_BASE_10.h} (74%) create mode 100644 Marlin/src/pins/ramps/pins_MKS_BASE_common.h diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index a1c2ad6b83a4..e05bfeed0498 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -105,7 +105,7 @@ #elif MB(BAM_DICE_DUE) #include "ramps/pins_BAM_DICE_DUE.h" // ATmega1280, ATmega2560 env:megaatmega1280 env:megaatmega2560 #elif MB(MKS_BASE) - #include "ramps/pins_MKS_BASE.h" // ATmega1280, ATmega2560 env:megaatmega1280 env:megaatmega2560 + #include "ramps/pins_MKS_BASE_10.h" // ATmega1280, ATmega2560 env:megaatmega1280 env:megaatmega2560 #elif MB(MKS_BASE_14) #include "ramps/pins_MKS_BASE_14.h" // ATmega2560 env:megaatmega2560 #elif MB(MKS_BASE_15) diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE.h b/Marlin/src/pins/ramps/pins_MKS_BASE_10.h similarity index 74% rename from Marlin/src/pins/ramps/pins_MKS_BASE.h rename to Marlin/src/pins/ramps/pins_MKS_BASE_10.h index 72e062e635ea..b1010482c168 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_10.h @@ -31,23 +31,7 @@ #error "MKS BASE 1.0 supports up to 2 hotends / E-steppers. Comment out this line to continue." #endif -#ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "MKS BASE 1.0" -#endif - -// -// Heaters / Fans -// -// Power outputs EFBF or EFBE -#define MOSFET_D_PIN 7 - -#define CASE_LIGHT_PIN 2 - -// -// M3/M4/M5 - Spindle/Laser Control -// -#define SPINDLE_LASER_PWM_PIN 2 // Hardware PWM -#define SPINDLE_LASER_ENA_PIN 15 // Pullup! -#define SPINDLE_DIR_PIN 19 +#define BOARD_INFO_NAME "MKS BASE 1.0" +#define MKS_BASE_VERSION 10 -#include "pins_RAMPS.h" +#include "pins_MKS_BASE_common.h" diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_14.h b/Marlin/src/pins/ramps/pins_MKS_BASE_14.h index a4fe6f90c12a..b1564ea2c326 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_14.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_14.h @@ -30,52 +30,31 @@ #endif #define BOARD_INFO_NAME "MKS BASE 1.4" +#define MKS_BASE_VERSION 14 // // Heaters / Fans // -#define MOSFET_D_PIN 7 // PH4 ** Pin16 ** PWM7 //E1 -#define FAN_PIN 9 // PH6 ** Pin18 ** PWM9 +#define FAN_PIN 9 // PH6 ** Pin18 ** PWM9 // Other Mods -#define CASE_LIGHT_PIN 11 // PB5 ** Pin24 ** PWM11 -#define SERVO3_PIN 12 // PB6 ** Pin25 ** D12 -#define PS_ON_PIN 2 // X+ // PE4 ** Pin6 ** PWM2 **MUST BE HARDWARE PWM -#define FILWIDTH_PIN 15 // Y+ // PJ0 ** Pin63 ** USART3_RX **Pin should have a pullup! -#define FIL_RUNOUT_PIN 19 // Z+ // PD2 ** Pin45 ** USART1_RX - -// -// M3/M4/M5 - Spindle/Laser Control -// -#define SPINDLE_LASER_PWM_PIN 2 // X+ // PE4 ** Pin6 ** PWM2 **MUST BE HARDWARE PWM -#define SPINDLE_LASER_ENA_PIN 15 // Y+ // PJ0 ** Pin63 ** USART3_RX **Pin should have a pullup! -#define SPINDLE_DIR_PIN 19 // Z+ // PD2 ** Pin45 ** USART1_RX - -// -// Microstepping pins -// -#define X_MS1_PIN 5 // PE3 ** Pin5 ** PWM5 -#define X_MS2_PIN 6 // PH3 ** Pin15 ** PWM6 -#define Y_MS1_PIN 59 // PF5 ** Pin92 ** A5 -#define Y_MS2_PIN 58 // PF4 ** Pin93 ** A4 -#define Z_MS1_PIN 22 // PA0 ** Pin78 ** D22 -#define Z_MS2_PIN 39 // PG2 ** Pin70 ** D39 -#define E0_MS1_PIN 64 // PK2 ** Pin87 ** A10 -#define E0_MS2_PIN 63 // PK1 ** Pin88 ** A9 -#define E1_MS1_PIN 57 // PF3 ** Pin94 ** A3 -#define E1_MS2_PIN 4 // PG5 ** Pin1 ** PWM4 +#define CASE_LIGHT_PIN 11 // PB5 ** Pin24 ** PWM11 +#define SERVO3_PIN 12 // PB6 ** Pin25 ** D12 +#define PS_ON_PIN 2 // X+ // PE4 ** Pin6 ** PWM2 **MUST BE HARDWARE PWM +#define FILWIDTH_PIN 15 // Y+ // PJ0 ** Pin63 ** USART3_RX **Pin should have a pullup! +#define FIL_RUNOUT_PIN 19 // Z+ // PD2 ** Pin45 ** USART1_RX #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN 50 + #define RGB_LED_R_PIN 50 #endif #ifndef RGB_LED_R_PIN - #define RGB_LED_G_PIN 51 + #define RGB_LED_G_PIN 51 #endif #ifndef RGB_LED_R_PIN - #define RGB_LED_B_PIN 52 + #define RGB_LED_B_PIN 52 #endif -#include "pins_RAMPS.h" +#include "pins_MKS_BASE_common.h" /* Available connectors on MKS BASE v1.4 diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_15.h b/Marlin/src/pins/ramps/pins_MKS_BASE_15.h index efb7bb23eb1a..683c6b7d0ee9 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_15.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_15.h @@ -30,19 +30,6 @@ #endif #define BOARD_INFO_NAME "MKS BASE 1.5" +#define MKS_BASE_VERSION 15 -#include "pins_MKS_BASE.h" - -/** - * Microstepping pins - */ -#define X_MS1_PIN 5 // Digital 3 / Pin 5 / PE3 / SERVO2_PIN -#define X_MS2_PIN 6 // Digital 6 / Pin 14 / PH3 / SERVO1_PIN -#define Y_MS1_PIN 59 // Analog 5 / Pin 92 / PF5 -#define Y_MS2_PIN 58 // Analog 4 / Pin 93 / PF4 -#define Z_MS1_PIN 22 // Digital 22 / Pin 78 / PA0 -#define Z_MS2_PIN 39 // Digital 39 / Pin 70 / PG2 -#define E0_MS1_PIN 63 // Analog 9 / Pin 86 / PK1 -#define E0_MS2_PIN 64 // Analog 10 / Pin 87 / PK2 -#define E1_MS1_PIN 57 // Analog 3 / Pin 93 / PF3 -#define E1_MS2_PIN 4 // Digital 4 / Pin 1 / PG5 / SERVO3_PIN +#include "pins_MKS_BASE_common.h" diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_16.h b/Marlin/src/pins/ramps/pins_MKS_BASE_16.h index 1cf2345e051c..985aa056b81a 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_16.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_16.h @@ -30,19 +30,30 @@ #endif #define BOARD_INFO_NAME "MKS BASE 1.6" +#define MKS_BASE_VERSION 16 -#include "pins_MKS_BASE.h" +// +// Servos +// +#define SERVO1_PIN 12 // Digital 12 / Pin 25 -/** - * Microstepping pins - */ -#define X_MS1_PIN 5 // Digital 3 / Pin 5 / PE3 / SERVO2_PIN -#define X_MS2_PIN 6 // Digital 6 / Pin 14 / PH3 / SERVO1_PIN -#define Y_MS1_PIN 59 // Analog 5 / Pin 92 / PF5 -#define Y_MS2_PIN 58 // Analog 4 / Pin 93 / PF4 -#define Z_MS1_PIN 22 // Digital 22 / Pin 78 / PA0 -#define Z_MS2_PIN 39 // Digital 39 / Pin 70 / PG2 -#define E0_MS1_PIN 63 // Analog 9 / Pin 86 / PK1 -#define E0_MS2_PIN 64 // Analog 10 / Pin 87 / PK2 -#define E1_MS1_PIN 57 // Analog 3 / Pin 93 / PF3 -#define E1_MS2_PIN 4 // Digital 4 / Pin 1 / PG5 / SERVO3_PIN +// +// Omitted RAMPS pins +// +#ifndef SERVO2_PIN + #define SERVO2_PIN -1 +#endif +#ifndef SERVO3_PIN + #define SERVO3_PIN -1 +#endif +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN -1 +#endif +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN -1 +#endif +#ifndef PS_ON_PIN + #define PS_ON_PIN -1 +#endif + +#include "pins_MKS_BASE_common.h" diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_common.h b/Marlin/src/pins/ramps/pins_MKS_BASE_common.h new file mode 100644 index 000000000000..0406da560503 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_common.h @@ -0,0 +1,75 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +/** + * MKS BASE – Arduino Mega2560 with RAMPS pin assignments + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "MKS BASE" +#endif + +#if MKS_BASE_VERSION == 14 || MKS_BASE_VERSION == 15 + // + // Heaters / Fans + // + // Power outputs EFBF or EFBE + #define MOSFET_D_PIN 7 + + // + // M3/M4/M5 - Spindle/Laser Control + // + #if HAS_CUTTER + #define SPINDLE_LASER_PWM_PIN 2 // Hardware PWM + #define SPINDLE_LASER_ENA_PIN 15 // Pullup! + #define SPINDLE_DIR_PIN 19 + #endif + + #ifndef CASE_LIGHT_PIN + #define CASE_LIGHT_PIN 2 + #endif + +#endif + +// +// Microstepping pins +// +#if MKS_BASE_VERSION >= 14 // |===== 1.4 =====|===== 1.5+ =====| + #define X_MS1_PIN 5 // PE3 | Pin 5 | PWM5 | | D3 | SERVO2_PIN + #define X_MS2_PIN 6 // PH3 | Pin 15 | PWM6 | Pin 14 | D6 | SERVO1_PIN + #define Y_MS1_PIN 59 // PF5 | Pin 92 | A5 | | | + #define Y_MS2_PIN 58 // PF4 | Pin 93 | A4 | | | + #define Z_MS1_PIN 22 // PA0 | Pin 78 | D22 | | | + #define Z_MS2_PIN 39 // PG2 | Pin 70 | D39 | | | + #if MKS_BASE_VERSION == 14 + #define E0_MS1_PIN 64 // PK2 | Pin 87 | A10 | | | + #define E0_MS2_PIN 63 // PK1 | Pin 88 | A9 | | | + #else + #define E0_MS1_PIN 63 // PK1 | | | Pin 86 | A9 | + #define E0_MS2_PIN 64 // PK2 | | | Pin 87 | A10 | + #endif + #define E1_MS1_PIN 57 // PF3 | Pin 94 | A3 | Pin 93 | A3 | + #define E1_MS2_PIN 4 // PG5 | Pin 1 | PWM4 | | D4 | SERVO3_PIN +#endif + +#include "pins_RAMPS.h" From 3bef7a445080fcb133dfa49aefddc0f28057b226 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Feb 2020 14:52:15 -0600 Subject: [PATCH 02/16] Add g-code quoted strings, improve stream code (#16818) --- Marlin/Configuration_adv.h | 4 + Marlin/src/gcode/host/M115.cpp | 15 +- Marlin/src/gcode/parser.cpp | 70 ++++++--- Marlin/src/gcode/parser.h | 10 ++ Marlin/src/gcode/queue.cpp | 174 ++++++++++----------- buildroot/share/tests/megaatmega1280-tests | 2 +- 6 files changed, 163 insertions(+), 112 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2c3cd38def08..2e0a5b5c50fc 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2784,6 +2784,10 @@ */ #define FASTER_GCODE_PARSER +#if ENABLED(FASTER_GCODE_PARSER) + //#define GCODE_QUOTED_STRINGS // Support for quoted string parameters +#endif + /** * CNC G-code options * Support CNC-style G-code dialects used by laser cutters, drawing machine cams, etc. diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 9123bc6e62cc..bce0c891842e 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -33,7 +33,9 @@ #endif /** - * M115: Capabilities string + * M115: Capabilities string and extended capabilities report + * If a capability is not reported, hosts should assume + * the capability is not present. */ void GcodeSuite::M115() { @@ -41,6 +43,16 @@ void GcodeSuite::M115() { #if ENABLED(EXTENDED_CAPABILITIES_REPORT) + // PAREN_COMMENTS + #if ENABLED(PAREN_COMMENTS) + cap_line(PSTR("PAREN_COMMENTS"), true); + #endif + + // QUOTED_STRINGS + #if ENABLED(GCODE_QUOTED_STRINGS) + cap_line(PSTR("QUOTED_STRINGS"), true); + #endif + // SERIAL_XON_XOFF cap_line(PSTR("SERIAL_XON_XOFF") #if ENABLED(SERIAL_XON_XOFF) @@ -171,6 +183,5 @@ void GcodeSuite::M115() { #endif ); - #endif // EXTENDED_CAPABILITIES_REPORT } diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 75f88df76b54..8218ee53d887 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -92,6 +92,26 @@ void GCodeParser::reset() { #endif } +#if ENABLED(GCODE_QUOTED_STRINGS) + + // Pass the address after the first quote (if any) + char* GCodeParser::unescape_string(char* &src) { + if (*src == '"') ++src; // Skip the leading quote + char * const out = src; // Start of the string + char *dst = src; // Prepare to unescape and terminate + for (;;) { + char c = *src++; // Get the next char + switch (c) { + case '\\': c = *src++; break; // Get the escaped char + case '"' : c = '\0'; break; // Convert bare quote to nul + } + if (!(*dst++ = c)) break; // Copy and break on nul + } + return out; + } + +#endif + // Populate all fields by parsing a single line of GCode // 58 bytes of SRAM are used to speed up seen/value void GCodeParser::parse(char *p) { @@ -229,17 +249,12 @@ void GCodeParser::parse(char *p) { #if ENABLED(EXPECTED_PRINTER_CHECK) case 16: #endif - case 23: case 28: case 30: case 117: case 118: case 928: string_arg = p; return; - default: break; - } -/* - #if ENABLED(CANCEL_OBJECTS) - if (letter == 'O') switch (codenum) { - case 1: string_arg = p; return; + case 23: case 28: case 30: case 117: case 118: case 928: + string_arg = unescape_string(p); + return; default: break; } - #endif -*/ + #if ENABLED(DEBUG_GCODE_PARSER) const bool debug = codenum == 800; #endif @@ -252,21 +267,31 @@ void GCodeParser::parse(char *p) { * This allows M0/M1 with expire time to work: "M0 S5 You Win!" * For 'M118' you must use 'E1' and 'A1' rather than just 'E' or 'A' */ + #if ENABLED(GCODE_QUOTED_STRINGS) + bool quoted_string_arg = false; + #endif string_arg = nullptr; - while (const char code = *p++) { // Get the next parameter. A NUL ends the loop + while (const char param = *p++) { // Get the next parameter. A NUL ends the loop // Special handling for M32 [P] !/path/to/file.g# // The path must be the last parameter - if (code == '!' && letter == 'M' && codenum == 32) { + if (param == '!' && letter == 'M' && codenum == 32) { string_arg = p; // Name starts after '!' char * const lb = strchr(p, '#'); // Already seen '#' as SD char (to pause buffering) if (lb) *lb = '\0'; // Safe to mark the end of the filename return; } + #if ENABLED(GCODE_QUOTED_STRINGS) + if (!quoted_string_arg && param == '"') { + quoted_string_arg = true; + string_arg = unescape_string(p); + } + #endif + // Arguments MUST be uppercase for fast GCode parsing #if ENABLED(FASTER_GCODE_PARSER) - #define PARAM_TEST WITHIN(code, 'A', 'Z') + #define PARAM_TEST WITHIN(param, 'A', 'Z') #else #define PARAM_TEST true #endif @@ -275,16 +300,22 @@ void GCodeParser::parse(char *p) { while (*p == ' ') p++; // Skip spaces between parameters & values - const bool has_num = valid_float(p); + #if ENABLED(GCODE_QUOTED_STRINGS) + const bool is_str = (*p == '"'), has_val = is_str || valid_float(p); + char * const valptr = has_val ? is_str ? unescape_string(p) : p : nullptr; + #else + const bool has_val = valid_float(p); + char * const valptr = has_val ? p : nullptr; + #endif #if ENABLED(DEBUG_GCODE_PARSER) if (debug) { - SERIAL_ECHOPAIR("Got letter ", code, " at index ", (int)(p - command_ptr - 1)); - if (has_num) SERIAL_ECHOPGM(" (has_num)"); + SERIAL_ECHOPAIR("Got param ", param, " at index ", (int)(p - command_ptr - 1)); + if (has_val) SERIAL_ECHOPGM(" (has_val)"); } #endif - if (!has_num && !string_arg) { // No value? First time, keep as string_arg + if (!has_val && !string_arg) { // No value? First time, keep as string_arg string_arg = p - 1; #if ENABLED(DEBUG_GCODE_PARSER) if (debug) SERIAL_ECHOPAIR(" string_arg: ", hex_address((void*)string_arg)); // DEBUG @@ -296,7 +327,7 @@ void GCodeParser::parse(char *p) { #endif #if ENABLED(FASTER_GCODE_PARSER) - set(code, has_num ? p : nullptr); // Set parameter exists and pointer (nullptr for no number) + set(param, valptr); // Set parameter exists and pointer (nullptr for no value) #endif } else if (!string_arg) { // Not A-Z? First time, keep as the string_arg @@ -359,7 +390,7 @@ void GCodeParser::unknown_command_warning() { if (seen(c)) { SERIAL_ECHOPAIR("Code '", c); SERIAL_ECHOPGM("':"); if (has_value()) { - SERIAL_ECHOPAIR( + SERIAL_ECHOLNPAIR( "\n float: ", value_float(), "\n long: ", value_long(), "\n ulong: ", value_ulong(), @@ -374,8 +405,7 @@ void GCodeParser::unknown_command_warning() { ); } else - SERIAL_ECHOPGM(" (no value)"); - SERIAL_ECHOLNPGM("\n"); + SERIAL_ECHOLNPGM(" (no value)"); } } } diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index cce8abe5fdfc..08f8613c1718 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -208,6 +208,12 @@ class GCodeParser { return SEEN_TEST('X') || SEEN_TEST('Y') || SEEN_TEST('Z') || SEEN_TEST('E'); } + #if ENABLED(GCODE_QUOTED_STRINGS) + static char* unescape_string(char* &src); + #else + FORCE_INLINE static char* unescape_string(char* &src) { return src; } + #endif + // Populate all fields by parsing a single line of GCode // This uses 54 bytes of SRAM to speed up seen/value static void parse(char * p); @@ -223,6 +229,9 @@ class GCodeParser { // Seen a parameter with a value static inline bool seenval(const char c) { return seen(c) && has_value(); } + // Float removes 'E' to prevent scientific notation interpretation + static inline char* value_string() { return value_ptr; } + // Float removes 'E' to prevent scientific notation interpretation static inline float value_float() { if (value_ptr) { @@ -369,6 +378,7 @@ class GCodeParser { void unknown_command_warning(); // Provide simple value accessors with default option + static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 5d317b6ca5fe..b83a211967f7 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -309,6 +309,66 @@ FORCE_INLINE bool is_M29(const char * const cmd) { // matches "M29" & "M29 ", b return m29 && !NUMERIC(m29[3]); } +#define PS_NORMAL 0 +#define PS_EOL 1 +#define PS_QUOTED 2 +#define PS_PAREN 3 +#define PS_ESC 4 + +inline void process_stream_char(const char c, uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind) { + + if (sis == PS_EOL) return; // EOL comment or overflow + + #if ENABLED(PAREN_COMMENTS) + else if (sis == PS_PAREN) { // Inline comment + if (c == ')') sis = PS_NORMAL; + return; + } + #endif + + else if (sis >= PS_ESC) // End escaped char + sis -= PS_ESC; + + else if (c == '\\') { // Start escaped char + sis += PS_ESC; + if (sis == PS_ESC) return; // Keep if quoting + } + + #if ENABLED(GCODE_QUOTED_STRINGS) + + else if (sis == PS_QUOTED) { + if (c == '"') sis = PS_NORMAL; // End quoted string + } + else if (c == '"') // Start quoted string + sis = PS_QUOTED; + + #endif + + else if (c == ';') { // Start end-of-line comment + sis = PS_EOL; + return; + } + + #if ENABLED(PAREN_COMMENTS) + else if (c == '(') { // Start inline comment + sis = PS_PAREN; + return; + } + #endif + + buff[ind++] = c; + if (ind >= MAX_CMD_SIZE - 1) + sis = PS_EOL; // Skip the rest on overflow +} + +inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind) { + sis = PS_NORMAL; + if (!ind) { thermalManager.manage_heater(); return true; } + buff[ind] = 0; + ind = 0; + return false; +} + /** * Get all commands waiting on the serial port and queue them. * Exit when the buffer is full or when no more characters are @@ -316,11 +376,8 @@ FORCE_INLINE bool is_M29(const char * const cmd) { // matches "M29" & "M29 ", b */ void GCodeQueue::get_serial_commands() { static char serial_line_buffer[NUM_SERIAL][MAX_CMD_SIZE]; - static bool serial_comment_mode[NUM_SERIAL] = { false } - #if ENABLED(PAREN_COMMENTS) - , serial_comment_paren_mode[NUM_SERIAL] = { false } - #endif - ; + + static uint8_t serial_input_state[NUM_SERIAL] = { 0 }; #if ENABLED(BINARY_FILE_TRANSFER) if (card.flag.binary_mode) { @@ -350,27 +407,15 @@ void GCodeQueue::get_serial_commands() { */ while (length < BUFSIZE && serial_data_available()) { for (uint8_t i = 0; i < NUM_SERIAL; ++i) { - int c; - if ((c = read_serial(i)) < 0) continue; - char serial_char = c; + const int c = read_serial(i); + if (c < 0) continue; - /** - * If the character ends the line - */ - if (serial_char == '\n' || serial_char == '\r') { - - // Start with comment mode off - serial_comment_mode[i] = false; - #if ENABLED(PAREN_COMMENTS) - serial_comment_paren_mode[i] = false; - #endif + const char serial_char = c; - // Skip empty lines and comments - if (!serial_count[i]) { thermalManager.manage_heater(); continue; } + if (serial_char == '\n' || serial_char == '\r') { - serial_line_buffer[i][serial_count[i]] = 0; // Terminate string - serial_count[i] = 0; // Reset buffer + process_line_done(serial_input_state[i], serial_line_buffer[i], serial_count[i]); char* command = serial_line_buffer[i]; @@ -409,16 +454,17 @@ void GCodeQueue::get_serial_commands() { return gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM), i); #endif - // Movement commands alert when stopped + // + // Movement commands give an alert when the machine is stopped + // + if (IsStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { switch (strtol(gpos + 1, nullptr, 10)) { - case 0: - case 1: + case 0: case 1: #if ENABLED(ARC_SUPPORT) - case 2: - case 3: + case 2: case 3: #endif #if ENABLED(BEZIER_CURVE_SUPPORT) case 5: @@ -453,31 +499,9 @@ void GCodeQueue::get_serial_commands() { #endif ); } - else if (serial_count[i] >= MAX_CMD_SIZE - 1) { - // Keep fetching, but ignore normal characters beyond the max length - // The command will be injected when EOL is reached - } - else if (serial_char == '\\') { // Handle escapes - // if we have one more character, copy it over - if ((c = read_serial(i)) >= 0 && !serial_comment_mode[i] - #if ENABLED(PAREN_COMMENTS) - && !serial_comment_paren_mode[i] - #endif - ) - serial_line_buffer[i][serial_count[i]++] = (char)c; - } - else { // it's not a newline, carriage return or escape char - if (serial_char == ';') serial_comment_mode[i] = true; - #if ENABLED(PAREN_COMMENTS) - else if (serial_char == '(') serial_comment_paren_mode[i] = true; - else if (serial_char == ')') serial_comment_paren_mode[i] = false; - #endif - else if (!serial_comment_mode[i] - #if ENABLED(PAREN_COMMENTS) - && ! serial_comment_paren_mode[i] - #endif - ) serial_line_buffer[i][serial_count[i]++] = serial_char; - } + else + process_stream_char(serial_char, serial_input_state[i], serial_line_buffer[i], serial_count[i]); + } // for NUM_SERIAL } // queue has space, serial has data } @@ -490,21 +514,17 @@ void GCodeQueue::get_serial_commands() { * can also interrupt buffering. */ inline void GCodeQueue::get_sdcard_commands() { - static bool sd_comment_mode = false - #if ENABLED(PAREN_COMMENTS) - , sd_comment_paren_mode = false - #endif - ; + static uint8_t sd_input_state = PS_NORMAL; if (!IS_SD_PRINTING()) return; - uint16_t sd_count = 0; + int sd_count = 0; bool card_eof = card.eof(); while (length < BUFSIZE && !card_eof) { const int16_t n = card.get(); - char sd_char = (char)n; card_eof = card.eof(); - if (card_eof || n == -1 || sd_char == '\n' || sd_char == '\r') { + const char sd_char = (char)n; + if (card_eof || n < 0 || sd_char == '\n' || sd_char == '\r') { if (card_eof) { card.printingHasFinished(); @@ -527,19 +547,10 @@ void GCodeQueue::get_serial_commands() { #endif // PRINTER_EVENT_LEDS } } - else if (n == -1) + else if (n < 0) SERIAL_ERROR_MSG(MSG_SD_ERR_READ); - sd_comment_mode = false; // for new command - #if ENABLED(PAREN_COMMENTS) - sd_comment_paren_mode = false; - #endif - - // Skip empty lines and comments - if (!sd_count) { thermalManager.manage_heater(); continue; } - - command_buffer[index_w][sd_count] = '\0'; // terminate string - sd_count = 0; // clear sd line buffer + process_line_done(sd_input_state, command_buffer[index_w], sd_count); _commit_command(false); @@ -547,24 +558,9 @@ void GCodeQueue::get_serial_commands() { recovery.cmd_sdpos = card.getIndex(); // Prime for the next _commit_command #endif } - else if (sd_count >= MAX_CMD_SIZE - 1) { - /** - * Keep fetching, but ignore normal characters beyond the max length - * The command will be injected when EOL is reached - */ - } - else { - if (sd_char == ';') sd_comment_mode = true; - #if ENABLED(PAREN_COMMENTS) - else if (sd_char == '(') sd_comment_paren_mode = true; - else if (sd_char == ')') sd_comment_paren_mode = false; - #endif - else if (!sd_comment_mode - #if ENABLED(PAREN_COMMENTS) - && ! sd_comment_paren_mode - #endif - ) command_buffer[index_w][sd_count++] = sd_char; - } + else + process_stream_char(sd_char, sd_input_state, command_buffer[index_w], sd_count); + } } diff --git a/buildroot/share/tests/megaatmega1280-tests b/buildroot/share/tests/megaatmega1280-tests index 05e262f6e73f..4e5ad253552f 100644 --- a/buildroot/share/tests/megaatmega1280-tests +++ b/buildroot/share/tests/megaatmega1280-tests @@ -19,7 +19,7 @@ restore_configs opt_set LCD_LANGUAGE an opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \ MESH_BED_LEVELING ENABLE_LEVELING_FADE_HEIGHT MESH_G28_REST_ORIGIN \ - G26_MESH_VALIDATION MESH_EDIT_MENU + G26_MESH_VALIDATION MESH_EDIT_MENU GCODE_QUOTED_STRINGS exec_test $1 $2 "Spindle, MESH_BED_LEVELING, and LCD" From fa4a6cdb5c05abc812a9dce5f20956c0dd42386a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Feb 2020 16:33:21 -0600 Subject: [PATCH 03/16] Fix out-of-order M0 after SD printing Fixes #14774 Co-Authored-By: tol2cj --- Marlin/src/gcode/queue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index b83a211967f7..c01a92ab10c3 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -536,7 +536,7 @@ void GCodeQueue::get_serial_commands() { #if ENABLED(PRINTER_EVENT_LEDS) printerEventLEDs.onPrintCompleted(); #if HAS_RESUME_CONTINUE - inject_P(PSTR("M0 Q S" + enqueue_now_P(PSTR("M0 Q S" #if HAS_LCD_MENU "1800" #else @@ -544,7 +544,7 @@ void GCodeQueue::get_serial_commands() { #endif )); #endif - #endif // PRINTER_EVENT_LEDS + #endif } } else if (n < 0) From 3f87f912c5b78a08b17dca07840333c882ceada2 Mon Sep 17 00:00:00 2001 From: proferabg Date: Mon, 10 Feb 2020 17:48:22 -0500 Subject: [PATCH 04/16] Enable hotend / bed PID separately in ExtUI (#16827) --- Marlin/src/lcd/extensible_ui/ui_api.cpp | 33 ++++++++++++++++--------- Marlin/src/lcd/extensible_ui/ui_api.h | 9 ++++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index 21c99d94a6ec..31d195c95de4 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -894,42 +894,51 @@ namespace ExtUI { float getFeedrate_percent() { return feedrate_percentage; } - #if HAS_PID_HEATING + #if ENABLED(PIDTEMP) float getPIDValues_Kp(const extruder_t tool) { return PID_PARAM(Kp, tool); } + float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); } + float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); } + + void setPIDValues(const float p, const float i, const float d, extruder_t tool) { + thermalManager.temp_hotend[tool].pid.Kp = p; + thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i); + thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d); + thermalManager.updatePID(); + } + + void startPIDTune(const float temp, extruder_t tool){ + thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true); + } + #endif + + #if ENABLED(PIDTEMPBED) float getBedPIDValues_Kp() { return thermalManager.temp_bed.pid.Kp; } + float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); } + float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); } - - void setPIDValues(const float p, const float i, const float d, extruder_t tool) { - thermalManager.temp_hotend[tool].pid.Kp = p; - thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i); - thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d); - thermalManager.updatePID(); - } + void setBedPIDValues(const float p, const float i, const float d) { thermalManager.temp_bed.pid.Kp = p; thermalManager.temp_bed.pid.Ki = scalePID_i(i); thermalManager.temp_bed.pid.Kd = scalePID_d(d); thermalManager.updatePID(); } - - void startPIDTune(const float temp, extruder_t tool){ - thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true); - } + void startBedPIDTune(const float temp) { thermalManager.PID_autotune(temp, H_BED, 4, true); } diff --git a/Marlin/src/lcd/extensible_ui/ui_api.h b/Marlin/src/lcd/extensible_ui/ui_api.h index 4f88b4606e14..d99cfcedb4f6 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.h +++ b/Marlin/src/lcd/extensible_ui/ui_api.h @@ -249,16 +249,19 @@ namespace ExtUI { #endif #endif - #if HAS_PID_HEATING + #if ENABLED(PIDTEMP) float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); float getPIDValues_Kd(const extruder_t); + void setPIDValues(const float, const float, const float, extruder_t); + void startPIDTune(const float, extruder_t); + #endif + + #if ENABLED(PIDTEMPBED) float getBedPIDValues_Kp(); float getBedPIDValues_Ki(); float getBedPIDValues_Kd(); - void setPIDValues(const float, const float, const float, extruder_t); void setBedPIDValues(const float, const float, const float); - void startPIDTune(const float, extruder_t); void startBedPIDTune(const float); #endif From d8b2726fd3248c90da719b2ec1bf87eb0bb5aadd Mon Sep 17 00:00:00 2001 From: darksiah Date: Mon, 10 Feb 2020 19:49:36 -0300 Subject: [PATCH 05/16] Fix MKS Robin Nano platformio.ini entry (#16826) --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 2e57e7d773fa..db8f5dd6b7d7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -489,7 +489,7 @@ build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py build_unflags = -std=gnu++11 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_nano.py src_filter = ${common.default_src_filter} + -lib_deps = +lib_deps = ${common.lib_deps} SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip lib_ignore = Adafruit NeoPixel, SPI From 2836834d7ef2043ccd80b8a76560c21f2eb8fe74 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Feb 2020 16:58:21 -0600 Subject: [PATCH 06/16] Unify step pulse timing of ISR / babystep (#16813) --- Marlin/src/module/stepper.cpp | 160 ++++++++++++++++------------------ 1 file changed, 73 insertions(+), 87 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index c739abe26a42..a4a457c0a78a 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -402,6 +402,7 @@ constexpr uint32_t NS_TO_PULSE_TIMER_TICKS(uint32_t NS) { return (NS + (NS_PER_P #define PULSE_HIGH_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_HIGH_NS - _MIN(_MIN_PULSE_HIGH_NS, TIMER_SETUP_NS))) #define PULSE_LOW_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_LOW_NS - _MIN(_MIN_PULSE_LOW_NS, TIMER_SETUP_NS))) +#define USING_TIMED_PULSE() hal_timer_t end_tick_count = 0 #define START_TIMED_PULSE(DIR) (end_tick_count = HAL_timer_get_count(PULSE_TIMER_NUM) + PULSE_##DIR##_TICK_COUNT) #define AWAIT_TIMED_PULSE() while (HAL_timer_get_count(PULSE_TIMER_NUM) < end_tick_count) { } #define START_HIGH_PULSE() START_TIMED_PULSE(HIGH) @@ -409,6 +410,18 @@ constexpr uint32_t NS_TO_PULSE_TIMER_TICKS(uint32_t NS) { return (NS + (NS_PER_P #define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE() #define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE() +#if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 + #define DIR_WAIT_BEFORE() DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY) +#else + #define DIR_WAIT_BEFORE() +#endif + +#if MINIMUM_STEPPER_POST_DIR_DELAY > 0 + #define DIR_WAIT_AFTER() DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY) +#else + #define DIR_WAIT_AFTER() +#endif + void Stepper::wake_up() { // TCNT1 = 0; ENABLE_STEPPER_DRIVER_INTERRUPT(); @@ -423,9 +436,7 @@ void Stepper::wake_up() { */ void Stepper::set_directions() { - #if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 - DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); - #endif + DIR_WAIT_BEFORE(); #define SET_STEP_DIR(A) \ if (motor_direction(_AXIS(A))) { \ @@ -494,10 +505,7 @@ void Stepper::set_directions() { } #endif - // A small delay may be needed after changing direction - #if MINIMUM_STEPPER_POST_DIR_DELAY > 0 - DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); - #endif + DIR_WAIT_AFTER(); } #if ENABLED(S_CURVE_ACCELERATION) @@ -1488,12 +1496,12 @@ void Stepper::stepper_pulse_phase_isr() { // Take multiple steps per interrupt (For high speed moves) #if ISR_MULTI_STEPS bool firstStep = true; - hal_timer_t end_tick_count = 0; + USING_TIMED_PULSE(); #endif xyze_bool_t step_needed{0}; do { - #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP + #define _APPLY_STEP(AXIS, INV, ALWAYS) AXIS ##_APPLY_STEP(INV, ALWAYS) #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN // Determine if a pulse is needed using Bresenham @@ -1509,14 +1517,14 @@ void Stepper::stepper_pulse_phase_isr() { // Start an active pulse, if Bresenham says so, and update position #define PULSE_START(AXIS) do{ \ if (step_needed[_AXIS(AXIS)]) { \ - _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), 0); \ + _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), 0); \ } \ }while(0) // Stop an active pulse, if any, and adjust error term #define PULSE_STOP(AXIS) do { \ if (step_needed[_AXIS(AXIS)]) { \ - _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), 0); \ + _APPLY_STEP(AXIS, _INVERT_STEP_PIN(AXIS), 0); \ } \ }while(0) @@ -1978,9 +1986,7 @@ uint32_t Stepper::stepper_block_phase_isr() { else interval = LA_ADV_NEVER; - #if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 - DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); - #endif + DIR_WAIT_BEFORE(); #if ENABLED(MIXING_EXTRUDER) // We don't know which steppers will be stepped because LA loop follows, @@ -1996,17 +2002,14 @@ uint32_t Stepper::stepper_block_phase_isr() { REV_E_DIR(stepper_extruder); #endif - // A small delay may be needed after changing direction - #if MINIMUM_STEPPER_POST_DIR_DELAY > 0 - DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); - #endif + DIR_WAIT_AFTER(); //const hal_timer_t added_step_ticks = hal_timer_t(ADDED_STEP_TICKS); // Step E stepper if we have steps #if ISR_MULTI_STEPS bool firstStep = true; - hal_timer_t end_tick_count = 0; + USING_TIMED_PULSE(); #endif while (LA_steps) { @@ -2424,57 +2427,52 @@ void Stepper::report_positions() { #if ENABLED(BABYSTEPPING) - #if MINIMUM_STEPPER_PULSE - #define STEP_PULSE_CYCLES ((MINIMUM_STEPPER_PULSE) * CYCLES_PER_MICROSECOND) - #else - #define STEP_PULSE_CYCLES 0 - #endif - - #if ENABLED(DELTA) - #define CYCLES_EATEN_BABYSTEP (2 * 15) - #else - #define CYCLES_EATEN_BABYSTEP 0 - #endif - #define EXTRA_CYCLES_BABYSTEP (STEP_PULSE_CYCLES - (CYCLES_EATEN_BABYSTEP)) - #define _ENABLE_AXIS(AXIS) ENABLE_AXIS_## AXIS() #define _READ_DIR(AXIS) AXIS ##_DIR_READ() #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) - #if EXTRA_CYCLES_BABYSTEP > 20 - #define _SAVE_START const hal_timer_t pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM) - #define _PULSE_WAIT while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } - #else - #define _SAVE_START NOOP - #if EXTRA_CYCLES_BABYSTEP > 0 - #define _PULSE_WAIT DELAY_NS(EXTRA_CYCLES_BABYSTEP * NANOSECONDS_PER_CYCLE) - #elif ENABLED(DELTA) - #define _PULSE_WAIT DELAY_US(2); - #elif STEP_PULSE_CYCLES > 0 - #define _PULSE_WAIT NOOP - #else - #define _PULSE_WAIT DELAY_US(4); - #endif - #endif - - #define BABYSTEP_AXIS(AXIS, INVERT, DIR) { \ + #if DISABLED(DELTA) + #define BABYSTEP_AXIS(AXIS, INV, DIR) do{ \ const uint8_t old_dir = _READ_DIR(AXIS); \ _ENABLE_AXIS(AXIS); \ - DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); \ - _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^DIR^INVERT); \ - DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); \ - _SAVE_START; \ - _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ - _PULSE_WAIT; \ - _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \ + DIR_WAIT_BEFORE(); \ + _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^DIR^INV); \ + DIR_WAIT_AFTER(); \ + USING_TIMED_PULSE(); \ + START_HIGH_PULSE(); \ + _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), true); \ + AWAIT_HIGH_PULSE(); \ + _APPLY_STEP(AXIS, _INVERT_STEP_PIN(AXIS), true); \ _APPLY_DIR(AXIS, old_dir); \ - } + }while(0) + #endif + + #if IS_CORE + #define BABYSTEP_CORE(A, B, INV, DIR) do{ \ + const xy_byte_t old_dir = { _READ_DIR(A), _READ_DIR(B) }; \ + _ENABLE_AXIS(A); _ENABLE_AXIS(B); \ + DIR_WAIT_BEFORE(); \ + _APPLY_DIR(A, _INVERT_DIR(A)^DIR^INV); \ + _APPLY_DIR(B, _INVERT_DIR(B)^DIR^INV^(CORESIGN(1)<0)); \ + DIR_WAIT_AFTER(); \ + USING_TIMED_PULSE(); \ + START_HIGH_PULSE(); \ + _APPLY_STEP(A, !_INVERT_STEP_PIN(A), true); \ + _APPLY_STEP(B, !_INVERT_STEP_PIN(B), true); \ + AWAIT_HIGH_PULSE(); \ + _APPLY_STEP(A, _INVERT_STEP_PIN(A), true); \ + _APPLY_STEP(B, _INVERT_STEP_PIN(B), true); \ + _APPLY_DIR(A, old_dir.a); _APPLY_DIR(B, old_dir.b); \ + }while(0) + #endif // MUST ONLY BE CALLED BY AN ISR, // No other ISR should ever interrupt this! void Stepper::babystep(const AxisEnum axis, const bool direction) { - cli(); + DISABLE_ISRS(); + + USING_TIMED_PULSE(); switch (axis) { @@ -2482,11 +2480,9 @@ void Stepper::report_positions() { case X_AXIS: #if CORE_IS_XY - BABYSTEP_AXIS(X, false, direction); - BABYSTEP_AXIS(Y, false, direction); + BABYSTEP_CORE(X, Y, false, direction); #elif CORE_IS_XZ - BABYSTEP_AXIS(X, false, direction); - BABYSTEP_AXIS(Z, false, direction); + BABYSTEP_CORE(X, Z, false, direction); #else BABYSTEP_AXIS(X, false, direction); #endif @@ -2494,11 +2490,9 @@ void Stepper::report_positions() { case Y_AXIS: #if CORE_IS_XY - BABYSTEP_AXIS(X, false, direction); - BABYSTEP_AXIS(Y, false, direction^(CORESIGN(1)<0)); + BABYSTEP_CORE(X, Y, false, direction); #elif CORE_IS_YZ - BABYSTEP_AXIS(Y, false, direction); - BABYSTEP_AXIS(Z, false, direction^(CORESIGN(1)<0)); + BABYSTEP_CORE(Y, Z, false, direction); #else BABYSTEP_AXIS(Y, false, direction); #endif @@ -2509,13 +2503,9 @@ void Stepper::report_positions() { case Z_AXIS: { #if CORE_IS_XZ - BABYSTEP_AXIS(X, BABYSTEP_INVERT_Z, direction); - BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z, direction^(CORESIGN(1)<0)); - + BABYSTEP_CORE(X, Z, BABYSTEP_INVERT_Z, direction); #elif CORE_IS_YZ - BABYSTEP_AXIS(Y, BABYSTEP_INVERT_Z, direction); - BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z, direction^(CORESIGN(1)<0)); - + BABYSTEP_CORE(Y, Z, BABYSTEP_INVERT_Z, direction); #elif DISABLED(DELTA) BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z, direction); @@ -2527,38 +2517,32 @@ void Stepper::report_positions() { ENABLE_AXIS_Y(); ENABLE_AXIS_Z(); - #if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 - DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY); - #endif + DIR_WAIT_BEFORE(); - const uint8_t old_x_dir_pin = X_DIR_READ(), - old_y_dir_pin = Y_DIR_READ(), - old_z_dir_pin = Z_DIR_READ(); + const xyz_byte_t old_dir = { X_DIR_READ(), Y_DIR_READ(), Z_DIR_READ() }; X_DIR_WRITE(INVERT_X_DIR ^ z_direction); Y_DIR_WRITE(INVERT_Y_DIR ^ z_direction); Z_DIR_WRITE(INVERT_Z_DIR ^ z_direction); - #if MINIMUM_STEPPER_POST_DIR_DELAY > 0 - DELAY_NS(MINIMUM_STEPPER_POST_DIR_DELAY); - #endif + DIR_WAIT_AFTER(); - _SAVE_START; + START_HIGH_PULSE(); X_STEP_WRITE(!INVERT_X_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN); Z_STEP_WRITE(!INVERT_Z_STEP_PIN); - _PULSE_WAIT; + AWAIT_HIGH_PULSE(); X_STEP_WRITE(INVERT_X_STEP_PIN); Y_STEP_WRITE(INVERT_Y_STEP_PIN); Z_STEP_WRITE(INVERT_Z_STEP_PIN); // Restore direction bits - X_DIR_WRITE(old_x_dir_pin); - Y_DIR_WRITE(old_y_dir_pin); - Z_DIR_WRITE(old_z_dir_pin); + X_DIR_WRITE(old_dir.x); + Y_DIR_WRITE(old_dir.y); + Z_DIR_WRITE(old_dir.z); #endif @@ -2566,7 +2550,9 @@ void Stepper::report_positions() { default: break; } - sei(); + + START_LOW_PULSE(); AWAIT_LOW_PULSE(); // Prevent Stepper::ISR pulsing too soon + ENABLE_ISRS(); // Now it's ok for the ISR to run } #endif // BABYSTEPPING From b26f7fca3fb085a502195319e04101b38d61dba1 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 11 Feb 2020 00:04:03 +0000 Subject: [PATCH 07/16] [cron] Bump distribution date (2020-02-11) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index fe72b696404c..1d263f0eeaee 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-02-10" + #define STRING_DISTRIBUTION_DATE "2020-02-11" #endif /** From d5790e09a5cff1a4088e7d6828b7a02175539f63 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Tue, 11 Feb 2020 09:05:58 +0100 Subject: [PATCH 08/16] Update SAMD51 EEPROM repo link (#16832) --- Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h index d0bc2275bf6c..ddea64f2d01f 100644 --- a/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h @@ -44,7 +44,7 @@ #endif #if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM) - #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Activator" + #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Manager/releases" #endif #if HAS_TMC_SW_SERIAL From 71539bcbeb68284663d0627207ffd5a9a377e920 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 02:29:47 -0600 Subject: [PATCH 09/16] Undo driver type auto-assignment for now Good general concept but needs more time to develop and group with a stepper suite. --- Marlin/Configuration.h | 5 +++++ Marlin/src/pins/pins.h | 22 ---------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0a9df1feca0a..fd3687a7fc45 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -674,6 +674,11 @@ //#define X_DRIVER_TYPE A4988 //#define Y_DRIVER_TYPE A4988 //#define Z_DRIVER_TYPE A4988 +//#define X2_DRIVER_TYPE A4988 +//#define Y2_DRIVER_TYPE A4988 +//#define Z2_DRIVER_TYPE A4988 +//#define Z3_DRIVER_TYPE A4988 +//#define Z4_DRIVER_TYPE A4988 //#define E0_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index e05bfeed0498..941b21bbbf87 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -1189,18 +1189,12 @@ #define _PEXI(p,q) __PEXI(p,q) #define __EPIN(p,q) E##p##_##q##_PIN #define _EPIN(p,q) __EPIN(p,q) -#define __EDRV(p) E##p##_DRIVER_TYPE -#define _EDRV(p) __EDRV(p) #define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN) // The X2 axis, if any, should be the next open extruder port #define X2_E_INDEX E_STEPPERS #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) - #ifndef X2_DRIVER_TYPE - #define X2_DRIVER_TYPE _EDRV(X2_E_INDEX) - #endif - #ifndef X2_STEP_PIN #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR) @@ -1274,10 +1268,6 @@ // The Y2 axis, if any, should be the next open extruder port #if ENABLED(Y_DUAL_STEPPER_DRIVERS) - #ifndef Y2_DRIVER_TYPE - #define Y2_DRIVER_TYPE _EDRV(Y2_E_INDEX) - #endif - #ifndef Y2_STEP_PIN #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR) @@ -1346,10 +1336,6 @@ // The Z2 axis, if any, should be the next open extruder port #if NUM_Z_STEPPER_DRIVERS >= 2 - #ifndef Z2_DRIVER_TYPE - #define Z2_DRIVER_TYPE _EDRV(Z2_E_INDEX) - #endif - #ifndef Z2_STEP_PIN #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR) @@ -1417,10 +1403,6 @@ #endif #if NUM_Z_STEPPER_DRIVERS >= 3 - #ifndef Z3_DRIVER_TYPE - #define Z3_DRIVER_TYPE _EDRV(Z3_E_INDEX) - #endif - #ifndef Z3_STEP_PIN #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP) #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR) @@ -1488,10 +1470,6 @@ #endif #if NUM_Z_STEPPER_DRIVERS >= 4 - #ifndef Z4_DRIVER_TYPE - #define Z4_DRIVER_TYPE _EDRV(Z4_E_INDEX) - #endif - #ifndef Z4_STEP_PIN #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP) #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR) From e442663e2aaaa5f71d16c947b3ace277ab80fbea Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 04:15:10 -0600 Subject: [PATCH 10/16] No Z sensorless req'd if homing with probe Fixes #16674 --- Marlin/src/inc/SanityCheck.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4c1dd38471a7..d14551c4b4a1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2239,11 +2239,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS // Sensorless homing is required for both combined steppers in an H-bot #if CORE_IS_XY && X_SENSORLESS != Y_SENSORLESS - #error "CoreXY requires both X and Y to use sensorless homing if either does." -#elif CORE_IS_XZ && X_SENSORLESS != Z_SENSORLESS - #error "CoreXZ requires both X and Z to use sensorless homing if either does." -#elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS - #error "CoreYZ requires both Y and Z to use sensorless homing if either does." + #error "CoreXY requires both X and Y to use sensorless homing if either one does." +#elif CORE_IS_XZ && X_SENSORLESS != Z_SENSORLESS && !HOMING_Z_WITH_PROBE + #error "CoreXZ requires both X and Z to use sensorless homing if either one does." +#elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS && !HOMING_Z_WITH_PROBE + #error "CoreYZ requires both Y and Z to use sensorless homing if either one does." #endif // Other TMC feature requirements From 1c556cd90dc2ee5d8643bbe9bfbe363b8bf57d0e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 07:40:07 -0600 Subject: [PATCH 11/16] Recommend Z Safe Homing Co-Authored-By: Vertabreaker --- Marlin/src/inc/SanityCheck.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index d14551c4b4a1..a94300d45e84 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1227,6 +1227,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Z_PROBE_LOW_POINT must be less than or equal to 0." #endif + #if HOMING_Z_WITH_PROBE && DISABLED(Z_SAFE_HOMING) + #error "Z_SAFE_HOMING is recommended when homing with a probe. Enable it or comment out this line to continue." + #endif + #else /** From 189c101793c72780fdff2b8cd693d4a53040a0e8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 08:52:11 -0600 Subject: [PATCH 12/16] Use prior babystep delay method (#16833) --- Marlin/src/module/stepper.cpp | 85 +++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index a4a457c0a78a..bc08e3537747 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2432,47 +2432,78 @@ void Stepper::report_positions() { #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) + #if MINIMUM_STEPPER_PULSE + #define STEP_PULSE_CYCLES ((MINIMUM_STEPPER_PULSE) * CYCLES_PER_MICROSECOND) + #else + #define STEP_PULSE_CYCLES 0 + #endif + + #if ENABLED(DELTA) + #define CYCLES_EATEN_BABYSTEP (2 * 15) + #else + #define CYCLES_EATEN_BABYSTEP 0 + #endif + #define EXTRA_CYCLES_BABYSTEP (STEP_PULSE_CYCLES - (CYCLES_EATEN_BABYSTEP)) + + #if EXTRA_CYCLES_BABYSTEP > 20 + #define _SAVE_START() const hal_timer_t pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM) + #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } + #else + #define _SAVE_START() NOOP + #if EXTRA_CYCLES_BABYSTEP > 0 + #define _PULSE_WAIT() DELAY_NS(EXTRA_CYCLES_BABYSTEP * NANOSECONDS_PER_CYCLE) + #elif ENABLED(DELTA) + #define _PULSE_WAIT() DELAY_US(2); + #elif STEP_PULSE_CYCLES > 0 + #define _PULSE_WAIT() NOOP + #else + #define _PULSE_WAIT() DELAY_US(4); + #endif + #endif + #if DISABLED(DELTA) + #define BABYSTEP_AXIS(AXIS, INV, DIR) do{ \ const uint8_t old_dir = _READ_DIR(AXIS); \ _ENABLE_AXIS(AXIS); \ DIR_WAIT_BEFORE(); \ _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^DIR^INV); \ DIR_WAIT_AFTER(); \ - USING_TIMED_PULSE(); \ - START_HIGH_PULSE(); \ + _SAVE_START(); \ _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), true); \ - AWAIT_HIGH_PULSE(); \ - _APPLY_STEP(AXIS, _INVERT_STEP_PIN(AXIS), true); \ + _PULSE_WAIT(); \ + _APPLY_STEP(AXIS, _INVERT_STEP_PIN(AXIS), true); \ + DIR_WAIT_BEFORE(); \ _APPLY_DIR(AXIS, old_dir); \ + DIR_WAIT_AFTER(); \ }while(0) - #endif - #if IS_CORE - #define BABYSTEP_CORE(A, B, INV, DIR) do{ \ + #elif IS_CORE + + #define BABYSTEP_CORE(A, B, INV, DIR) do{ \ const xy_byte_t old_dir = { _READ_DIR(A), _READ_DIR(B) }; \ - _ENABLE_AXIS(A); _ENABLE_AXIS(B); \ - DIR_WAIT_BEFORE(); \ - _APPLY_DIR(A, _INVERT_DIR(A)^DIR^INV); \ - _APPLY_DIR(B, _INVERT_DIR(B)^DIR^INV^(CORESIGN(1)<0)); \ - DIR_WAIT_AFTER(); \ - USING_TIMED_PULSE(); \ - START_HIGH_PULSE(); \ - _APPLY_STEP(A, !_INVERT_STEP_PIN(A), true); \ - _APPLY_STEP(B, !_INVERT_STEP_PIN(B), true); \ - AWAIT_HIGH_PULSE(); \ - _APPLY_STEP(A, _INVERT_STEP_PIN(A), true); \ - _APPLY_STEP(B, _INVERT_STEP_PIN(B), true); \ - _APPLY_DIR(A, old_dir.a); _APPLY_DIR(B, old_dir.b); \ + _ENABLE_AXIS(A); _ENABLE_AXIS(B); \ + DIR_WAIT_BEFORE(); \ + _APPLY_DIR(A, _INVERT_DIR(A)^DIR^INV); \ + _APPLY_DIR(B, _INVERT_DIR(B)^DIR^INV^(CORESIGN(1)<0)); \ + DIR_WAIT_AFTER(); \ + _SAVE_START(); \ + _APPLY_STEP(A, !_INVERT_STEP_PIN(A), true); \ + _APPLY_STEP(B, !_INVERT_STEP_PIN(B), true); \ + _PULSE_WAIT(); \ + _APPLY_STEP(A, _INVERT_STEP_PIN(A), true); \ + _APPLY_STEP(B, _INVERT_STEP_PIN(B), true); \ + DIR_WAIT_BEFORE(); \ + _APPLY_DIR(A, old_dir.a); _APPLY_DIR(B, old_dir.b); \ + DIR_WAIT_AFTER(); \ }while(0) + #endif // MUST ONLY BE CALLED BY AN ISR, // No other ISR should ever interrupt this! void Stepper::babystep(const AxisEnum axis, const bool direction) { - DISABLE_ISRS(); - - USING_TIMED_PULSE(); + cli(); switch (axis) { @@ -2527,13 +2558,13 @@ void Stepper::report_positions() { DIR_WAIT_AFTER(); - START_HIGH_PULSE(); + _SAVE_START(); X_STEP_WRITE(!INVERT_X_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN); Z_STEP_WRITE(!INVERT_Z_STEP_PIN); - AWAIT_HIGH_PULSE(); + _PULSE_WAIT(); X_STEP_WRITE(INVERT_X_STEP_PIN); Y_STEP_WRITE(INVERT_Y_STEP_PIN); @@ -2550,9 +2581,7 @@ void Stepper::report_positions() { default: break; } - - START_LOW_PULSE(); AWAIT_LOW_PULSE(); // Prevent Stepper::ISR pulsing too soon - ENABLE_ISRS(); // Now it's ok for the ISR to run + sei(); } #endif // BABYSTEPPING From 7b02a62da82034e9c1e2a6098f1bca39e06811a5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 09:05:45 -0600 Subject: [PATCH 13/16] Fix up tests --- Marlin/src/inc/Conditionals_LCD.h | 2 +- buildroot/share/tests/DUE-tests | 3 ++- buildroot/share/tests/LPC1769-tests | 2 +- buildroot/share/tests/megaatmega2560-tests | 6 +++--- buildroot/share/tests/teensy35-tests | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7f387914d362..67130d21e45f 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -490,7 +490,7 @@ #endif /** - * Set a flag for a servo probe + * Set a flag for a servo probe (or BLTouch) */ #define HAS_Z_SERVO_PROBE (defined(Z_PROBE_SERVO_NR) && Z_PROBE_SERVO_NR >= 0) diff --git a/buildroot/share/tests/DUE-tests b/buildroot/share/tests/DUE-tests index e3ef7d453495..cfce93a92eeb 100755 --- a/buildroot/share/tests/DUE-tests +++ b/buildroot/share/tests/DUE-tests @@ -37,7 +37,8 @@ exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), EXTENSIBLE_UI, S-Curve, many restore_configs opt_set MOTHERBOARD BOARD_RADDS opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \ - Z_MULTI_ENDSTOPS Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS + Z_MULTI_ENDSTOPS Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS \ + Z_SAFE_HOMING #TOUCH_UI_FTDI_EVE LCD_ALEPHOBJECTS_CLCD_UI OTHER_PIN_LAYOUT opt_set NUM_Z_STEPPER_DRIVERS 3 opt_add Z2_MAX_ENDSTOP_INVERTING false diff --git a/buildroot/share/tests/LPC1769-tests b/buildroot/share/tests/LPC1769-tests index 6b7ef9725f3c..0cdb2f313b55 100755 --- a/buildroot/share/tests/LPC1769-tests +++ b/buildroot/share/tests/LPC1769-tests @@ -49,7 +49,7 @@ opt_set Y_DRIVER_TYPE TMC2130 opt_set Z_DRIVER_TYPE TMC2130 opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT \ TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP_XY STEALTHCHOP_Z HYBRID_THRESHOLD \ - SENSORLESS_PROBING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG + SENSORLESS_PROBING Z_SAFE_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY TMC_DEBUG opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN PSU_CONTROL exec_test $1 $2 "Cohesion3D Remix DELTA + ABL Bilinear + EEPROM + SENSORLESS_PROBING" diff --git a/buildroot/share/tests/megaatmega2560-tests b/buildroot/share/tests/megaatmega2560-tests index 039e023e314b..9509806d1a1a 100755 --- a/buildroot/share/tests/megaatmega2560-tests +++ b/buildroot/share/tests/megaatmega2560-tests @@ -108,7 +108,7 @@ opt_set NUM_SERVOS 1 opt_enable ZONESTAR_LCD Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE BOOT_MARLIN_LOGO_ANIMATED \ AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \ - PRUSA_MMU2 MMU2_MENUS NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE + PRUSA_MMU2 MMU2_MENUS NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING exec_test $1 $2 "RAMPS | ZONESTAR_LCD | MMU2 | Servo Probe | ABL 3-Pt | Debug Leveling | EEPROM | G38 ..." # @@ -182,7 +182,7 @@ opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \ REPRAP_DISCOUNT_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \ ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \ FIX_MOUNTED_PROBE AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE FILAMENT_WIDTH_SENSOR \ - SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \ + Z_SAFE_HOMING SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \ SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT ADVANCED_OK M114_DETAIL \ VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS EXTRA_FAN_SPEED FWRETRACT opt_set FAN_MIN_PWM 50 @@ -345,7 +345,7 @@ exec_test $1 $2 "RAMPS 1.3 | DELTA | FLSUN AC Config" use_example_configs SCARA/Morgan opt_set LCD_LANGUAGE es opt_enable USE_ZMIN_PLUG FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR PAUSE_BEFORE_DEPLOY_STOW \ - MKS_12864OLED EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ + MKS_12864OLED EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL Z_SAFE_HOMING \ STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD SENSORLESS_HOMING SQUARE_WAVE_STEPPING opt_set X_MAX_ENDSTOP_INVERTING false opt_set X_DRIVER_TYPE TMC2209 diff --git a/buildroot/share/tests/teensy35-tests b/buildroot/share/tests/teensy35-tests index e367e7ca4728..f2a098e7cd1c 100755 --- a/buildroot/share/tests/teensy35-tests +++ b/buildroot/share/tests/teensy35-tests @@ -36,7 +36,7 @@ exec_test $1 $2 "Teensy3.5 with many features" # restore_configs opt_set MOTHERBOARD BOARD_TEENSY35_36 -opt_enable EEPROM_SETTINGS Z_PROBE_SLED AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE GCODE_MACROS +opt_enable EEPROM_SETTINGS Z_PROBE_SLED Z_SAFE_HOMING AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE GCODE_MACROS exec_test $1 $2 "Sled Z Probe with Linear leveling" # From fa6e7cb733d07bc3f387987ea3f44ec75986eb0c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 01:13:02 -0600 Subject: [PATCH 14/16] Function-style critical section macros --- Marlin/src/HAL/HAL_AVR/HAL.h | 4 ++-- Marlin/src/HAL/HAL_DUE/HAL.h | 4 ++-- Marlin/src/HAL/HAL_DUE/InterruptVectors.cpp | 8 ++++---- Marlin/src/HAL/HAL_ESP32/HAL.h | 4 ++-- Marlin/src/HAL/HAL_LINUX/HAL.h | 4 ++-- Marlin/src/HAL/HAL_LPC1768/HAL.h | 4 ++-- Marlin/src/HAL/HAL_SAMD51/HAL.h | 4 ++-- Marlin/src/HAL/HAL_STM32/HAL.h | 4 ++-- Marlin/src/HAL/HAL_STM32F1/HAL.h | 4 ++-- Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h | 4 ++-- Marlin/src/HAL/HAL_TEENSY31_32/HAL.h | 4 ++-- Marlin/src/HAL/HAL_TEENSY35_36/HAL.h | 4 ++-- Marlin/src/HAL/shared/servo.cpp | 4 ++-- Marlin/src/feature/Max7219_Debug_LEDs.cpp | 20 ++++++++++---------- Marlin/src/libs/buzzer.cpp | 8 ++++---- 15 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h index ccbeec941ddd..025516981955 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.h +++ b/Marlin/src/HAL/HAL_AVR/HAL.h @@ -53,8 +53,8 @@ //#define analogInputToDigitalPin(IO) IO #ifndef CRITICAL_SECTION_START - #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli() - #define CRITICAL_SECTION_END SREG = _sreg + #define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli() + #define CRITICAL_SECTION_END() SREG = _sreg #endif #define ISRS_ENABLED() TEST(SREG, SREG_I) #define ENABLE_ISRS() sei() diff --git a/Marlin/src/HAL/HAL_DUE/HAL.h b/Marlin/src/HAL/HAL_DUE/HAL.h index ed9b1f3894f4..97b94b5db234 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL.h +++ b/Marlin/src/HAL/HAL_DUE/HAL.h @@ -119,8 +119,8 @@ typedef int8_t pin_t; // // Interrupts // -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/HAL_DUE/InterruptVectors.cpp b/Marlin/src/HAL/HAL_DUE/InterruptVectors.cpp index cf523cfe3b45..7964f2d1f680 100644 --- a/Marlin/src/HAL/HAL_DUE/InterruptVectors.cpp +++ b/Marlin/src/HAL/HAL_DUE/InterruptVectors.cpp @@ -63,13 +63,13 @@ static pfnISR_Handler* get_relocated_table_addr() { memcpy(&ram_tab, romtab, sizeof(ram_tab)); // Disable global interrupts - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); // Set the vector table base address to the SRAM copy SCB->VTOR = (uint32_t)(&ram_tab); // Reenable interrupts - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); // Return the address of the table return (pfnISR_Handler*)(&ram_tab); @@ -80,7 +80,7 @@ pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler) { pfnISR_Handler *isrtab = get_relocated_table_addr(); // Disable global interrupts - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); // Get the original handler pfnISR_Handler oldHandler = isrtab[irq + 16]; @@ -89,7 +89,7 @@ pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler) { isrtab[irq + 16] = newHandler; // Reenable interrupts - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); // Return the original one return oldHandler; diff --git a/Marlin/src/HAL/HAL_ESP32/HAL.h b/Marlin/src/HAL/HAL_ESP32/HAL.h index b59722d87760..a04343b69e5a 100644 --- a/Marlin/src/HAL/HAL_ESP32/HAL.h +++ b/Marlin/src/HAL/HAL_ESP32/HAL.h @@ -65,8 +65,8 @@ extern portMUX_TYPE spinlock; #define NUM_SERIAL 1 #endif -#define CRITICAL_SECTION_START portENTER_CRITICAL(&spinlock) -#define CRITICAL_SECTION_END portEXIT_CRITICAL(&spinlock) +#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) +#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) #define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL) #define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock) #define DISABLE_ISRS() portENTER_CRITICAL(&spinlock) diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.h b/Marlin/src/HAL/HAL_LINUX/HAL.h index fffe11111113..0475c953c356 100644 --- a/Marlin/src/HAL/HAL_LINUX/HAL.h +++ b/Marlin/src/HAL/HAL_LINUX/HAL.h @@ -72,8 +72,8 @@ extern HalSerial usb_serial; // // Interrupts // -#define CRITICAL_SECTION_START -#define CRITICAL_SECTION_END +#define CRITICAL_SECTION_START() +#define CRITICAL_SECTION_END() #define ISRS_ENABLED() #define ENABLE_ISRS() #define DISABLE_ISRS() diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index 302cf9d376b0..c727877ff372 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -119,8 +119,8 @@ extern "C" volatile uint32_t _millis; // // Interrupts // -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/HAL_SAMD51/HAL.h b/Marlin/src/HAL/HAL_SAMD51/HAL.h index 209514a70402..f2ee02a22fcc 100644 --- a/Marlin/src/HAL/HAL_SAMD51/HAL.h +++ b/Marlin/src/HAL/HAL_SAMD51/HAL.h @@ -101,8 +101,8 @@ typedef int8_t pin_t; // // Interrupts // -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/HAL_STM32/HAL.h b/Marlin/src/HAL/HAL_STM32/HAL.h index a62c3f41309b..9fb40d612187 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL.h +++ b/Marlin/src/HAL/HAL_STM32/HAL.h @@ -127,8 +127,8 @@ #define analogInputToDigitalPin(p) (p) #endif -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.h b/Marlin/src/HAL/HAL_STM32F1/HAL.h index b7e2921ffa52..c97abf4bb1a8 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.h @@ -162,8 +162,8 @@ void HAL_idletask(); #define digitalPinHasPWM(P) (PIN_MAP[P].timer_device != nullptr) #endif -#define CRITICAL_SECTION_START uint32_t primask = __get_primask(); (void)__iCliRetVal() -#define CRITICAL_SECTION_END if (!primask) (void)__iSeiRetVal() +#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); (void)__iCliRetVal() +#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal() #define ISRS_ENABLED() (!__get_primask()) #define ENABLE_ISRS() ((void)__iSeiRetVal()) #define DISABLE_ISRS() ((void)__iCliRetVal()) diff --git a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h index d92aebeac0e5..b5d8ac29cf4f 100644 --- a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h +++ b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h @@ -127,8 +127,8 @@ #define analogInputToDigitalPin(p) (p) #endif -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h index 5a5038287cc1..15e9ab71bb34 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h @@ -70,8 +70,8 @@ typedef int8_t pin_t; #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1) #endif -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h index 3fbfeaea64f3..7e5be1081c01 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h @@ -73,8 +73,8 @@ typedef int8_t pin_t; #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1) #endif -#define CRITICAL_SECTION_START uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_primask()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() diff --git a/Marlin/src/HAL/shared/servo.cpp b/Marlin/src/HAL/shared/servo.cpp index 7c078d2f4180..d03b80b20097 100644 --- a/Marlin/src/HAL/shared/servo.cpp +++ b/Marlin/src/HAL/shared/servo.cpp @@ -129,9 +129,9 @@ void Servo::writeMicroseconds(int value) { value = constrain(value, SERVO_MIN(min), SERVO_MAX(max)) - (TRIM_DURATION); value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); servo_info[channel].ticks = value; - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); } } diff --git a/Marlin/src/feature/Max7219_Debug_LEDs.cpp b/Marlin/src/feature/Max7219_Debug_LEDs.cpp index f56d98a5bca3..2b329db3b333 100644 --- a/Marlin/src/feature/Max7219_Debug_LEDs.cpp +++ b/Marlin/src/feature/Max7219_Debug_LEDs.cpp @@ -125,8 +125,8 @@ uint8_t Max7219::led_line[MAX7219_LINES]; // = { 0 }; #define SIG_DELAY() DELAY_US(1) // Approximate a 1µs delay on 32-bit ARM #undef CRITICAL_SECTION_START #undef CRITICAL_SECTION_END - #define CRITICAL_SECTION_START NOOP - #define CRITICAL_SECTION_END NOOP + #define CRITICAL_SECTION_START() NOOP + #define CRITICAL_SECTION_END() NOOP #else #define SIG_DELAY() DELAY_NS(188) // Delay for 0.1875µs (16MHz AVR) or 0.15µs (20MHz AVR) #endif @@ -163,7 +163,7 @@ inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) { } void Max7219::noop() { - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); SIG_DELAY(); WRITE(MAX7219_DIN_PIN, LOW); for (uint8_t i = 16; i--;) { @@ -174,11 +174,11 @@ void Max7219::noop() { WRITE(MAX7219_CLK_PIN, HIGH); SIG_DELAY(); } - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); } void Max7219::putbyte(uint8_t data) { - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); for (uint8_t i = 8; i--;) { SIG_DELAY(); WRITE(MAX7219_CLK_PIN, LOW); // tick @@ -189,7 +189,7 @@ void Max7219::putbyte(uint8_t data) { SIG_DELAY(); data <<= 1; } - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); } void Max7219::pulse_load() { @@ -202,12 +202,12 @@ void Max7219::pulse_load() { void Max7219::send(const uint8_t reg, const uint8_t data) { SIG_DELAY(); - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); SIG_DELAY(); putbyte(reg); // specify register SIG_DELAY(); putbyte(data); // put data - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); } // Send out a single native row of bits to just one unit @@ -574,14 +574,14 @@ void Max7219::idle_tasks() { #define MAX7219_USE_HEAD (defined(MAX7219_DEBUG_PLANNER_HEAD) || defined(MAX7219_DEBUG_PLANNER_QUEUE)) #define MAX7219_USE_TAIL (defined(MAX7219_DEBUG_PLANNER_TAIL) || defined(MAX7219_DEBUG_PLANNER_QUEUE)) #if MAX7219_USE_HEAD || MAX7219_USE_TAIL - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); #if MAX7219_USE_HEAD const uint8_t head = planner.block_buffer_head; #endif #if MAX7219_USE_TAIL const uint8_t tail = planner.block_buffer_tail; #endif - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); #endif #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE) diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index 891d9fd17353..35631708c425 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -63,13 +63,13 @@ void Buzzer::tick() { if (state.tone.frequency > 0) { #if ENABLED(EXTENSIBLE_UI) - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); ExtUI::onPlayTone(state.tone.frequency, state.tone.duration); - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); #elif ENABLED(SPEAKER) - CRITICAL_SECTION_START; + CRITICAL_SECTION_START(); ::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration); - CRITICAL_SECTION_END; + CRITICAL_SECTION_END(); #else on(); #endif From 0fd0554b5fbf6aecb5000ba6f37ab79a1c32f039 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 11 Feb 2020 10:07:24 -0600 Subject: [PATCH 15/16] Simplify old safe homing sanity check --- Marlin/src/inc/SanityCheck.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a94300d45e84..4581ca9b158c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1361,14 +1361,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Make sure Z_SAFE_HOMING point is reachable */ #if ENABLED(Z_SAFE_HOMING) - #if HAS_BED_PROBE && (ENABLED(DELTA) || IS_SCARA) - static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, PROBE_X_MIN, PROBE_X_MAX), "Z_SAFE_HOMING_X_POINT is outside the probe region."); - static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, PROBE_Y_MIN, PROBE_Y_MAX), "Z_SAFE_HOMING_Y_POINT is outside the probe region."); - #else - static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, X_MIN_POS, X_MAX_POS), "Z_SAFE_HOMING_X_POINT can't be reached by the nozzle."); - static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, Y_MIN_POS, Y_MAX_POS), "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle."); - #endif -#endif // Z_SAFE_HOMING + static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, X_MIN_BED, X_MAX_BED), "Z_SAFE_HOMING_X_POINT can't be reached by the nozzle."); + static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, Y_MIN_BED, Y_MAX_BED), "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle."); +#endif /** * Make sure DISABLE_[XYZ] compatible with selected homing options From 4a733796bdd11e429f117e652c0edb74c33c9e49 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Tue, 11 Feb 2020 17:43:28 +0100 Subject: [PATCH 16/16] Prevent pin glitches on out commutation (#16835) Better for switching from pulled input to output and also set real output (with no input enabled). --- Marlin/src/HAL/HAL_SAMD51/fastio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/HAL_SAMD51/fastio.h b/Marlin/src/HAL/HAL_SAMD51/fastio.h index c91965e19e0b..e00fa77a7c1f 100644 --- a/Marlin/src/HAL/HAL_SAMD51/fastio.h +++ b/Marlin/src/HAL/HAL_SAMD51/fastio.h @@ -88,8 +88,8 @@ 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].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{ \