![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.
Dependencies: mbed FXOS8700CQ MODSERIAL
Diff: main.cpp
- Revision:
- 14:0c353e212296
- Parent:
- 12:7c94ec5069dc
- Child:
- 16:17c5916f2d12
diff -r df9c49662797 -r 0c353e212296 main.cpp --- a/main.cpp Tue Jul 12 21:58:17 2016 +0000 +++ b/main.cpp Wed Jul 13 00:39:08 2016 +0000 @@ -47,6 +47,8 @@ DigitalOut mdm_power_on(PTB9); // 0 = turn modem on, 1 = turn modem off (should be held high for >5 seconds to cycle modem) DigitalOut mdm_wakeup_in(PTC2); // 0 = let modem sleep, 1 = keep modem awake -- Note: pulled high on shield +DigitalOut mdm_reset(PTC12); // active high + DigitalOut shield_3v3_1v8_sig_trans_ena(PTC4); // 0 = disabled (all signals high impedence, 1 = translation active DigitalOut mdm_uart1_cts(PTD0); @@ -132,9 +134,23 @@ } int mdm_init(void) { - // disable signal level translator + // disable signal level translator (necessary + // for the modem to boot properly) shield_3v3_1v8_sig_trans_ena = 0; + // Hard reset the modem (doesn't go through + // the signal level translator) + mdm_reset = 1; + + // wait a moment for the modem to react + wait_ms(10); + + // Let modem boot + mdm_reset = 0; + + // wait a moment for the modem to react + wait(1.0); + // power modem on //off mdm_power_on = 0; //1; @@ -151,6 +167,13 @@ mdm_uart1_cts = 0; + // wait a moment for the modem to react to signal + // conditions while the level translator is disabled + // (sorry, don't have enough information to know + // what exactly the modem is doing with the current + // pin settings) + wait(1.0); + // enable the signal level translator to start // modem reset process (modem will be powered down) shield_3v3_1v8_sig_trans_ena = 1; @@ -163,7 +186,7 @@ const char * rsp_lst[] = { ok_str, error_str, NULL }; int rc = mdm_sendAtCmd("AT", rsp_lst, 500); if (rc == 0) - return timer.read(); + return true; //timer.read(); wait_ms(1000 - (timer.read_ms() % 1000)); pc.printf("\r%d",timer.read_ms()/1000); } @@ -332,11 +355,12 @@ // Initialize the modem printf(GRN "Modem initializing... will take up to 60 seconds" DEF "\r\n"); - i=mdm_init(); - if (!i) { - pc.printf(RED "Modem initialization failed!" DEF "\n"); - while (1); - } + do { + i=mdm_init(); + if (!i) { + pc.printf(RED "Modem initialization failed!" DEF "\n"); + } + } while (!i); //Software init software_init_mdm();