#include "Arduino.h"
#define _UART1_ 1
#define _UART2_ 1
#if _UART1_
HardwareSerial mySerial1(1); // UART1 (RX=9, TX=10)
#endif
#if _UART2_
HardwareSerial mySerial2(2); // UART2 (RX=16, TX=17)
#endif
void setup()
{
Serial.begin(115200);
delay(2000);
#if _UART1_
// enable
Serial1
Serial.println("Enable Serail1");
mySerial1.begin(115200, SERIAL_8N1, 32, 33); // RX=32,
TX=33
#endif
#if _UART2_
// enable
Serial2
Serial.println("Enable Serail2");
mySerial2.begin(115200); // RX:IO16 TX:IO17
#endif
}
void loop()
{
unsigned long
time = millis();
Serial.printf("Serial Hello World %ld", time);
Serial.println();
#if _UART1_
mySerial1.printf("Serial1 Hello World %ld", time);
mySerial1.println();
#endif
#if _UART2_
mySerial2.printf("Serial2 Hello World %ld", time);
mySerial2.println();
#endif
delay(1000);
}
|