Board support library for C027
Dependents: IoTWorkshopLCD IoTWorkshopBuzzer IoTWorkshopSensors C027_USSDTest ... more
Fork of C027 by
C027.cpp
- Committer:
- mazgch
- Date:
- 2013-11-10
- Revision:
- 12:31fb5ff9fef5
- Parent:
- 11:722101675ce4
- Child:
- 13:fb30e9923a7b
File content as of revision 12:31fb5ff9fef5:
/* Platform source file, for the u-blox C27-C20/U20/G35 * mbed Internet of Things Starter Kit * http://mbed.org/platforms/u-blox-C027/ * */ #include "C027.h" void mbed_die(void) { DigitalOut led(LED); led = 0; // Send SOS in Morse Code: // "... --- ... " const char sos[] = "=.=.=...===.===.===...=.=.=......"; const int dot = 100; // length of the dot in milliseconds (typical: 50-100 ms) // lengths of symbols: // di = dot // dah = 3 dot // char space = 3 dot // word space = 6 dot for (int i = 0; /* nothing */; i = sos[i+1] ? i+1 : 0) { led = (sos[i] == '='); wait_ms(dot); } } C027::C027() : mdmEn(MDMEN), mdmRst(MDMRST), mdmPwrOn(MDMPWRON), // MDM CTRL mdmRts(MDMRTS), mdmLvlOe(MDMLVLOE), mdmUsbDet(MDMUSBDET), // MDM IF gpsEn(GPSEN), gpsRst(GPSRST) // GPS CTRL { // we start with the gps disabled gpsEn = 0; // LDOEN: 1=on,0=off gpsRst = 0; // RESET: 0=reset,1=operating gpsIsEnabled = false; // we start with the modem disabled mdmLvlOe = 1; // LVLEN: 1=disabled mdmUsbDet = 0; // USBDET: 0=disabled mdmPwrOn = 1; // PWRON: 1=idle, 0=action mdmRts = 0; // RTS. 0=ready to send mdmEn = 0; // LDOEN: 1=on, 0=off mdmRst = 0; // RESET: 0=reset, 1=operating mdmIsEnabled = false; } void C027::mdmPower(bool enable) { if (!mdmIsEnabled && enable) // enable modem { #ifdef C027_REVA // we need the gps ldo for the level shifters of the modem gpsEn = 1; // LDOEN(gps): 0=off -> 1=on #endif mdmPwrOn = 1; // PWRON: 1=idle mdmEn = 0; // LDOEN: 0=off mdmRst = 0; // RESET: 0=reset mdmLvlOe = 1; // LVLEN: 1=disabled mdmUsbDet = 0; // USBDET: 0=disabled wait_ms( 10); // wait until supply switched off mdmEn = 1; // LDOEN: 0=off -> 1=on wait_ms( 10); // wait until supply stable and on wait_ms(300); // power on sequence is triggered by keeping reset 50ms-300ms low mdmRst = 1; // RESET: 0=reset -> 1=operating mdmLvlOe = 0; // LVLEN: 0=enabled mdmUsbDet = 1; // USBDET: 1=enabled mdmIsEnabled = true; // the interfaces of the modem should be fully ready after a certain period // LISA-U200 5000ms // SARA-G350 3000ms // LISA-C200 wait_ms(1000); } else if (mdmIsEnabled && !enable) // disable modem { mdmIsEnabled = false; // initiate power off sequence by setting PwnOn low for >1s mdmLvlOe = 1; // LVLEN: 1=disabled mdmUsbDet = 0; // USBDET: 0=disabled mdmPwrOn = 0; // PWRON: 0=active wait_ms(1000); // send to sleep mdmPwrOn = 1; // PWRON: 0=active -> 1=idle // now we can savely switch off the ldo mdmRst = 0; // RESET: 1=operating -> 0=reset mdmEn = 0; // LDOEN: 1=on -> 0=off #ifdef C027_REVA // the gps ldo may no longer be needed level shifters of the modem // so we switch it off if the gps is not enabled if (!gpsIsEnabled) gpsEn = 0; // LDOEN(gps): 1=on -> 0=off #endif } } void C027::mdmReset(void) { if (mdmIsEnabled) { mdmRst = 0; // RESET: 0=reset // power on sequence is triggered by reset low // LISA-U200 50ms // SARA-G350 50ms // LISA-C200 300ms wait_ms(300); mdmRst = 1; // RESET: 0=reset -> 1=operating } } void C027::mdmWakeup(void) { if (mdmIsEnabled) { mdmPwrOn = 0; // wakeup the device by low pulse: // LISA-U200 50-80us // SARA-G350 5ms // LISA-C200 150ms wait_ms(150); mdmPwrOn = 1; } } void C027::mdmSleep(void) { if (mdmIsEnabled) { mdmPwrOn = 0; // going to sleep is triggerd by low pulse: // LISA-U200 1000ms // SARA-G350 n/a // LISA-C200 n/a wait_ms(1000); mdmPwrOn = 1; } } void C027::gpsPower(bool enable) { if (!gpsIsEnabled && enable) // enable gps { gpsRst = 0; // RESET: 0=reset gpsEn = 1; // LDOEN: 0=off -> 1=on wait_ms(1); // wait until stable gpsRst = 1; // RESET: 0=reset -> 1=operating gpsIsEnabled = true; // the gps schould be fully ready after 50ms } else if (gpsIsEnabled && !enable) // diasble gps { gpsIsEnabled = false; gpsRst = 0; // RESET: 1=operating -> 0=reset #ifdef C027_REVA // the gps ldo may have to remain enabled for the level shifters of the modem if (!mdmIsEnabled) gpsEn = 0; // LDOEN: 1=on -> 0=off #else gpsEn = 0; // LDOEN: 1=on -> 0=off #endif } } void C027::gpsReset(void) { if (gpsIsEnabled) { gpsRst = 0; // RESET: 0=reset,1=operating wait_ms(1); gpsRst = 1; // RESET: 1=operating,0=reset } }