Alessandro Ratti
/
Nucleo_read_hyperterminal
Bridge to test NBIoT schield
Diff: main.cpp
- Revision:
- 1:6d9b0810f7b8
- Parent:
- 0:aabe1b05abb9
--- a/main.cpp Wed Jun 21 17:53:41 2017 +0000 +++ b/main.cpp Wed Jan 24 13:09:33 2018 +0000 @@ -1,18 +1,49 @@ #include "mbed.h" -Serial pc(SERIAL_TX, SERIAL_RX); +Serial pc(SERIAL_TX, SERIAL_RX,9600); DigitalOut led(LED1); +DigitalOut BG96_reset(D7); +DigitalOut VBAT_3V8_EN(D11); +//DigitalOut BG96_W_DISABLE(D11); +DigitalOut BG96_PWRKEY(D10); + +Serial BG96_uart(PA_9, PA_10,9600); int main() { + BG96_reset = 1; + VBAT_3V8_EN = 1; +// BG96_W_DISABLE = 0; + BG96_PWRKEY = 1; pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); + wait( 0.3 ); + BG96_reset = 0; + wait( 0.1 ); while(1) { - char c = pc.getc(); // Read hyperterminal - if (c == '0') { - led = 0; // OFF + char c; + + if( BG96_uart.readable() != 0 ) + { + c = BG96_uart.getc(); + // c=pc.getc(); + pc.putc(c); } - if (c == '1') { - led = 1; // ON + if( pc.readable() != 0 ) + { + //c = BG96_uart.getc(); + c=pc.getc(); +/* + if( c == '!' ) + { + BG96_reset = 1; + pc.printf("reset\n"); + wait( 0.3 ); + BG96_reset = 0; + wait( 0.1 ); + } + else +*/ BG96_uart.putc(c); + } } }