Pablo Andrés Araya Castillo
/
AT_Command
atfmsf
main.cpp@0:f1d62de1fdff, 2019-06-04 (annotated)
- Committer:
- williequesada
- Date:
- Tue Jun 04 19:34:45 2019 +0000
- Revision:
- 0:f1d62de1fdff
pablo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
williequesada | 0:f1d62de1fdff | 1 | #include "mbed.h" |
williequesada | 0:f1d62de1fdff | 2 | |
williequesada | 0:f1d62de1fdff | 3 | //------------------------------------ |
williequesada | 0:f1d62de1fdff | 4 | // Hyperterminal configuration |
williequesada | 0:f1d62de1fdff | 5 | // 9600 bauds, 8-bit data, no parity |
williequesada | 0:f1d62de1fdff | 6 | //------------------------------------ |
williequesada | 0:f1d62de1fdff | 7 | |
williequesada | 0:f1d62de1fdff | 8 | RawSerial Computer(SERIAL_TX, SERIAL_RX,9600); // tx, rx |
williequesada | 0:f1d62de1fdff | 9 | RawSerial Gsm(PA_0,PA_1,19200); |
williequesada | 0:f1d62de1fdff | 10 | DigitalOut led(LED2); |
williequesada | 0:f1d62de1fdff | 11 | DigitalOut ResetSIM900(PA_10); |
williequesada | 0:f1d62de1fdff | 12 | DigitalOut EnableSIM900(PB_0); |
williequesada | 0:f1d62de1fdff | 13 | char c; |
williequesada | 0:f1d62de1fdff | 14 | |
williequesada | 0:f1d62de1fdff | 15 | DigitalOut myled(LED1); |
williequesada | 0:f1d62de1fdff | 16 | |
williequesada | 0:f1d62de1fdff | 17 | void Interrupt_Sim900() |
williequesada | 0:f1d62de1fdff | 18 | { |
williequesada | 0:f1d62de1fdff | 19 | if(Gsm.readable()) { |
williequesada | 0:f1d62de1fdff | 20 | c=Gsm.getc(); |
williequesada | 0:f1d62de1fdff | 21 | Computer.putc(c); |
williequesada | 0:f1d62de1fdff | 22 | } |
williequesada | 0:f1d62de1fdff | 23 | } |
williequesada | 0:f1d62de1fdff | 24 | |
williequesada | 0:f1d62de1fdff | 25 | void Interrupt_Computer() |
williequesada | 0:f1d62de1fdff | 26 | { |
williequesada | 0:f1d62de1fdff | 27 | c=Computer.getc(); |
williequesada | 0:f1d62de1fdff | 28 | Gsm.putc(c); |
williequesada | 0:f1d62de1fdff | 29 | } |
williequesada | 0:f1d62de1fdff | 30 | |
williequesada | 0:f1d62de1fdff | 31 | int main() |
williequesada | 0:f1d62de1fdff | 32 | { |
williequesada | 0:f1d62de1fdff | 33 | Gsm.attach(&Interrupt_Sim900); |
williequesada | 0:f1d62de1fdff | 34 | Computer.attach(&Interrupt_Computer); |
williequesada | 0:f1d62de1fdff | 35 | Computer.printf("Commmandos AT\n"); |
williequesada | 0:f1d62de1fdff | 36 | ResetSIM900=0; |
williequesada | 0:f1d62de1fdff | 37 | EnableSIM900=1; |
williequesada | 0:f1d62de1fdff | 38 | wait(1); |
williequesada | 0:f1d62de1fdff | 39 | EnableSIM900=0; |
williequesada | 0:f1d62de1fdff | 40 | while(1) { |
williequesada | 0:f1d62de1fdff | 41 | wait(1); |
williequesada | 0:f1d62de1fdff | 42 | led = !led; |
williequesada | 0:f1d62de1fdff | 43 | } |
williequesada | 0:f1d62de1fdff | 44 | } |