UPAEP_AztechSat-1_Payloads
/
Serial_STX3
Versión 1.0 del programa para enviar un comando y recibir una respuesta del módulo STX3
main.cpp@0:5c60e855af70, 2017-10-21 (annotated)
- Committer:
- Sumobot
- Date:
- Sat Oct 21 18:29:14 2017 +0000
- Revision:
- 0:5c60e855af70
Versi?n 1.0 del programa para enviar un comando y recibir una respuesta del m?dulo STX3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sumobot | 0:5c60e855af70 | 1 | #include "mbed.h" |
Sumobot | 0:5c60e855af70 | 2 | #include "rtos.h" |
Sumobot | 0:5c60e855af70 | 3 | |
Sumobot | 0:5c60e855af70 | 4 | Serial pc(USBTX, USBRX, 9600); // tx, rx |
Sumobot | 0:5c60e855af70 | 5 | Serial device(p9, p10, 9600); // tx, rx |
Sumobot | 0:5c60e855af70 | 6 | DigitalOut RTS(p5); |
Sumobot | 0:5c60e855af70 | 7 | InterruptIn CTS(p6); |
Sumobot | 0:5c60e855af70 | 8 | Thread thread; |
Sumobot | 0:5c60e855af70 | 9 | |
Sumobot | 0:5c60e855af70 | 10 | |
Sumobot | 0:5c60e855af70 | 11 | void stx3() { |
Sumobot | 0:5c60e855af70 | 12 | pc.putc(device.getc()); |
Sumobot | 0:5c60e855af70 | 13 | } |
Sumobot | 0:5c60e855af70 | 14 | |
Sumobot | 0:5c60e855af70 | 15 | void cts() { |
Sumobot | 0:5c60e855af70 | 16 | Thread::wait(5); |
Sumobot | 0:5c60e855af70 | 17 | pc.printf("El valor de CTS es %f\n\r", CTS.read()); |
Sumobot | 0:5c60e855af70 | 18 | device.putc(0XAA); |
Sumobot | 0:5c60e855af70 | 19 | device.putc(0X05); |
Sumobot | 0:5c60e855af70 | 20 | device.putc(0X01); |
Sumobot | 0:5c60e855af70 | 21 | device.putc(0X50); |
Sumobot | 0:5c60e855af70 | 22 | device.putc(0XD5); |
Sumobot | 0:5c60e855af70 | 23 | RTS=1; |
Sumobot | 0:5c60e855af70 | 24 | } |
Sumobot | 0:5c60e855af70 | 25 | |
Sumobot | 0:5c60e855af70 | 26 | int main() { |
Sumobot | 0:5c60e855af70 | 27 | pc.printf("Hello World"); |
Sumobot | 0:5c60e855af70 | 28 | RTS=1; |
Sumobot | 0:5c60e855af70 | 29 | thread.start(stx3); |
Sumobot | 0:5c60e855af70 | 30 | while(1) { |
Sumobot | 0:5c60e855af70 | 31 | Thread::wait(9000); |
Sumobot | 0:5c60e855af70 | 32 | pc.printf("El valor de CTS es %f\n\r", CTS.read()); |
Sumobot | 0:5c60e855af70 | 33 | RTS=0; |
Sumobot | 0:5c60e855af70 | 34 | CTS.fall(&cts); |
Sumobot | 0:5c60e855af70 | 35 | } |
Sumobot | 0:5c60e855af70 | 36 | } |