test

Dependencies:   USBDevice mbed

Fork of USBSerial_HelloWorld by Samuel Mokrani

Committer:
zapta
Date:
Mon Dec 21 07:12:39 2015 +0000
Revision:
10:aed18128d16d
Parent:
9:d88699a0905a
.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 7:5e693654d5b4 1 #include "mbed.h"
samux 7:5e693654d5b4 2 #include "USBSerial.h"
samux 7:5e693654d5b4 3
zapta 10:aed18128d16d 4 DigitalOut led(P0_20); // LED pin
samux 9:d88699a0905a 5
zapta 10:aed18128d16d 6 //Virtual serial port over USB
zapta 10:aed18128d16d 7 USBSerial usb_serial;
zapta 10:aed18128d16d 8
zapta 10:aed18128d16d 9 // Hardware serial to wifi device.
zapta 10:aed18128d16d 10 Serial wifi_serial(P0_19, P0_18); // tx, rx
zapta 10:aed18128d16d 11
zapta 10:aed18128d16d 12 Timer timer;
zapta 10:aed18128d16d 13
zapta 10:aed18128d16d 14 void setup() {
zapta 10:aed18128d16d 15 timer.start();
zapta 10:aed18128d16d 16 wifi_serial.baud(19200);
zapta 10:aed18128d16d 17 }
zapta 10:aed18128d16d 18
zapta 10:aed18128d16d 19 void loop() {
zapta 10:aed18128d16d 20 if (timer.read_ms() < 200) {
zapta 10:aed18128d16d 21 return;
zapta 10:aed18128d16d 22 }
zapta 10:aed18128d16d 23 led = !led; // Invert LED state
zapta 10:aed18128d16d 24 timer.reset();
zapta 10:aed18128d16d 25 usb_serial.printf("usb\r\n");
zapta 10:aed18128d16d 26 wifi_serial.printf("wifi\r\n");
zapta 10:aed18128d16d 27 }
zapta 10:aed18128d16d 28
zapta 10:aed18128d16d 29 int main(void) {
zapta 10:aed18128d16d 30 setup();
zapta 10:aed18128d16d 31 for(;;) {
zapta 10:aed18128d16d 32 loop();
zapta 10:aed18128d16d 33 }
zapta 10:aed18128d16d 34 }