Wait for serial port to connect in example - needed for Leonardo, Teensy and other boards with built-in USB CDC serial connection

This commit is contained in:
Kristian Sloth Lauszus 2013-10-21 19:58:03 +02:00
parent d20ae89818
commit f8c0adc107
34 changed files with 35 additions and 1 deletions

View file

@ -19,6 +19,7 @@ boolean printAngle;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -23,6 +23,7 @@ void setup() {
} }
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -28,6 +28,7 @@ String output = ""; // We will store the data in this string
void setup() { void setup() {
Serial.begin(115200); // This wil lprint the debugging from the libraries Serial.begin(115200); // This wil lprint the debugging from the libraries
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -18,6 +18,7 @@ boolean firstMessage = true;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -20,6 +20,7 @@ void setup() {
SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "1234" for all connections SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "1234" for all connections
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -18,6 +18,7 @@ bool printAngle;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -30,6 +30,7 @@ uint8_t printObjects;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -23,6 +23,7 @@ void setup() {
} }
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -16,6 +16,7 @@ WII Wii(&Btd,PAIR); // This will start an inquiry and then pair with your Wiimot
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -101,6 +101,7 @@ KbdRptParser Prs;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -148,6 +148,7 @@ MouseRptParser MousePrs;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -55,6 +55,7 @@ MouseRptParser Prs;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -12,6 +12,7 @@ JoystickReportParser Joy(&JoyEvents);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -51,6 +51,7 @@ UniversalReportParser Uni;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -15,6 +15,7 @@ JoystickReportParser Joy(&JoyEvents);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -17,6 +17,7 @@ ScaleReportParser Scale(&ScaleEvents);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -16,6 +16,7 @@ uint8_t state = 0;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -45,6 +45,7 @@ void PrintAddress(uint8_t addr)
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -13,6 +13,7 @@ XBOXOLD Xbox(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); // halt while(1); // halt

View file

@ -12,6 +12,7 @@ XBOXRECV Xbox(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -11,6 +11,7 @@ XBOXUSB Xbox(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while(1); //halt while(1); //halt

View file

@ -43,6 +43,7 @@ ACM Acm(&Usb, &AsyncOper);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -15,12 +15,13 @@ ADK adk(&Usb,"TKJElectronics", // Manufacturer Name
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.print("\r\nADK demo start"); while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print("\r\nOSCOKIRQ failed to assert"); Serial.print("\r\nOSCOKIRQ failed to assert");
while(1); //halt while(1); //halt
} }
pinMode(LED, OUTPUT); pinMode(LED, OUTPUT);
Serial.print("\r\nArduino Blink LED Started");
} }
void loop() void loop()

View file

@ -64,6 +64,7 @@ KbdRptParser Prs;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {

View file

@ -37,6 +37,7 @@ void init_leds()
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {

View file

@ -14,6 +14,7 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {

View file

@ -13,6 +13,7 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {

View file

@ -19,6 +19,7 @@ USB Usb;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
E_Notify(PSTR("\r\nCircuits At Home 2011"),0x80); E_Notify(PSTR("\r\nCircuits At Home 2011"),0x80);
E_Notify(PSTR("\r\nUSB Host Shield Quality Control Routine"),0x80); E_Notify(PSTR("\r\nUSB Host Shield Quality Control Routine"),0x80);
/* SPI quick test - check revision register */ /* SPI quick test - check revision register */

View file

@ -38,6 +38,7 @@ uint32_t next_time;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -41,6 +41,7 @@ void PrintAddress(uint8_t addr)
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -46,6 +46,7 @@ PL2303 Pl(&Usb, &AsyncOper);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -49,6 +49,7 @@ uint32_t read_delay;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -64,6 +64,7 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
Serial.println("by Mikal Hart"); Serial.println("by Mikal Hart");

View file

@ -46,6 +46,7 @@ PL2303 Pl(&Usb, &AsyncOper);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)