echo characters typed on USB debug port

Dependencies:   mbed

Committer:
mfiore
Date:
Wed Dec 02 18:08:19 2015 +0000
Revision:
1:43abfdd0709b
Parent:
0:279c532226c8
blink RSSI LED on micro UDK and D3 led on UDK2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 0:279c532226c8 1 // this program echos on the USB debug port
mfiore 1:43abfdd0709b 2 // it also blinks the RSSI LED on the micro UDK and the D3 LED on the UDK2
mfiore 0:279c532226c8 3
mfiore 0:279c532226c8 4 #include "mbed.h"
mfiore 0:279c532226c8 5
mfiore 1:43abfdd0709b 6 DigitalOut uled(XBEE_RSSI); // RSSI LED on micro UDK
mfiore 1:43abfdd0709b 7 DigitalOut led(LED1); // D3 LED on UDK2
mfiore 1:43abfdd0709b 8
mfiore 1:43abfdd0709b 9 Ticker tick;
mfiore 1:43abfdd0709b 10 void tock(void) {
mfiore 1:43abfdd0709b 11 uled = !uled;
mfiore 1:43abfdd0709b 12 led = !led;
mfiore 1:43abfdd0709b 13 }
mfiore 1:43abfdd0709b 14
mfiore 0:279c532226c8 15 int main() {
mfiore 0:279c532226c8 16 Serial usb(USBTX, USBRX);
mfiore 0:279c532226c8 17
mfiore 1:43abfdd0709b 18 tick.attach(&tock, 0.5);
mfiore 1:43abfdd0709b 19
mfiore 0:279c532226c8 20 // change the following value to change the baud rate
mfiore 0:279c532226c8 21 usb.baud(115200);
mfiore 0:279c532226c8 22
mfiore 0:279c532226c8 23 while (true)
mfiore 0:279c532226c8 24 if (usb.readable())
mfiore 0:279c532226c8 25 usb.putc(usb.getc());
mfiore 0:279c532226c8 26 }