From 0767af826db9d38ef4ca0a284658ae8331ea0bea Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Wed, 14 Oct 2020 00:30:57 -0700 Subject: [PATCH 1/2] Mostly revert Revert "Fix at90usb1286 build (#19687)" This reverts most of the changes from commit 7d030ba27f9e6c7ffaaead6c96711ceefab38fe0. (cherry picked from commit 6cbee9c14008edd7196e650142953204bc50a398) --- Marlin/src/HAL/AVR/HAL.h | 4 ++-- Marlin/src/HAL/AVR/MarlinSerial.cpp | 6 +++--- Marlin/src/HAL/AVR/MarlinSerial.h | 2 +- Marlin/src/gcode/control/M111.cpp | 4 ++-- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/inc/Conditionals_adv.h | 8 ++++---- Marlin/src/inc/SanityCheck.h | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 6e0afa8f10ed..ce15ed29fb3a 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -25,7 +25,7 @@ #include "watchdog.h" #include "math.h" -#ifdef IS_AT90USB +#ifdef USBCON #include #else #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion @@ -81,7 +81,7 @@ typedef int8_t pin_t; //extern uint8_t MCUSR; // Serial ports -#ifdef IS_AT90USB +#ifdef USBCON #define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial) #else #if !WITHIN(SERIAL_PORT, -1, 3) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 8feac32aa74c..63599efd4132 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -38,7 +38,7 @@ #include "../../inc/MarlinConfig.h" -#if !IS_AT90USB && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)) +#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)) #include "MarlinSerial.h" #include "../../MarlinCore.h" @@ -792,10 +792,10 @@ MarlinSerial> customizedSerial1; #endif -#endif // !IS_AT90USB && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H) +#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H) // For AT90USB targets use the UART for BT interfacing -#if BOTH(IS_AT90USB, BLUETOOTH) +#if defined(USBCON) && ENABLED(BLUETOOTH) HardwareSerial bluetoothSerial; #endif diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 3850e2a47e2a..8a0423d143d8 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -327,6 +327,6 @@ #endif // Use the UART for Bluetooth in AT90USB configurations -#if BOTH(IS_AT90USB, BLUETOOTH) +#if defined(USBCON) && ENABLED(BLUETOOTH) extern HardwareSerial bluetoothSerial; #endif diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index cc871bf38b52..e31c3e2fb7b2 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -55,7 +55,7 @@ void GcodeSuite::M111() { } else { SERIAL_ECHOPGM(STR_DEBUG_OFF); - #if !IS_AT90USB + #if !defined(__AVR__) || !defined(USBCON) #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS) SERIAL_ECHOPAIR("\nBuffer Overruns: ", MYSERIAL0.buffer_overruns()); #endif @@ -71,7 +71,7 @@ void GcodeSuite::M111() { #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED) SERIAL_ECHOPAIR("\nMax RX Queue Size: ", MYSERIAL0.rxMaxEnqueued()); #endif - #endif // !IS_AT90USB + #endif // !defined(__AVR__) || !defined(USBCON) } SERIAL_EOL(); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index a02d2c016042..b9169d90e1c7 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -624,7 +624,7 @@ void GCodeQueue::advance() { card.closefile(); SERIAL_ECHOLNPGM(STR_FILE_SAVED); - #if !IS_AT90USB + #if !defined(__AVR__) || !defined(USBCON) #if ENABLED(SERIAL_STATS_DROPPED_RX) SERIAL_ECHOLNPAIR("Dropped bytes: ", MYSERIAL0.dropped()); #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index bab05e5ff60d..255470bca6e7 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -208,10 +208,7 @@ #define NEEDS_HARDWARE_PWM 1 #endif -#if defined(__AVR__) && defined(USBCON) - #define IS_AT90USB 1 - #undef SERIAL_XON_XOFF // Not supported on USB-native devices -#else +#if !defined(__AVR__) || !defined(USBCON) // Define constants and variables for buffering serial data. // Use only 0 or powers of 2 greater than 1 // : [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...] @@ -223,6 +220,9 @@ #ifndef TX_BUFFER_SIZE #define TX_BUFFER_SIZE 32 #endif +#else + // SERIAL_XON_XOFF not supported on USB-native devices + #undef SERIAL_XON_XOFF #endif #if ENABLED(HOST_ACTION_COMMANDS) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 2cffde0907f7..e4f278b22b4f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -582,7 +582,7 @@ /** * Serial */ -#if !IS_AT90USB +#if !(defined(__AVR__) && defined(USBCON)) #if ENABLED(SERIAL_XON_XOFF) && RX_BUFFER_SIZE < 1024 #error "SERIAL_XON_XOFF requires RX_BUFFER_SIZE >= 1024 for reliable transfers without drops." #elif RX_BUFFER_SIZE && (RX_BUFFER_SIZE < 2 || !IS_POWER_OF_2(RX_BUFFER_SIZE)) @@ -2108,9 +2108,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif /** - * Emergency Command Parser + * emergency-command parser */ -#if BOTH(IS_AT90USB, EMERGENCY_PARSER) +#if ENABLED(EMERGENCY_PARSER) && defined(__AVR__) && defined(USBCON) #error "EMERGENCY_PARSER does not work on boards with AT90USB processors (USBCON)." #endif From f5cc456c7080e6da929436397ce6966d63e5595f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 14 Oct 2020 13:45:38 -0500 Subject: [PATCH 2/2] Update M111.cpp --- Marlin/src/gcode/control/M111.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index e31c3e2fb7b2..38cb06532241 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -71,7 +71,7 @@ void GcodeSuite::M111() { #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED) SERIAL_ECHOPAIR("\nMax RX Queue Size: ", MYSERIAL0.rxMaxEnqueued()); #endif - #endif // !defined(__AVR__) || !defined(USBCON) + #endif // !__AVR__ || !USBCON } SERIAL_EOL(); }