Board support library for C027

Dependents:   IoTWorkshopLCD IoTWorkshopBuzzer IoTWorkshopSensors C027_USSDTest ... more

Fork of C027 by u-blox

/media/uploads/ublox/c027_pinout_new.png

Committer:
mazgch
Date:
Fri Oct 25 08:46:43 2013 +0000
Revision:
7:e3eab86f1de9
Parent:
6:e11bf54dd344
Child:
8:a356376db984
added function to power and reset the modules on the board; make sure the correct board revision is selected

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 2:b7bd3660ff64 1 /* Platform source file, for the u-blox C27-C20/U20/G35
mazgch 2:b7bd3660ff64 2 * mbed Internet of Things Starter Kit
mazgch 2:b7bd3660ff64 3 * http://mbed.org/platforms/u-blox-C027/
mazgch 2:b7bd3660ff64 4 *
mazgch 2:b7bd3660ff64 5 */
mazgch 2:b7bd3660ff64 6
mazgch 2:b7bd3660ff64 7 #include "C027.h"
mazgch 2:b7bd3660ff64 8
mazgch 2:b7bd3660ff64 9 void mbed_die(void)
mazgch 2:b7bd3660ff64 10 {
mazgch 2:b7bd3660ff64 11 for (;;)
mazgch 2:b7bd3660ff64 12 {
mazgch 2:b7bd3660ff64 13 // nothing to do here
mazgch 2:b7bd3660ff64 14
mazgch 3:b54777b90da1 15 // we do not have fancy leds that
mazgch 3:b54777b90da1 16 // can be flashed on the C027
mazgch 2:b7bd3660ff64 17 }
mazgch 2:b7bd3660ff64 18 }
mazgch 2:b7bd3660ff64 19
mazgch 6:e11bf54dd344 20 C027::C027() :
mazgch 7:e3eab86f1de9 21 mdmEn(MDMEN),
mazgch 7:e3eab86f1de9 22 #ifndef C027_REVA
mazgch 7:e3eab86f1de9 23 mdmRst(MDMRST),
mazgch 7:e3eab86f1de9 24 #endif
mazgch 7:e3eab86f1de9 25 mdmPwrOn(MDMPWRON), mdmRts(MDMRTS),
mazgch 6:e11bf54dd344 26 gpsEn(GPSEN), gpsRst(GPSRST)
mazgch 6:e11bf54dd344 27 {
mazgch 7:e3eab86f1de9 28 // we start with the gps disabled
mazgch 6:e11bf54dd344 29 gpsEn = 0; // LDOEN: 1=on,0=off
mazgch 6:e11bf54dd344 30 gpsRst = 0; // RESET: 0=reset,1=operating
mazgch 6:e11bf54dd344 31 gpsIsEnabled = false;
mazgch 7:e3eab86f1de9 32 // we start with the modem disabled
mazgch 6:e11bf54dd344 33 mdmPwrOn = 1; // PWRON: 1=idle,0=action
mazgch 6:e11bf54dd344 34 mdmRts = 0; // RTS. 0=ready to send
mazgch 6:e11bf54dd344 35 mdmEn = 0; // LDOEN: 1=on,0=off
mazgch 7:e3eab86f1de9 36 #ifndef C027_REVA
mazgch 6:e11bf54dd344 37 mdmRst = 0; // RESET: 0=reset,1=operating
mazgch 7:e3eab86f1de9 38 #endif
mazgch 6:e11bf54dd344 39 mdmIsEnabled = false;
mazgch 6:e11bf54dd344 40 }
mazgch 6:e11bf54dd344 41
mazgch 6:e11bf54dd344 42 void C027::mdmPower(bool enable)
mazgch 6:e11bf54dd344 43 {
mazgch 7:e3eab86f1de9 44 if (!mdmIsEnabled && enable) // enable modem
mazgch 6:e11bf54dd344 45 {
mazgch 7:e3eab86f1de9 46 #ifdef C027_REVA
mazgch 7:e3eab86f1de9 47 // we need the gps ldo for the level shifters of the modem
mazgch 7:e3eab86f1de9 48 gpsEn = 1; // LDOEN(gps): 0=off -> 1=on
mazgch 7:e3eab86f1de9 49 #endif
mazgch 7:e3eab86f1de9 50 mdmPwrOn = 1; // PWRON: 1=idle
mazgch 7:e3eab86f1de9 51 mdmEn = 0; // LDOEN: 0=off
mazgch 7:e3eab86f1de9 52 #ifndef C027_REVA
mazgch 7:e3eab86f1de9 53 mdmRst = 0; // RESET: 0=reset
mazgch 7:e3eab86f1de9 54 #endif
mazgch 7:e3eab86f1de9 55 wait_ms(1); // wait until stable
mazgch 7:e3eab86f1de9 56 mdmEn = 1; // LDOEN: 0=off -> 1=on
mazgch 7:e3eab86f1de9 57 wait_ms(50); // power on sequence is triggered by keeping reset 50ms low
mazgch 7:e3eab86f1de9 58 #ifndef C027_REVA
mazgch 7:e3eab86f1de9 59 mdmRst = 1; // RESET: 0=reset -> 1=operating
mazgch 6:e11bf54dd344 60 #endif
mazgch 7:e3eab86f1de9 61 mdmIsEnabled = true;
mazgch 7:e3eab86f1de9 62 // the modem schould be fully ready after 3000ms
mazgch 7:e3eab86f1de9 63 }
mazgch 7:e3eab86f1de9 64 else if (mdmIsEnabled && !enable) // disable modem
mazgch 7:e3eab86f1de9 65 {
mazgch 7:e3eab86f1de9 66 mdmIsEnabled = false;
mazgch 7:e3eab86f1de9 67 // initiate power off sequence by setting PwnOn low for >1s
mazgch 7:e3eab86f1de9 68 mdmPwrOn = 0; // PWRON: 0=active
mazgch 7:e3eab86f1de9 69 wait_ms(1000);
mazgch 7:e3eab86f1de9 70 mdmPwrOn = 1; // PWRON: 0=active -> 1=idle
mazgch 7:e3eab86f1de9 71 // now we can savely switch off the ldo
mazgch 7:e3eab86f1de9 72 #ifndef C027_REVA
mazgch 7:e3eab86f1de9 73 mdmRst = 0; // RESET: 1=operating -> 0=reset
mazgch 7:e3eab86f1de9 74 #endif
mazgch 7:e3eab86f1de9 75 mdmEn = 0; // LDOEN: 1=on -> 0=off
mazgch 7:e3eab86f1de9 76 #ifdef C027_REVA
mazgch 7:e3eab86f1de9 77 // the gps ldo may no longer be needed level shifters of the modem
mazgch 7:e3eab86f1de9 78 // so we switch it off if the gps is not enabled
mazgch 7:e3eab86f1de9 79 if (!gpsIsEnabled)
mazgch 7:e3eab86f1de9 80 gpsEn = 0; // LDOEN(gps): 1=on -> 0=off
mazgch 7:e3eab86f1de9 81 #endif
mazgch 6:e11bf54dd344 82 }
mazgch 6:e11bf54dd344 83 }
mazgch 6:e11bf54dd344 84
mazgch 6:e11bf54dd344 85 void C027::mdmReset(void)
mazgch 6:e11bf54dd344 86 {
mazgch 7:e3eab86f1de9 87 #ifndef C027_REVA
mazgch 6:e11bf54dd344 88 if (mdmIsEnabled)
mazgch 6:e11bf54dd344 89 {
mazgch 7:e3eab86f1de9 90 // power on sequence is triggered by 50ms reset low
mazgch 6:e11bf54dd344 91 mdmRst = 0; // RESET: 0=reset,1=operating
mazgch 7:e3eab86f1de9 92 wait_ms(50);
mazgch 6:e11bf54dd344 93 mdmRst = 1; // RESET: 1=operating,0=reset
mazgch 6:e11bf54dd344 94 }
mazgch 7:e3eab86f1de9 95 #endif
mazgch 7:e3eab86f1de9 96 }
mazgch 7:e3eab86f1de9 97
mazgch 7:e3eab86f1de9 98 void C027::gpsPower(bool enable)
mazgch 7:e3eab86f1de9 99 {
mazgch 7:e3eab86f1de9 100 if (!gpsIsEnabled && enable) // enable gps
mazgch 7:e3eab86f1de9 101 {
mazgch 7:e3eab86f1de9 102 gpsRst = 0; // RESET: 0=reset
mazgch 7:e3eab86f1de9 103 gpsEn = 1; // LDOEN: 0=off -> 1=on
mazgch 7:e3eab86f1de9 104 wait_ms(1); // wait until stable
mazgch 7:e3eab86f1de9 105 gpsRst = 1; // RESET: 0=reset -> 1=operating
mazgch 7:e3eab86f1de9 106 gpsIsEnabled = true;
mazgch 7:e3eab86f1de9 107 // the gps schould be fully ready after 50ms
mazgch 7:e3eab86f1de9 108 }
mazgch 7:e3eab86f1de9 109 else if (gpsIsEnabled && !enable) // diasble gps
mazgch 7:e3eab86f1de9 110 {
mazgch 7:e3eab86f1de9 111 gpsIsEnabled = false;
mazgch 7:e3eab86f1de9 112 gpsRst = 0; // RESET: 1=operating -> 0=reset
mazgch 7:e3eab86f1de9 113 #ifdef C027_REVA
mazgch 7:e3eab86f1de9 114 // the gps ldo may have to remain enabled for the level shifters of the modem
mazgch 7:e3eab86f1de9 115 if (!mdmIsEnabled)
mazgch 7:e3eab86f1de9 116 gpsEn = 0; // LDOEN: 1=on -> 0=off
mazgch 7:e3eab86f1de9 117 #else
mazgch 7:e3eab86f1de9 118 gpsEn = 0; // LDOEN: 1=on -> 0=off
mazgch 7:e3eab86f1de9 119 #endif
mazgch 7:e3eab86f1de9 120 }
mazgch 6:e11bf54dd344 121 }
mazgch 6:e11bf54dd344 122
mazgch 6:e11bf54dd344 123 void C027::gpsReset(void)
mazgch 6:e11bf54dd344 124 {
mazgch 6:e11bf54dd344 125 if (gpsIsEnabled)
mazgch 6:e11bf54dd344 126 {
mazgch 6:e11bf54dd344 127 gpsRst = 0; // RESET: 0=reset,1=operating
mazgch 6:e11bf54dd344 128 wait_ms(1);
mazgch 6:e11bf54dd344 129 gpsRst = 1; // RESET: 1=operating,0=reset
mazgch 6:e11bf54dd344 130 }
mazgch 6:e11bf54dd344 131 }