Skip to content

Commit

Permalink
updated USB examples:
Browse files Browse the repository at this point in the history
 - Demo1: Simple Echo
 - Demo2: UART Bridge UART1 - USB

Replaced in programmers.txt file tiusb with tilib
  • Loading branch information
StefanSch committed Sep 11, 2013
1 parent a10a46b commit 92cc703
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
@@ -1,8 +1,7 @@
/*
USB serial test
Receives from the hardware serial, sends to USB serial.
Receives from USB serial, sends to hardware serial.
Receives from USB serial and Echos back the data.
created back in the mists of time
Expand All @@ -16,6 +15,7 @@
#include <USBSerial.h>

USBSerial mySerial(1); // USB
uint8_t i = 0;

void setup()
{
Expand All @@ -24,11 +24,6 @@ void setup()
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);

// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Goodnight moon!");
digitalWrite(RED_LED, HIGH); // set the LED on

// open the USBSerial port
mySerial.begin();
mySerial.println("Hello USB world");
Expand All @@ -38,7 +33,10 @@ void setup()
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
{
mySerial.write(mySerial.read());
i ^= HIGH; // Toggle value
digitalWrite(RED_LED, i); // toggle the LED
}

}
@@ -1,12 +1,12 @@
/*
USB serial multiple serial test
USB serial test
Receives from the hardware serial, sends to USB serial.
Receives from USB serial, sends to hardware serial.
created back in the mists of time
modified 04 July 2013
modified 31 July 2013
by Stefan Schauer
based on Mikal Hart's example
Expand All @@ -19,43 +19,26 @@ USBSerial mySerial(1); // USB

void setup()
{

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
pinMode(PUSH2, INPUT_PULLUP);

digitalWrite(RED_LED, HIGH); // set the LED off
digitalWrite(RED_LED, LOW); // set the LED off
digitalWrite(GREEN_LED, LOW); // set the LED off
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);

// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Goodnight moon!");

while (digitalRead(PUSH2) == HIGH);

// set the data rate for the USBSerial port
digitalWrite(GREEN_LED, LOW); // set the LED off
mySerial.begin();
digitalWrite(RED_LED, HIGH); // set the LED on
mySerial.println("Hello, world?");
Serial.println("Hello Serial 1");

// open the USBSerial port
mySerial.begin();
mySerial.println("Hello USB world");
digitalWrite(GREEN_LED, HIGH); // set the LED on
}

void loop() // run over and over
{
digitalWrite(GREEN_LED, HIGH); // set the LED on
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
digitalWrite(GREEN_LED, LOW); // set the LED off

if (digitalRead(PUSH2) == LOW)
{
Serial.println("serial 1");
mySerial.println("serial USB");
}

}
4 changes: 2 additions & 2 deletions hardware/msp430/programmers.txt
Expand Up @@ -3,5 +3,5 @@
rf2500.name=rf2500
rf2500.protocol=rf2500

tiusb.name=tiusb
tiusb.protocol=tiusb
tilib.name=tilib
tilib.protocol=tilib

0 comments on commit 92cc703

Please sign in to comment.