Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 5da293e

Browse files
authored
v1.1.2 to use auto SerialDebug port
### Release v1.1.2 1. Using `Serial3` for debugging with `Curiosity Nano AVRDB`, and `Serial1` for debugging with `Curiosity Nano AVRDA`
1 parent 2a8c1cb commit 5da293e

24 files changed

+371
-232
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
## Table of Contents
1010

1111
* [Changelog](#changelog)
12+
* [Release v1.1.2](#release-v112)
1213
* [Release v1.1.1](#release-v111)
1314
* [Release v1.1.0](#release-v110)
1415
* [Initial Release v1.0.0](#initial-release-v100)
@@ -18,6 +19,11 @@
1819

1920
## Changelog
2021

22+
### Release v1.1.2
23+
24+
1. Using `Serial3` for debugging with `Curiosity Nano AVRDB`, and `Serial1` for debugging with `Curiosity Nano AVRDA`
25+
26+
2127
### Release v1.1.1
2228

2329
1. Using Serial1 instead of Serial for debugging with Curiosity Nano AVRDA/AVRDB

examples/Argument_Complex/Argument_Complex.ino

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
#endif
7474
#endif
7575

76+
#if defined(__AVR_AVR128DA48__)
77+
#define SerialDebug Serial1
78+
#elif defined(__AVR_AVR128DB48__)
79+
#define SerialDebug Serial3
80+
#else
81+
// standard Serial
82+
#define SerialDebug Serial
83+
#endif
84+
7685
struct pinStruct
7786
{
7887
unsigned int Pin1;
@@ -88,19 +97,19 @@ void TimerHandler1(unsigned int outputPinsAddress)
8897

8998
//timer interrupt toggles pins
9099
#if (TIMER_INTERRUPT_DEBUG > 1)
91-
Serial1.print("Toggle pin1 = "); Serial1.println( ((pinStruct *) outputPinsAddress)->Pin1 );
100+
SerialDebug.print("Toggle pin1 = "); SerialDebug.println( ((pinStruct *) outputPinsAddress)->Pin1 );
92101
#endif
93102

94103
digitalWrite(((pinStruct *) outputPinsAddress)->Pin1, toggle);
95104

96105
#if (TIMER_INTERRUPT_DEBUG > 1)
97-
Serial1.print("Read pin2 A0 ("); Serial1.print(((pinStruct *) outputPinsAddress)->Pin2 );
98-
Serial1.print(") = ");
99-
Serial1.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin2) ? "HIGH" : "LOW" );
106+
SerialDebug.print("Read pin2 A0 ("); SerialDebug.print(((pinStruct *) outputPinsAddress)->Pin2 );
107+
SerialDebug.print(") = ");
108+
SerialDebug.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin2) ? "HIGH" : "LOW" );
100109

101-
Serial1.print("Read pin3 A1 ("); Serial1.print(((pinStruct *) outputPinsAddress)->Pin3 );
102-
Serial1.print(") = ");
103-
Serial1.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin3) ? "HIGH" : "LOW" );
110+
SerialDebug.print("Read pin3 A1 ("); SerialDebug.print(((pinStruct *) outputPinsAddress)->Pin3 );
111+
SerialDebug.print(") = ");
112+
SerialDebug.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin3) ? "HIGH" : "LOW" );
104113
#endif
105114

106115
toggle = !toggle;
@@ -114,32 +123,32 @@ void setup()
114123
pinMode(myOutputPins.Pin2, INPUT_PULLUP);
115124
pinMode(myOutputPins.Pin3, INPUT_PULLUP);
116125

117-
Serial1.begin(115200);
118-
while (!Serial1 && millis() < 5000);
126+
SerialDebug.begin(115200);
127+
while (!SerialDebug && millis() < 5000);
119128

120-
Serial1.print(F("\nStarting Argument_Complex on ")); Serial1.println(BOARD_NAME);
121-
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
122-
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
129+
SerialDebug.print(F("\nStarting Argument_Complex on ")); SerialDebug.println(BOARD_NAME);
130+
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
131+
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));
123132

124-
Serial1.print(F("TCB Clock Frequency = "));
133+
SerialDebug.print(F("TCB Clock Frequency = "));
125134

