C O
/
simpleCon
Oxford cwm serial 01
main.cpp@0:a2a851b6a23f, 2013-05-01 (annotated)
- Committer:
- codabash
- Date:
- Wed May 01 15:04:45 2013 +0000
- Revision:
- 0:a2a851b6a23f
Serial comms oxford - trial 01
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
codabash | 0:a2a851b6a23f | 1 | #include "mbed.h" |
codabash | 0:a2a851b6a23f | 2 | |
codabash | 0:a2a851b6a23f | 3 | DigitalOut l1(LED1); |
codabash | 0:a2a851b6a23f | 4 | DigitalOut l2(LED2); |
codabash | 0:a2a851b6a23f | 5 | DigitalOut l3(LED3); |
codabash | 0:a2a851b6a23f | 6 | |
codabash | 0:a2a851b6a23f | 7 | Serial talky(PTC4, PTC3); |
codabash | 0:a2a851b6a23f | 8 | Serial pc(USBTX, USBRX); |
codabash | 0:a2a851b6a23f | 9 | |
codabash | 0:a2a851b6a23f | 10 | int main() { |
codabash | 0:a2a851b6a23f | 11 | |
codabash | 0:a2a851b6a23f | 12 | l1=1; |
codabash | 0:a2a851b6a23f | 13 | l2=1; |
codabash | 0:a2a851b6a23f | 14 | l3=1; |
codabash | 0:a2a851b6a23f | 15 | while(1) { |
codabash | 0:a2a851b6a23f | 16 | if (pc.readable() && talky.writeable()){ |
codabash | 0:a2a851b6a23f | 17 | char c = pc.getc(); |
codabash | 0:a2a851b6a23f | 18 | l1=!l1; |
codabash | 0:a2a851b6a23f | 19 | talky.putc(c); |
codabash | 0:a2a851b6a23f | 20 | wait(0.01); |
codabash | 0:a2a851b6a23f | 21 | l1=!l1; |
codabash | 0:a2a851b6a23f | 22 | } |
codabash | 0:a2a851b6a23f | 23 | if (talky.readable() && pc.writeable()){ |
codabash | 0:a2a851b6a23f | 24 | l2=!l2; |
codabash | 0:a2a851b6a23f | 25 | char c2 = talky.getc(); |
codabash | 0:a2a851b6a23f | 26 | wait(0.01); |
codabash | 0:a2a851b6a23f | 27 | l2=!l2; |
codabash | 0:a2a851b6a23f | 28 | pc.putc(c2); |
codabash | 0:a2a851b6a23f | 29 | } |
codabash | 0:a2a851b6a23f | 30 | wait(0.01); |
codabash | 0:a2a851b6a23f | 31 | } |
codabash | 0:a2a851b6a23f | 32 | } |