Skip to content

Commit 7a29e02

Browse files
authored
Merge pull request #10530 from wajahat-ublox/c027_modem_flag
C027 Fix for modemOn flag
2 parents 2f1338b + fd0a2c7 commit 7a29e02

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ void ublox_mdm_powerOn(int usb)
5959
// turn on the mode by enabling power with power on pin low and correct USB detect level
6060
gpio_init_out_ex(&gpio, MDMUSBDET, usb ? 1 : 0); // USBDET: 0=disabled, 1=enabled
6161
if (!modemOn) { // enable modem
62+
modemOn = true;
6263
gpio_init_out_ex(&gpio, MDMEN, 1); // LDOEN: 1=on
6364
wait_ms(1); // wait until supply switched off
6465
// now we can safely enable the level shifters
6566
gpio_init_out_ex(&gpio, MDMLVLOE, 0); // LVLEN: 0=enabled (uart/gpio)
66-
if (gpsOn)
67+
if (gpsOn) {
6768
gpio_init_out_ex(&gpio, MDMILVLOE, 1); // ILVLEN: 1=enabled (i2c)
69+
}
6870
}
6971
}
7072

@@ -78,32 +80,35 @@ void ublox_mdm_powerOff(void)
7880
{
7981
gpio_t gpio;
8082
if (modemOn) {
83+
modemOn = false;
8184
// diable all level shifters
8285
gpio_init_out_ex(&gpio, MDMILVLOE, 0); // ILVLEN: 0=disabled (i2c)
8386
gpio_init_out_ex(&gpio, MDMLVLOE, 1); // LVLEN: 1=disabled (uart/gpio)
8487
gpio_init_out_ex(&gpio,MDMUSBDET, 0); // USBDET: 0=disabled
8588
// now we can savely switch off the ldo
8689
gpio_init_out_ex(&gpio, MDMEN, 0); // LDOEN: 0=off
87-
modemOn = false;
8890
}
8991
}
9092

9193
void ublox_gps_powerOn(void)
9294
{
9395
gpio_t gpio;
9496
if (!gpsOn) {
97+
gpsOn = true;
9598
// switch on power supply
9699
gpio_init_out_ex(&gpio, GPSEN, 1); // LDOEN: 1=on
97100
wait_ms(1); // wait until supply switched off
98-
if (modemOn)
101+
if (modemOn) {
99102
gpio_init_out_ex(&gpio, MDMILVLOE, 1); // ILVLEN: 1=enabled (i2c)
103+
}
100104
}
101105
}
102106

103107
void ublox_gps_powerOff(void)
104108
{
105109
gpio_t gpio;
106110
if (gpsOn) {
111+
gpsOn = false;
107112
gpio_init_out_ex(&gpio, MDMILVLOE, 0); // ILVLEN: 0=disabled (i2c)
108113
gpio_init_out_ex(&gpio, GPSEN, 0); // LDOEN: 0=off
109114
}

0 commit comments

Comments
 (0)