Template for LAB10_Oppgave3
Dependencies: mbed
Import program
00001 #include "mbed.h" 00002 00003 Serial serial3(PB_9, PB_8); // tx, rx 00004 Serial pc(USBTX, USBRX); // tx, rx 00005 00006 void serial3Rx() 00007 { pc.putc(serial3.getc()); 00008 } 00009 00010 void pcRx() 00011 { serial3.putc(pc.getc()); 00012 } 00013 00014 int main() 00015 { 00016 serial3.attach(&serial3Rx); 00017 pc.attach(&pcRx); 00018 00019 while(1) { 00020 wait(1); 00021 } 00022 } 00023 00024 00025 00026
main.cpp@0:00b5baa80198, 2015-11-04 (annotated)
- Committer:
- rlanghbv
- Date:
- Wed Nov 04 20:58:44 2015 +0000
- Revision:
- 0:00b5baa80198
- Child:
- 1:05b1d2a203e5
Serial3 Loopback
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rlanghbv | 0:00b5baa80198 | 1 | #include "mbed.h" |
rlanghbv | 0:00b5baa80198 | 2 | |
rlanghbv | 0:00b5baa80198 | 3 | Serial serial3(PB_9, PB_8); // tx, rx |
rlanghbv | 0:00b5baa80198 | 4 | Serial pc(USBTX, USBRX); // tx, rx |
rlanghbv | 0:00b5baa80198 | 5 | |
rlanghbv | 0:00b5baa80198 | 6 | void serial3Rx() |
rlanghbv | 0:00b5baa80198 | 7 | { |
rlanghbv | 0:00b5baa80198 | 8 | putchar(serial3.getc()); |
rlanghbv | 0:00b5baa80198 | 9 | } |
rlanghbv | 0:00b5baa80198 | 10 | |
rlanghbv | 0:00b5baa80198 | 11 | void pcRx() |
rlanghbv | 0:00b5baa80198 | 12 | { |
rlanghbv | 0:00b5baa80198 | 13 | serial3.putc(pc.getc()); |
rlanghbv | 0:00b5baa80198 | 14 | } |
rlanghbv | 0:00b5baa80198 | 15 | |
rlanghbv | 0:00b5baa80198 | 16 | int main() |
rlanghbv | 0:00b5baa80198 | 17 | { |
rlanghbv | 0:00b5baa80198 | 18 | serial3.attach(&serial3Rx); |
rlanghbv | 0:00b5baa80198 | 19 | pc.attach(&pcRx); |
rlanghbv | 0:00b5baa80198 | 20 | |
rlanghbv | 0:00b5baa80198 | 21 | |
rlanghbv | 0:00b5baa80198 | 22 | while(1) |
rlanghbv | 0:00b5baa80198 | 23 | { |
rlanghbv | 0:00b5baa80198 | 24 | wait(1); |
rlanghbv | 0:00b5baa80198 | 25 | } |
rlanghbv | 0:00b5baa80198 | 26 | } |
rlanghbv | 0:00b5baa80198 | 27 | |
rlanghbv | 0:00b5baa80198 | 28 | |
rlanghbv | 0:00b5baa80198 | 29 | |
rlanghbv | 0:00b5baa80198 | 30 |