V3.0
Dependencies: mbed
Fork of Serial_STX3_2 by
main.cpp@1:405cd679275c, 2017-10-25 (annotated)
- Committer:
- Sumobot
- Date:
- Wed Oct 25 21:24:06 2017 +0000
- Revision:
- 1:405cd679275c
- Parent:
- 0:c2333cdfbcfa
Pull Up; RX-TX
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sumobot | 0:c2333cdfbcfa | 1 | #include "mbed.h" |
Sumobot | 0:c2333cdfbcfa | 2 | |
Sumobot | 1:405cd679275c | 3 | |
Sumobot | 0:c2333cdfbcfa | 4 | Serial pc(USBTX, USBRX, 9600); // tx, rx |
Sumobot | 0:c2333cdfbcfa | 5 | Serial device(p9, p10, 9600); // tx, rx |
Sumobot | 1:405cd679275c | 6 | DigitalOut RTS(p7, 1); |
Sumobot | 1:405cd679275c | 7 | DigitalIn CTS(p8, PullUp); |
Sumobot | 1:405cd679275c | 8 | int flag=1; |
Sumobot | 1:405cd679275c | 9 | //Timer t; |
Sumobot | 0:c2333cdfbcfa | 10 | |
Sumobot | 0:c2333cdfbcfa | 11 | int main() { |
Sumobot | 1:405cd679275c | 12 | //CTS.mode(PullUp); |
Sumobot | 1:405cd679275c | 13 | wait(5); |
Sumobot | 1:405cd679275c | 14 | pc.printf("El valor de CTS 1 es %d\n\r",CTS.read()); |
Sumobot | 1:405cd679275c | 15 | pc.printf("El valor de RTS 1 es %d\n\r",RTS.read()); |
Sumobot | 0:c2333cdfbcfa | 16 | RTS=0; |
Sumobot | 0:c2333cdfbcfa | 17 | while(flag==1){ |
Sumobot | 1:405cd679275c | 18 | //t.start(); |
Sumobot | 0:c2333cdfbcfa | 19 | flag=CTS.read(); |
Sumobot | 1:405cd679275c | 20 | //wait(.1); |
Sumobot | 0:c2333cdfbcfa | 21 | pc.printf("El valor de flag es %d\n\r", flag); |
Sumobot | 0:c2333cdfbcfa | 22 | } |
Sumobot | 1:405cd679275c | 23 | wait(.1); |
Sumobot | 1:405cd679275c | 24 | device.putc(0XAA); |
Sumobot | 0:c2333cdfbcfa | 25 | device.putc(0X05); |
Sumobot | 1:405cd679275c | 26 | device.putc(0X04); |
Sumobot | 1:405cd679275c | 27 | device.putc(0XFD); |
Sumobot | 1:405cd679275c | 28 | device.putc(0X82); |
Sumobot | 0:c2333cdfbcfa | 29 | wait(.1); |
Sumobot | 0:c2333cdfbcfa | 30 | RTS=1; |
Sumobot | 1:405cd679275c | 31 | //pc.printf("El tiempo es %f\n\r", t.read()); |
Sumobot | 1:405cd679275c | 32 | while(1) { |
Sumobot | 1:405cd679275c | 33 | if(device.readable()) { |
Sumobot | 1:405cd679275c | 34 | pc.putc(device.getc()); |
Sumobot | 1:405cd679275c | 35 | } |
Sumobot | 0:c2333cdfbcfa | 36 | } |
Sumobot | 0:c2333cdfbcfa | 37 | } |