126135
#if USING_FULL_CLOCK
127-
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
136+
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
128137
#elif USING_HALF_CLOCK
129-
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
138+
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
130139
#else
131-
Serial1.println(F("250KHz for lower accuracy but longer time"));
140+
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
132141
#endif
133142

134143
// Timer TCB2 is used for micros(), millis(), delay(), etc and can't be used
135144
CurrentTimer.init();
136145

137146
if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1, (unsigned int) &myOutputPins))
138147
{
139-
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
148+
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
140149
}
141150
else
142-
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
151+
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
143152
}
144153

145154
void loop()

examples/Argument_None/Argument_None.ino

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@
7575
#endif
7676
#endif
7777

78+
#if defined(__AVR_AVR128DA48__)
79+
#define SerialDebug Serial1
80+
#elif defined(__AVR_AVR128DB48__)
81+
#define SerialDebug Serial3
82+
#else
83+
// standard Serial
84+
#define SerialDebug Serial
85+
#endif
86+
7887
void TimerHandler1(void)
7988
{
8089
static bool toggle = false;
@@ -88,32 +97,32 @@ void setup()
8897
{
8998
pinMode(LED_BUILTIN, OUTPUT);
9099

91-
Serial1.begin(115200);
92-
while (!Serial1 && millis() < 5000);
100+
SerialDebug.begin(115200);
101+
while (!SerialDebug && millis() < 5000);
93102

94-
Serial1.print(F("\nStarting Argument_None on ")); Serial1.println(BOARD_NAME);
95-
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
96-
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
103+
SerialDebug.print(F("\nStarting Argument_None on ")); SerialDebug.println(BOARD_NAME);
104+
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
105+
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));
97106

98-
Serial1.print(F("TCB Clock Frequency = "));
107+
SerialDebug.print(F("TCB Clock Frequency = "));
99108

100109
#if USING_FULL_CLOCK
101-
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
110+
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
102111
#elif USING_HALF_CLOCK
103-
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
112+
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
104113
#else
105-
Serial1.println(F("250KHz for lower accuracy but longer time"));
114+
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
106115
#endif
107116

108117
// Timer TCB2 is used for micros(), millis(), delay(), etc and can't be used
109118
CurrentTimer.init();
110119

111120
if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1))
112121
{
113-
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
122+
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
114123
}
115124
else
116-
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
125+
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
117126
}
118127

119128
void loop()

examples/Argument_Simple/Argument_Simple.ino

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
#endif
7474
#endif
7575

76+
#if defined(__AVR_AVR128DA48__)
77+
#define SerialDebug Serial1
78+
#elif defined(__AVR_AVR128DB48__)
79+
#define SerialDebug Serial3
80+
#else
81+
// standard Serial
82+
#define SerialDebug Serial
83+
#endif
84+
7685
unsigned int outputPin1 = LED_BUILTIN;
7786

7887
#define TIMER1_INTERVAL_MS 1000
@@ -83,8 +92,8 @@ void TimerHandler1(unsigned int outputPin = LED_BUILTIN)
8392

8493
#if (TIMER_INTERRUPT_DEBUG > 1)
8594
//timer interrupt toggles pin outputPin, default LED_BUILTIN
86-
Serial1.print("pin1 = "); Serial1.print(outputPin);
87-
Serial1.print(" address: "); Serial1.println((uint32_t) &outputPin );
95+
SerialDebug.print("pin1 = "); SerialDebug.print(outputPin);
96+
SerialDebug.print(" address: "); SerialDebug.println((uint32_t) &outputPin );
8897
#endif
8998

9099
digitalWrite(outputPin, toggle);
@@ -95,37 +104,37 @@ void setup()
95104
{
96105
pinMode(LED_BUILTIN, OUTPUT);
97106

98-
Serial1.begin(115200);
99-
while (!Serial1 && millis() < 5000);
107+
SerialDebug.begin(115200);
108+
while (!SerialDebug && millis() < 5000);
100109

101-
Serial1.print(F("\nStarting Argument_Simple on ")); Serial1.println(BOARD_NAME);
102-
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
103-
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
110+
SerialDebug.print(F("\nStarting Argument_Simple on ")); SerialDebug.println(BOARD_NAME);
111+
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
112+
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));
104113

105-
Serial1.print(F("TCB Clock Frequency = "));
114+
SerialDebug.print(F("TCB Clock Frequency = "));
106115

