![](/media/cache/profiles/8158fa3e4de806e614f7ff02e7b22fde.jpg.50x50_q85.png)
Used to create a USB -> Serial link between a PC and a serial device
Connect your serial device to p28 (tx) and p27 (rx). Change the baud rate to match your device. The baud rate must be the same for Serial pc and Serial device.
Revision 0:8e51213bffbc, committed 2014-09-18
- Comitter:
- joe4465
- Date:
- Thu Sep 18 08:37:54 2014 +0000
- Commit message:
- Final version
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 8e51213bffbc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 18 08:37:54 2014 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +DigitalOut myled(LED1); + +Serial pc(USBTX, USBRX); // tx, rx +Serial device(p28, p27); // tx, rx + +int main() { + + device.baud(115200); + pc.baud(115200); + + + while(1) { + if(pc.readable()) { + device.putc(pc.getc()); + } + if(device.readable()) { + myled = !myled; + pc.putc(device.getc()); + } + } +} \ No newline at end of file
diff -r 000000000000 -r 8e51213bffbc mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 18 08:37:54 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file