From 1b45b3802ac62c3b1e47213b847d9eb772ba1f4b Mon Sep 17 00:00:00 2001 From: charlespick Date: Thu, 20 May 2021 04:06:26 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Independent=20baud=20rates=20(#2194?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 27 ++++++++++++++++----------- Marlin/Configuration_adv.h | 3 --- Marlin/src/MarlinCore.cpp | 10 ++++++++-- buildroot/tests/STM32F103RC_btt_USB | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 58cb2514889b..366267aa7e97 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -104,12 +104,27 @@ */ #define SERIAL_PORT 0 +/** + * Serial Port Baud Rate + * This is the default communication speed for all serial ports. + * Set the baud rate defaults for additional serial ports below. + * + * 250000 works in most cases, but you might try a lower speed if + * you commonly experience drop-outs during host printing. + * You may try up to 1000000 to speed up SD file transfer. + * + * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] + */ +#define BAUDRATE 250000 +//#define BAUD_RATE_GCODE // Enable G-code M575 to set the baud rate + /** * Select a secondary serial port on the board to use for communication with the host. * Currently Ethernet (-2) is only supported on Teensy 4.1 boards. * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_2 -1 +//#define BAUDRATE_2 250000 // Enable to override BAUDRATE /** * Select a third serial port on the board to use for communication with the host. @@ -117,17 +132,7 @@ * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_3 1 - -/** - * This setting determines the communication speed of the printer. - * - * 250000 works in most cases, but you might try a lower speed if - * you commonly experience drop-outs during host printing. - * You may try up to 1000000 to speed up SD file transfer. - * - * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] - */ -#define BAUDRATE 250000 +//#define BAUDRATE_3 250000 // Enable to override BAUDRATE // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 5335fa012a15..5db36d9cbbe7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2114,9 +2114,6 @@ //#define SERIAL_XON_XOFF #endif -// Add M575 G-code to change the baud rate -//#define BAUD_RATE_GCODE - #if ENABLED(SDSUPPORT) // Enable this option to collect and display the maximum // RX queue usage after transferring a file to SD. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 5ef575a30f6a..4fca64ba6b79 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1073,11 +1073,17 @@ void setup() { while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #if HAS_MULTI_SERIAL && !HAS_ETHERNET - MYSERIAL2.begin(BAUDRATE); + #ifndef BAUDRATE_2 + #define BAUDRATE_2 BAUDRATE + #endif + MYSERIAL2.begin(BAUDRATE_2); serial_connect_timeout = millis() + 1000UL; while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #ifdef SERIAL_PORT_3 - MYSERIAL3.begin(BAUDRATE); + #ifndef BAUDRATE_3 + #define BAUDRATE_3 BAUDRATE + #endif + MYSERIAL3.begin(BAUDRATE_3); serial_connect_timeout = millis() + 1000UL; while (!MYSERIAL3.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #endif diff --git a/buildroot/tests/STM32F103RC_btt_USB b/buildroot/tests/STM32F103RC_btt_USB index 8381de0ea6e4..fb0f2f5bd2d9 100755 --- a/buildroot/tests/STM32F103RC_btt_USB +++ b/buildroot/tests/STM32F103RC_btt_USB @@ -10,7 +10,7 @@ set -e # Build with the default configurations # restore_configs -opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 +opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 BAUDRATE_2 115200 exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - Basic Configuration" "$3" # clean up