Browse Source

Merge pull request #26 from 3d-gussner/MK2

Merge pull request #241 from PavelSindler/slow_printer_fix
3d-gussner 7 years ago
parent
commit
f3c539d1ff
4 changed files with 20 additions and 18 deletions
  1. 1 1
      Firmware/Marlin.h
  2. 17 15
      Firmware/MarlinSerial.cpp
  3. 1 1
      Firmware/MarlinSerial.h
  4. 1 1
      Firmware/Marlin_main.cpp

+ 1 - 1
Firmware/Marlin.h

@@ -96,7 +96,7 @@ void serial_echopair_P(const char *s_P, float v);
 void serial_echopair_P(const char *s_P, double v);
 void serial_echopair_P(const char *s_P, unsigned long v);
 
-extern int selectedSerialPort;
+extern uint8_t selectedSerialPort;
 
 //Things to write to serial from Program memory. Saves 400 to 2k of RAM.
 FORCE_INLINE void serialprintPGM(const char *str)

+ 17 - 15
Firmware/MarlinSerial.cpp

@@ -124,22 +124,24 @@ void MarlinSerial::begin(long baud)
   sbi(M_UCSRxB, M_RXCIEx);
   
 #ifndef SNMM
-// set up the second serial port
-  if (useU2X) {
-        UCSR2A = 1 << U2X2;
-        baud_setting = (F_CPU / 4 / baud - 1) / 2;
-    } else {
-        UCSR2A = 0;
-        baud_setting = (F_CPU / 8 / baud - 1) / 2;
-    }
 
-    // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
-    UBRR2H = baud_setting >> 8;
-    UBRR2L = baud_setting;
-
-    sbi(UCSR2B, RXEN2);
-    sbi(UCSR2B, TXEN2);
-    sbi(UCSR2B, RXCIE2);
+  if (selectedSerialPort == 1) { //set up also the second serial port 
+	  if (useU2X) {
+		  UCSR2A = 1 << U2X2;
+		  baud_setting = (F_CPU / 4 / baud - 1) / 2;
+	  } else {
+		  UCSR2A = 0;
+		  baud_setting = (F_CPU / 8 / baud - 1) / 2;
+	  }
+
+	  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
+	  UBRR2H = baud_setting >> 8;
+	  UBRR2L = baud_setting;
+	  
+	  sbi(UCSR2B, RXEN2);
+	  sbi(UCSR2B, TXEN2);
+	  sbi(UCSR2B, RXCIE2);	  
+  }
 #endif
 }
 

+ 1 - 1
Firmware/MarlinSerial.h

@@ -73,7 +73,7 @@
 // is the index of the location from which to read.
 #define RX_BUFFER_SIZE 128
 
-extern int selectedSerialPort;
+extern uint8_t selectedSerialPort;
 
 struct ring_buffer
 {

+ 1 - 1
Firmware/Marlin_main.cpp

@@ -290,7 +290,7 @@ unsigned int custom_message_type;
 unsigned int custom_message_state;
 char snmm_filaments_used = 0;
 
-int selectedSerialPort;
+uint8_t selectedSerialPort;
 
 float distance_from_min[3];