Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SerialPassthrough by
main.cpp@6:0c31964f8cf2, 2016-10-21 (annotated)
- Committer:
- Wosser1sProductions
- Date:
- Fri Oct 21 21:24:45 2016 +0000
- Revision:
- 6:0c31964f8cf2
- Parent:
- 5:96cb82af9996
First commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedAustin | 0:59bec1fd956e | 1 | #include "mbed.h" |
| mbedAustin | 2:a8dcb07a1d00 | 2 | |
| sam_grove | 5:96cb82af9996 | 3 | RawSerial pc(USBTX, USBRX); |
| Wosser1sProductions | 6:0c31964f8cf2 | 4 | |
| Wosser1sProductions | 6:0c31964f8cf2 | 5 | //RawSerial dev(D1, D0); |
| Wosser1sProductions | 6:0c31964f8cf2 | 6 | RawSerial dev(A0, A1); |
| Wosser1sProductions | 6:0c31964f8cf2 | 7 | |
| sam_grove | 5:96cb82af9996 | 8 | DigitalOut led1(LED1); |
| sam_grove | 5:96cb82af9996 | 9 | DigitalOut led4(LED4); |
| mbedAustin | 2:a8dcb07a1d00 | 10 | |
| Wosser1sProductions | 6:0c31964f8cf2 | 11 | void dev_recv() { |
| sam_grove | 5:96cb82af9996 | 12 | led1 = !led1; |
| sam_grove | 5:96cb82af9996 | 13 | while(dev.readable()) { |
| sam_grove | 5:96cb82af9996 | 14 | pc.putc(dev.getc()); |
| sam_grove | 5:96cb82af9996 | 15 | } |
| sam_grove | 5:96cb82af9996 | 16 | } |
| sam_grove | 5:96cb82af9996 | 17 | |
| Wosser1sProductions | 6:0c31964f8cf2 | 18 | void pc_recv() { |
| sam_grove | 5:96cb82af9996 | 19 | led4 = !led4; |
| sam_grove | 5:96cb82af9996 | 20 | while(pc.readable()) { |
| mbedAustin | 4:ba9100d52e48 | 21 | dev.putc(pc.getc()); |
| mbedAustin | 0:59bec1fd956e | 22 | } |
| mbedAustin | 0:59bec1fd956e | 23 | } |
| mbedAustin | 4:ba9100d52e48 | 24 | |
| Wosser1sProductions | 6:0c31964f8cf2 | 25 | int main() { |
| Wosser1sProductions | 6:0c31964f8cf2 | 26 | #define BAUT 115200 |
| Wosser1sProductions | 6:0c31964f8cf2 | 27 | //#define BAUT 74880 |
| Wosser1sProductions | 6:0c31964f8cf2 | 28 | //#define BAUT 9600 |
| Wosser1sProductions | 6:0c31964f8cf2 | 29 | |
| Wosser1sProductions | 6:0c31964f8cf2 | 30 | pc.baud(BAUT); |
| Wosser1sProductions | 6:0c31964f8cf2 | 31 | dev.baud(BAUT); |
| mbedAustin | 4:ba9100d52e48 | 32 | |
| Wosser1sProductions | 6:0c31964f8cf2 | 33 | pc.printf("Start...\r\n"); |
| Wosser1sProductions | 6:0c31964f8cf2 | 34 | |
| sam_grove | 5:96cb82af9996 | 35 | pc.attach(&pc_recv, Serial::RxIrq); |
| sam_grove | 5:96cb82af9996 | 36 | dev.attach(&dev_recv, Serial::RxIrq); |
| sam_grove | 5:96cb82af9996 | 37 | |
| mbedAustin | 4:ba9100d52e48 | 38 | while(1) { |
| sam_grove | 5:96cb82af9996 | 39 | sleep(); |
| mbedAustin | 4:ba9100d52e48 | 40 | } |
| mbedAustin | 4:ba9100d52e48 | 41 | } |
