serial pc board pass through, use your board like a usb-serial 3.3V level converter,

Dependencies:   mbed

Committer:
felipeM
Date:
Sat Oct 05 19:46:21 2013 +0000
Revision:
0:bab6dd4a9c11
FRDM seral pc board pass through based in :; https://mbed.org/handbook/SerialPC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
felipeM 0:bab6dd4a9c11 1 #include "mbed.h"
felipeM 0:bab6dd4a9c11 2
felipeM 0:bab6dd4a9c11 3 Serial pc(USBTX, USBRX);
felipeM 0:bab6dd4a9c11 4 //TX RX pins, see https://mbed.org/handbook/mbed-FRDM-KL25Z
felipeM 0:bab6dd4a9c11 5 Serial uart(PTC4, PTC3);
felipeM 0:bab6dd4a9c11 6 //to test is you can use a hard bridge (piece of cable) between PTC4 and PTC3 open a terminal and write something :)
felipeM 0:bab6dd4a9c11 7 //you can integrate this to improve some interesting aplicattions like this:
felipeM 0:bab6dd4a9c11 8 //http://www.instructables.com/id/Temperature-sensor--weatherstation/http://www.instructables.com/id/Temperature-sensor--weatherstation/
felipeM 0:bab6dd4a9c11 9 DigitalOut pc_activity(LED1);
felipeM 0:bab6dd4a9c11 10 DigitalOut uart_activity(LED2);
felipeM 0:bab6dd4a9c11 11
felipeM 0:bab6dd4a9c11 12 int main() {
felipeM 0:bab6dd4a9c11 13 while(1) {
felipeM 0:bab6dd4a9c11 14 if(pc.readable()) {
felipeM 0:bab6dd4a9c11 15 uart.putc(pc.getc());
felipeM 0:bab6dd4a9c11 16 pc_activity = !pc_activity;
felipeM 0:bab6dd4a9c11 17 }
felipeM 0:bab6dd4a9c11 18 if(uart.readable()) {
felipeM 0:bab6dd4a9c11 19 pc.putc(uart.getc());
felipeM 0:bab6dd4a9c11 20 uart_activity = !uart_activity;
felipeM 0:bab6dd4a9c11 21 }
felipeM 0:bab6dd4a9c11 22 }
felipeM 0:bab6dd4a9c11 23 }