Merge pull request #74 from XPila/MK3

setup second serial port only in case it is selected
This commit is contained in:
XPila 2017-10-24 23:21:43 +02:00 committed by GitHub
commit 5100ead22e
4 changed files with 14489 additions and 25 deletions

View File

@ -9,7 +9,7 @@
// Firmware version
#define FW_version "3.0.12-RC2"
#define FW_build 103
#define FW_build 104
#define FW_version_build FW_version " b" STR(FW_build)

View File

@ -23,7 +23,7 @@
#include "Marlin.h"
#include "MarlinSerial.h"
int selectedSerialPort = 0;
uint8_t selectedSerialPort = 0;
#ifndef AT90USB
// this next line disables the entire HardwareSerial.cpp,
@ -58,23 +58,23 @@ FORCE_INLINE void store_char(unsigned char c)
// Test for a framing error.
if (M_UCSRxA & (1<<M_FEx)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = M_UDRx;
// Dummy register read (discard)
(void)(*(char *)M_UDRx);
} else {
// Read the input register.
unsigned char c = M_UDRx;
store_char(c);
}
}
#ifndef SNMM
SIGNAL(USART2_RX_vect)
{
if (selectedSerialPort == 1) {
// Test for a framing error.
if (UCSR2A & (1<<FE2)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = UDR2;
// Dummy register read (discard)
(void)(*(char *)UDR2);
} else {
// Read the input register.
unsigned char c = UDR2;
@ -84,6 +84,7 @@ FORCE_INLINE void store_char(unsigned char c)
}
}
#endif
#endif
// Constructors ////////////////////////////////////////////////////////////////
@ -124,8 +125,9 @@ void MarlinSerial::begin(long baud)
sbi(M_UCSRxB, M_TXENx);
sbi(M_UCSRxB, M_RXCIEx);
#ifndef SNMM
// set up the second serial port
if (selectedSerialPort == 1) { //set up also the second serial port
if (useU2X) {
UCSR2A = 1 << U2X2;
baud_setting = (F_CPU / 4 / baud - 1) / 2;
@ -142,6 +144,8 @@ void MarlinSerial::begin(long baud)
sbi(UCSR2B, TXEN2);
sbi(UCSR2B, RXCIE2);
}
#endif
}
void MarlinSerial::end()
{
@ -149,9 +153,11 @@ void MarlinSerial::end()
cbi(M_UCSRxB, M_TXENx);
cbi(M_UCSRxB, M_RXCIEx);
#ifndef SNMM
cbi(UCSR2B, RXEN2);
cbi(UCSR2B, TXEN2);
cbi(UCSR2B, RXCIE2);
#endif
}

View File

@ -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
{

File diff suppressed because it is too large Load Diff