Skip to content

Commit a71f12c

Browse files
Samd support add support for serial insterface other than Serial
I use -D SIMPLEFOC_SAMD_DEBUG_SERIAL=SERIAL_PORT_MONITOR
1 parent 6b2e449 commit a71f12c

File tree

4 files changed

+112
-109
lines changed

4 files changed

+112
-109
lines changed

src/drivers/hardware_specific/samd21_mcu.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void configureSAMDClock() {
163163
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
164164

165165
#ifdef SIMPLEFOC_SAMD_DEBUG
166-
Serial.println("Configured clock...");
166+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println("Configured clock...");
167167
#endif
168168
}
169169
}
@@ -217,8 +217,8 @@ void configureTCC(tccConfiguration& tccConfig, long pwm_frequency, bool negate,
217217
tc->COUNT8.CTRLA.bit.ENABLE = 1;
218218
while ( tc->COUNT8.STATUS.bit.SYNCBUSY == 1 );
219219
#ifdef SIMPLEFOC_SAMD_DEBUG
220-
Serial.print("Initialized TC ");
221-
Serial.println(tccConfig.tcc.tccn);
220+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("Initialized TC ");
221+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println(tccConfig.tcc.tccn);
222222
#endif
223223
}
224224
else {
@@ -255,13 +255,13 @@ void configureTCC(tccConfiguration& tccConfig, long pwm_frequency, bool negate,
255255
while ( tcc->SYNCBUSY.bit.ENABLE == 1 ); // wait for sync
256256

257257
#ifdef SIMPLEFOC_SAMD_DEBUG
258-
Serial.print(" Initialized TCC ");
259-
Serial.print(tccConfig.tcc.tccn);
260-
Serial.print("-");
261-
Serial.print(tccConfig.tcc.chan);
262-
Serial.print("[");
263-
Serial.print(tccConfig.wo);
264-
Serial.println("]");
258+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(" Initialized TCC ");
259+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.tcc.tccn);
260+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("-");
261+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.tcc.chan);
262+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("[");
263+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.wo);
264+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println("]");
265265
#endif
266266
}
267267
}
@@ -288,13 +288,13 @@ void configureTCC(tccConfiguration& tccConfig, long pwm_frequency, bool negate,
288288
while ( tcc->SYNCBUSY.bit.ENABLE == 1 );
289289

290290
#ifdef SIMPLEFOC_SAMD_DEBUG
291-
Serial.print("(Re-)Initialized TCC ");
292-
Serial.print(tccConfig.tcc.tccn);
293-
Serial.print("-");
294-
Serial.print(tccConfig.tcc.chan);
295-
Serial.print("[");
296-
Serial.print(tccConfig.wo);
297-
Serial.println("]");
291+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("(Re-)Initialized TCC ");
292+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.tcc.tccn);
293+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("-");
294+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.tcc.chan);
295+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("[");
296+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.wo);
297+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println("]");
298298
#endif
299299
}
300300

src/drivers/hardware_specific/samd51_mcu.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void configureSAMDClock() {
188188
while (GCLK->SYNCBUSY.vec.GENCTRL&(0x1<<PWM_CLOCK_NUM));
189189

190190
#ifdef SIMPLEFOC_SAMD_DEBUG
191-
Serial.println("Configured clock...");
191+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println("Configured clock...");
192192
#endif
193193
}
194194
}
@@ -248,13 +248,13 @@ void configureTCC(tccConfiguration& tccConfig, long pwm_frequency, bool negate,
248248
while ( tcc->SYNCBUSY.bit.ENABLE == 1 ); // wait for sync
249249

250250
#ifdef SIMPLEFOC_SAMD_DEBUG
251-
Serial.print("(Re-)Initialized TCC ");
252-
Serial.print(tccConfig.tcc.tccn);
253-
Serial.print("-");
254-
Serial.print(tccConfig.tcc.chan);
255-
Serial.print("[");
256-
Serial.print(tccConfig.wo);
257-
Serial.println("]");
251+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("(Re-)Initialized TCC ");
252+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.tcc.tccn);
253+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("-");
254+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.tcc.chan);
255+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("[");
256+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print(tccConfig.wo);
257+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println("]");
258258
#endif
259259
}
260260
else if (tccConfig.tcc.tccn>=TCC_INST_NUM) {
@@ -280,8 +280,8 @@ void configureTCC(tccConfiguration& tccConfig, long pwm_frequency, bool negate,
280280
// while ( tc->COUNT8.STATUS.bit.SYNCBUSY == 1 );
281281

282282
#ifdef SIMPLEFOC_SAMD_DEBUG
283-
Serial.print("Initialized TC ");
284-
Serial.println(tccConfig.tcc.tccn);
283+
SIMPLEFOC_SAMD_DEBUG_SERIAL.print("Initialized TC ");
284+
SIMPLEFOC_SAMD_DEBUG_SERIAL.println(tccConfig.tcc.tccn);
285285
#endif
286286
}
287287

0 commit comments

Comments
 (0)