|
@@ -24,7 +24,7 @@
|
24
|
24
|
#include "Marlin.h"
|
25
|
25
|
|
26
|
26
|
#if !defined(SERIAL_PORT)
|
27
|
|
-#error SERIAL_PORT not set
|
|
27
|
+#define SERIAL_PORT 0
|
28
|
28
|
#endif
|
29
|
29
|
|
30
|
30
|
// The presence of the UBRRH register is used to detect a UART.
|
|
@@ -35,29 +35,21 @@
|
35
|
35
|
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
|
36
|
36
|
// requires two levels of indirection to expand macro values properly)
|
37
|
37
|
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
|
38
|
|
-#if SERIAL_PORT == 0 && !defined(UBRR0H)
|
|
38
|
+#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
|
39
|
39
|
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
|
40
|
|
-#else
|
|
40
|
+#else
|
41
|
41
|
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
|
42
|
|
-#endif
|
|
42
|
+#endif
|
43
|
43
|
|
44
|
44
|
// Registers used by MarlinSerial class (these are expanded
|
45
|
45
|
// depending on selected serial port
|
46
|
|
-#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRxA where x is the serial port number
|
|
46
|
+#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number
|
47
|
47
|
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
|
48
|
48
|
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
|
49
|
49
|
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
|
50
|
50
|
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
|
51
|
51
|
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
|
52
|
|
-#if SERIAL_PORT == 0 && !defined(UDR0)
|
53
|
|
- #if defined(UDR)
|
54
|
|
- #define M_UDRx UDR // atmega8, atmega32
|
55
|
|
- #else
|
56
|
|
- #error UDR not defined
|
57
|
|
- #endif
|
58
|
|
-#else
|
59
|
|
- #define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
|
60
|
|
-#endif
|
|
52
|
+#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
|
61
|
53
|
#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
|
62
|
54
|
#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
|
63
|
55
|
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
|
|
@@ -189,4 +181,4 @@ class MarlinSerial //: public Stream
|
189
|
181
|
extern MarlinSerial MSerial;
|
190
|
182
|
#endif // ! teensylu
|
191
|
183
|
|
192
|
|
-#endif
|
|
184
|
+#endif
|