Skip to content

Commit e7a3130

Browse files
committed
Moving TXCO definition into HardwareSerial.cpp from HardwareSerial.h.
Otherwise, you get an error when compiling for processors with no serial port because the header file is always compiled. See, for an example of the problem: damellis/attiny#8
1 parent 825d68a commit e7a3130

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

hardware/arduino/cores/arduino/HardwareSerial.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@
3434

3535
#include "HardwareSerial.h"
3636

37+
/*
38+
* on ATmega8, the uart and its bits are not numbered, so there is no "TXC0"
39+
* definition. It is slightly cleaner to define this here instead of having
40+
* conditional code in the cpp module.
41+
*/
42+
#if !defined(TXC0)
43+
#if defined(TXC)
44+
#define TXC0 TXC
45+
#elif defined(TXC1)
46+
// Some devices have uart1 but no uart0
47+
#define TXC0 TXC1
48+
#else
49+
#error TXC0 not definable in HardwareSerial.h
50+
#endif
51+
#endif
52+
3753
// Define constants and variables for buffering incoming serial data. We're
3854
// using a ring buffer (I think), in which head is the index of the location
3955
// to which to write the next incoming character and tail is the index of the

hardware/arduino/cores/arduino/HardwareSerial.h

-16
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,6 @@ class HardwareSerial : public Stream
110110
extern HardwareSerial Serial3;
111111
#endif
112112

113-
/*
114-
* on ATmega8, the uart and its bits are not numbered, so there is no "TXC0"
115-
* definition. It is slightly cleaner to define this here instead of having
116-
* conditional code in the cpp module.
117-
*/
118-
#if !defined(TXC0)
119-
#if defined(TXC)
120-
#define TXC0 TXC
121-
#elif defined(TXC1)
122-
// Some devices have uart1 but no uart0
123-
#define TXC0 TXC1
124-
#else
125-
#error TXC0 not definable in HardwareSerial.h
126-
#endif
127-
#endif
128-
129113
extern void serialEventRun(void) __attribute__((weak));
130114

131115
#endif

0 commit comments

Comments
 (0)