107116
#if USING_FULL_CLOCK
108-
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
117+
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
109118
#elif USING_HALF_CLOCK
110-
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
119+
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
111120
#else
112-
Serial1.println(F("250KHz for lower accuracy but longer time"));
121+
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
113122
#endif
114123

115124
// Timer2 is used for micros(), millis(), delay(), etc and can't be used
116125
CurrentTimer.init();
117126

118127
if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1, outputPin1))
119128
{
120-
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
129+
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
121130

122131
#if (TIMER_INTERRUPT_DEBUG > 1)
123-
Serial1.print(F("OutputPin1 = ")); Serial1.print(outputPin1);
124-
Serial1.print(F(" address: ")); Serial1.println((uint32_t) &outputPin1 );
132+
SerialDebug.print(F("OutputPin1 = ")); SerialDebug.print(outputPin1);
133+
SerialDebug.print(F(" address: ")); SerialDebug.println((uint32_t) &outputPin1 );
125134
#endif
126135
}
127136
else
128-
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
137+
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
129138
}
130139

131140
void loop()

examples/Change_Interval/Change_Interval.ino

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,30 @@
7373
#endif
7474
#endif
7575

76+
#if defined(__AVR_AVR128DA48__)
77+
#define SerialDebug Serial1
78+
#elif defined(__AVR_AVR128DB48__)
79+
#define SerialDebug Serial3
80+
#else
81+
// standard Serial
82+
#define SerialDebug Serial
83+
#endif
84+
7685
#define TIMER1_INTERVAL_MS 50UL
7786

7887
volatile uint32_t Timer1Count = 1;
7988

8089
void printResult(uint32_t currTime)
8190
{
82-
Serial1.print(F("Time = ")); Serial1.print(currTime);
83-
Serial1.print(F(", Timer1Count = ")); Serial1.println(Timer1Count);
91+
SerialDebug.print(F("Time = ")); SerialDebug.print(currTime);
92+
SerialDebug.print(F(", Timer1Count = ")); SerialDebug.println(Timer1Count);
8493
}
8594

8695
void TimerHandler1()
8796
{
8897
static bool toggle = false;
8998

90-
// Flag for checking to be sure ISR is working as Serial1.print is not OK here in ISR
99+
// Flag for checking to be sure ISR is working as SerialDebug.print is not OK here in ISR
91100
Timer1Count++;
92101

93102
//timer interrupt toggles pin LED_BUILTIN
@@ -99,32 +108,32 @@ void setup()
99108
{
100109
pinMode(LED_BUILTIN, OUTPUT);
101110

102-
Serial1.begin(115200);
103-
while (!Serial1 && millis() < 5000);
111+
SerialDebug.begin(115200);
112+
while (!SerialDebug && millis() < 5000);
104113

105-
Serial1.print(F("\nStarting Change_Interval on ")); Serial1.println(BOARD_NAME);
106-
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
107-
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
114+
SerialDebug.print(F("\nStarting Change_Interval on ")); SerialDebug.println(BOARD_NAME);
115+
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
116+
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));
108117

109-
Serial1.print(F("TCB Clock Frequency = "));
118+
SerialDebug.print(F("TCB Clock Frequency = "));
110119

111120
#if USING_FULL_CLOCK
112-
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
121+
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
113122
#elif USING_HALF_CLOCK
114-
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
123+
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
115124
#else
116-
Serial1.println(F("250KHz for lower accuracy but longer time"));
125+
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
117126
#endif
118127

119128
// Timer TCB2 is used for micros(), millis(), delay(), etc and can't be used
120129
CurrentTimer.init();
121130

122131
if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1))
123132
{
124-
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
133+
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
125134
}
126135
else
127-
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
136+
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
128137
}
129138

130139
#define CHECK_INTERVAL_MS 1000L
@@ -156,7 +165,7 @@ void loop()
156165

157166
Timer1Count++;
158167

159-
Serial1.print(F("Changing Interval, Timer = ")); Serial1.println(TIMER1_INTERVAL_MS * (multFactor + 1));
168+
SerialDebug.print(F("Changing Interval, Timer = ")); SerialDebug.println(TIMER1_INTERVAL_MS * (multFactor + 1));
160169

161170
lastChangeTime = currTime;
162171
}

0 commit comments

Comments
 (0)