From 9c43e96a8ee4f2f39615d7412d31c70bd8b5c343 Mon Sep 17 00:00:00 2001 From: unsurv <43016521+unsurv@users.noreply.github.com> Date: Sat, 18 Jul 2020 21:16:59 +0200 Subject: [PATCH 1/5] implemented Power On/Off (UBX-RXM-PMREQ) --- src/SparkFun_Ublox_Arduino_Library.cpp | 107 +++++++++++++++++++++++++ src/SparkFun_Ublox_Arduino_Library.h | 2 + 2 files changed, 109 insertions(+) diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index a1f47a3..bdc2d76 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2569,6 +2569,113 @@ uint8_t SFE_UBLOX_GPS::getPowerSaveMode(uint16_t maxWait) return (payloadCfg[1]); // Return the low power mode } +// Powers off the GPS device for a given duration to reduce power consumption. +// WARNING: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! +boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) +{ + // use durationInMs = 0 for infinite duration + if (_printDebug == true) + { + _debugSerial->print(F("Powering off for ")); + _debugSerial->print(durationInMs); + _debugSerial->println(" ms"); + } + + // Power off device using UBX-RXM-PMREQ + packetCfg.cls = UBX_CLASS_RXM; // 0x02 + packetCfg.id = UBX_RXM_PMREQ; // 0x41 + packetCfg.len = 8; + packetCfg.startingSpot = 0; + + // duration + // big endian to little endian, switch byte order + payloadCfg[0] = (durationInMs >> (8*0)) & 0xff; + payloadCfg[1] = (durationInMs >> (8*1)) & 0xff; + payloadCfg[2] = (durationInMs >> (8*2)) & 0xff; + payloadCfg[3] = (durationInMs >> (8*3)) & 0xff; + + // check for "not acknowledged" command + return (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_COMMAND_NACK); +} + +// Powers off the GPS device for a given duration to reduce power consumption. +// While powered off it can be woken up by creating a falling or rising voltage edge on the specified pin. +// WARNING: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! +boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait) +{ + // use durationInMs = 0 for infinite duration + if (_printDebug == true) + { + _debugSerial->print(F("Powering off for ")); + _debugSerial->print(durationInMs); + _debugSerial->println(" ms"); + } + + // Power off device using UBX-RXM-PMREQ + packetCfg.cls = UBX_CLASS_RXM; // 0x02 + packetCfg.id = UBX_RXM_PMREQ; // 0x41 + packetCfg.len = 16; + packetCfg.startingSpot = 0; + + payloadCfg[0] = 0x00; // message version + // bytes 1-3 are reserved + + // duration + // big endian to little endian, switch byte order + payloadCfg[4] = (durationInMs >> (8*0)) & 0xff; + payloadCfg[5] = (durationInMs >> (8*1)) & 0xff; + payloadCfg[6] = (durationInMs >> (8*2)) & 0xff; + payloadCfg[7] = (durationInMs >> (8*3)) & 0xff; + + // flags + payloadCfg[8] = 0x00; + payloadCfg[9] = 0x00; + payloadCfg[10] = 0x00; + + // disables USB interface when powering off, defaults to true + if (forceWhileUsb) + { + payloadCfg[11] = 0x04; + } + else + { + payloadCfg[11] = 0x02; + } + + // wakeUpSources + payloadCfg[12] = 0x00; + payloadCfg[13] = 0x00; + payloadCfg[14] = 0x00; + + // wakeupPin mapping, defaults to EXINT0, limited to one pin for now + // last byte of wakeUpSources + uint8_t terminatingByte; + + switch (wakeupPin) + { + case 0: // UART RX + terminatingByte = 0x08; // 0000 1000 + break; + + case 1: // EXINT 0 + terminatingByte = 0x20; // 0010 0000 + break; + + case 2: // EXINT 1 + terminatingByte = 0x40; // 0100 0000 + break; + + case 3: // SPI CS + terminatingByte = 0x80; // 1000 0000 + break; + } + + payloadCfg[15] = terminatingByte; + + // check for "not acknowledged" command + return (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_COMMAND_NACK); +} + //Change the dynamic platform model using UBX-CFG-NAV5 //Possible values are: //PORTABLE,STATIONARY,PEDESTRIAN,AUTOMOTIVE,SEA, diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index ab28e22..50265bf 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -641,6 +641,8 @@ class SFE_UBLOX_GPS boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100); uint8_t getPowerSaveMode(uint16_t maxWait = 1100); // Returns 255 if the sendCommand fails + boolean powerOff(uint32_t durationInMs, uint16_t maxWait = 1100); + boolean powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin = 1, boolean forceWhileUsb = true, uint16_t maxWait = 1100); //Change the dynamic platform model using UBX-CFG-NAV5 boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100); From e8246caa6a7a2c1c6ee450002381e122e6e6a28e Mon Sep 17 00:00:00 2001 From: unsurv <43016521+unsurv@users.noreply.github.com> Date: Sat, 18 Jul 2020 23:26:55 +0200 Subject: [PATCH 2/5] added additional warning + keywords.txt --- keywords.txt | 2 ++ src/SparkFun_Ublox_Arduino_Library.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/keywords.txt b/keywords.txt index 9a9d8af..72d4636 100644 --- a/keywords.txt +++ b/keywords.txt @@ -139,6 +139,8 @@ setDynamicModel KEYWORD2 getDynamicModel KEYWORD2 powerSaveMode KEYWORD2 getPowerSaveMode KEYWORD2 +powerOff KEYWORD2 +powerOffWithInterrupt KEYWORD2 configureMessage KEYWORD2 enableMessage KEYWORD2 diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index bdc2d76..9d0a961 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2600,6 +2600,7 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) // Powers off the GPS device for a given duration to reduce power consumption. // While powered off it can be woken up by creating a falling or rising voltage edge on the specified pin. +// WARNING: The GPS seems to detect small voltage edges on the interrupt pin. Works best when Microcontroller is in deepsleep. // WARNING: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait) { From 2580acb4d7e42a23fcb508d636606dfb77655cee Mon Sep 17 00:00:00 2001 From: unsurv <43016521+unsurv@users.noreply.github.com> Date: Mon, 20 Jul 2020 21:12:23 +0200 Subject: [PATCH 3/5] added check for maxWait = 0 + changes in description --- src/SparkFun_Ublox_Arduino_Library.cpp | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 9d0a961..aba041e 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2570,7 +2570,9 @@ uint8_t SFE_UBLOX_GPS::getPowerSaveMode(uint16_t maxWait) } // Powers off the GPS device for a given duration to reduce power consumption. -// WARNING: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! +// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! +// returns true if command has not failed +// returns false if command has not been acknowledged or maxWait = 0 boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) { // use durationInMs = 0 for infinite duration @@ -2594,14 +2596,24 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) payloadCfg[2] = (durationInMs >> (8*2)) & 0xff; payloadCfg[3] = (durationInMs >> (8*3)) & 0xff; - // check for "not acknowledged" command - return (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_COMMAND_NACK); + if (maxWait != 0) + { + // check for "not acknowledged" command + return (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_COMMAND_NACK); + } + else + { + sendCommand(&packetCfg, maxWait); + return false; // can't tell if command not acknowledged if maxWait = 0 + } } // Powers off the GPS device for a given duration to reduce power consumption. // While powered off it can be woken up by creating a falling or rising voltage edge on the specified pin. -// WARNING: The GPS seems to detect small voltage edges on the interrupt pin. Works best when Microcontroller is in deepsleep. -// WARNING: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! +// NOTE: The GPS seems to detect small voltage edges on the interrupt pin. Works best when Microcontroller is in deepsleep. +// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! +// returns true if command has not failed +// returns false if command has not been acknowledged or maxWait = 0 boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait) { // use durationInMs = 0 for infinite duration @@ -2673,8 +2685,16 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake payloadCfg[15] = terminatingByte; - // check for "not acknowledged" command - return (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_COMMAND_NACK); + if (maxWait != 0) + { + // check for "not acknowledged" command + return (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_COMMAND_NACK); + } + else + { + sendCommand(&packetCfg, maxWait); + return false; // can't tell if command not acknowledged if maxWait = 0 + } } //Change the dynamic platform model using UBX-CFG-NAV5 From 0f7a8c3f585285fd046bc183bf0551fd355248a4 Mon Sep 17 00:00:00 2001 From: unsurv <43016521+unsurv@users.noreply.github.com> Date: Tue, 21 Jul 2020 00:49:23 +0200 Subject: [PATCH 4/5] added example + better description in src --- .../Example22_PowerOff/Example22_PowerOff.ino | 85 +++++++++++++++++++ src/SparkFun_Ublox_Arduino_Library.cpp | 10 +-- 2 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 examples/Example22_PowerOff/Example22_PowerOff.ino diff --git a/examples/Example22_PowerOff/Example22_PowerOff.ino b/examples/Example22_PowerOff/Example22_PowerOff.ino new file mode 100644 index 0000000..d1c8b45 --- /dev/null +++ b/examples/Example22_PowerOff/Example22_PowerOff.ino @@ -0,0 +1,85 @@ +/* + Powering off a ublox GPS module + By: bjorn + unsurv.org + Date: July 20th, 2020 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + This example shows you how to turn off the ublox module to lower the power consumption. + There are two functions: one just specifies a duration in milliseconds the other also specifies a pin on the GPS device to wake it up with. + By driving a voltage from LOW to HIGH or HIGH to LOW on the chosen module pin you wake the device back up. + Note: Doing so on the INT0 pin when using the regular powerOff(durationInMs) function will wake the device anyway. (tested on SAM-M8Q) + Note: While powered off, you should not query the device for data or it might wake up. This can be used to wake the device but is not recommended. + Works best when also putting your microcontroller to sleep. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + NEO-M8P RTK: https://www.sparkfun.com/products/15005 + SAM-M8Q: https://www.sparkfun.com/products/15106 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard. + To force the device to wake up you need to connect to a pin (for example INT0) seperately on the module. + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +// define a digital pin capable of driving HIGH and LOW +#define WAKEUP_PIN 5 + +// interrupt pin mapping +#define GPS_RX 0 +#define GPS_INT0 1 +#define GPS_INT1 2 +#define GPS_SPI_CS 3 + + +void wakeUp() { + + Serial.print("-- waking up module via pin " + String(WAKEUP_PIN)); + Serial.println(" on your microcontroller --"); + + digitalWrite(WAKEUP_PIN, LOW); + delay(1000); + digitalWrite(WAKEUP_PIN, HIGH); + delay(1000); + digitalWrite(WAKEUP_PIN, LOW); +} + + +void setup() { + + pinMode(WAKEUP_PIN, OUTPUT); + + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun Ublox Example"); + + Wire.begin(); + + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port + { + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); + while (1); + } + + // Powering off for 20s, you should see the power consumption drop. + Serial.println("-- Powering off module for 20s --"); + + myGPS.powerOff(20000); + // myGPS.powerOffWithInterrupt(20000, GPS_INT0); + + delay(10000); + + // After 10 seconds wake the device via the specified pin on your microcontroller and module. + wakeUp(); +} + +void loop() { + //Do nothing +} diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index aba041e..a0da8cd 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2571,8 +2571,8 @@ uint8_t SFE_UBLOX_GPS::getPowerSaveMode(uint16_t maxWait) // Powers off the GPS device for a given duration to reduce power consumption. // NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! -// returns true if command has not failed -// returns false if command has not been acknowledged or maxWait = 0 +// Returns true if command has not been not acknowledged. +// Returns false if command has not been acknowledged or maxWait = 0. boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) { // use durationInMs = 0 for infinite duration @@ -2610,10 +2610,10 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) // Powers off the GPS device for a given duration to reduce power consumption. // While powered off it can be woken up by creating a falling or rising voltage edge on the specified pin. -// NOTE: The GPS seems to detect small voltage edges on the interrupt pin. Works best when Microcontroller is in deepsleep. +// NOTE: The GPS seems to be sensitve to signals on the pins while powered off. Works best when Microcontroller is in deepsleep. // NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! -// returns true if command has not failed -// returns false if command has not been acknowledged or maxWait = 0 +// Returns true if command has not been not acknowledged. +// Returns false if command has not been acknowledged or maxWait = 0. boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait) { // use durationInMs = 0 for infinite duration From 0be173050e0ca524b0cce62acb118114689c32f0 Mon Sep 17 00:00:00 2001 From: Paul <5690545+PaulZC@users.noreply.github.com> Date: Sat, 25 Jul 2020 13:10:50 +0100 Subject: [PATCH 5/5] Changes by PaulZC --- .../Example22_PowerOff/Example22_PowerOff.ino | 17 +++--- keywords.txt | 4 +- src/SparkFun_Ublox_Arduino_Library.cpp | 59 +++++++++---------- src/SparkFun_Ublox_Arduino_Library.h | 8 ++- 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/examples/Example22_PowerOff/Example22_PowerOff.ino b/examples/Example22_PowerOff/Example22_PowerOff.ino index d1c8b45..90ae355 100644 --- a/examples/Example22_PowerOff/Example22_PowerOff.ino +++ b/examples/Example22_PowerOff/Example22_PowerOff.ino @@ -32,12 +32,12 @@ SFE_UBLOX_GPS myGPS; // define a digital pin capable of driving HIGH and LOW #define WAKEUP_PIN 5 -// interrupt pin mapping -#define GPS_RX 0 -#define GPS_INT0 1 -#define GPS_INT1 2 -#define GPS_SPI_CS 3 - +// Possible GNSS interrupt pins for powerOffWithInterrupt are: +// VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX = uartrx +// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 = extint0 (default) +// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 = extint1 +// VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS = spics +// These values can be or'd (|) together to enable interrupts on multiple pins void wakeUp() { @@ -55,6 +55,7 @@ void wakeUp() { void setup() { pinMode(WAKEUP_PIN, OUTPUT); + digitalWrite(WAKEUP_PIN, LOW); Serial.begin(115200); while (!Serial); //Wait for user to open terminal @@ -62,6 +63,8 @@ void setup() { Wire.begin(); + //myGPS.enableDebugging(); // Enable debug messages + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port { Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); @@ -72,7 +75,7 @@ void setup() { Serial.println("-- Powering off module for 20s --"); myGPS.powerOff(20000); - // myGPS.powerOffWithInterrupt(20000, GPS_INT0); + //myGPS.powerOffWithInterrupt(20000, VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0); delay(10000); diff --git a/keywords.txt b/keywords.txt index 72d4636..0b5d1d5 100644 --- a/keywords.txt +++ b/keywords.txt @@ -139,8 +139,8 @@ setDynamicModel KEYWORD2 getDynamicModel KEYWORD2 powerSaveMode KEYWORD2 getPowerSaveMode KEYWORD2 -powerOff KEYWORD2 -powerOffWithInterrupt KEYWORD2 +powerOff KEYWORD2 +powerOffWithInterrupt KEYWORD2 configureMessage KEYWORD2 enableMessage KEYWORD2 diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index a0da8cd..4a5857e 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2596,6 +2596,11 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) payloadCfg[2] = (durationInMs >> (8*2)) & 0xff; payloadCfg[3] = (durationInMs >> (8*3)) & 0xff; + payloadCfg[4] = 0x02; //Flags : set the backup bit + payloadCfg[5] = 0x00; //Flags + payloadCfg[6] = 0x00; //Flags + payloadCfg[7] = 0x00; //Flags + if (maxWait != 0) { // check for "not acknowledged" command @@ -2614,7 +2619,7 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait) // NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up! // Returns true if command has not been not acknowledged. // Returns false if command has not been acknowledged or maxWait = 0. -boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait) +boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources, boolean forceWhileUsb, uint16_t maxWait) { // use durationInMs = 0 for infinite duration if (_printDebug == true) @@ -2631,7 +2636,11 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake packetCfg.startingSpot = 0; payloadCfg[0] = 0x00; // message version - // bytes 1-3 are reserved + + // bytes 1-3 are reserved - and must be set to zero + payloadCfg[1] = 0x00; + payloadCfg[2] = 0x00; + payloadCfg[3] = 0x00; // duration // big endian to little endian, switch byte order @@ -2641,49 +2650,35 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake payloadCfg[7] = (durationInMs >> (8*3)) & 0xff; // flags - payloadCfg[8] = 0x00; - payloadCfg[9] = 0x00; - payloadCfg[10] = 0x00; // disables USB interface when powering off, defaults to true if (forceWhileUsb) { - payloadCfg[11] = 0x04; + payloadCfg[8] = 0x06; // force | backup } else { - payloadCfg[11] = 0x02; + payloadCfg[8] = 0x02; // backup only (leave the force bit clear - module will stay on if USB is connected) } - // wakeUpSources - payloadCfg[12] = 0x00; - payloadCfg[13] = 0x00; - payloadCfg[14] = 0x00; - - // wakeupPin mapping, defaults to EXINT0, limited to one pin for now - // last byte of wakeUpSources - uint8_t terminatingByte; - - switch (wakeupPin) - { - case 0: // UART RX - terminatingByte = 0x08; // 0000 1000 - break; + payloadCfg[9] = 0x00; + payloadCfg[10] = 0x00; + payloadCfg[11] = 0x00; - case 1: // EXINT 0 - terminatingByte = 0x20; // 0010 0000 - break; + // wakeUpSources - case 2: // EXINT 1 - terminatingByte = 0x40; // 0100 0000 - break; + // wakeupPin mapping, defaults to VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 - case 3: // SPI CS - terminatingByte = 0x80; // 1000 0000 - break; - } + // Possible values are: + // VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX + // VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 + // VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 + // VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS - payloadCfg[15] = terminatingByte; + payloadCfg[12] = (wakeupSources >> (8*0)) & 0xff; + payloadCfg[13] = (wakeupSources >> (8*1)) & 0xff; + payloadCfg[14] = (wakeupSources >> (8*2)) & 0xff; + payloadCfg[15] = (wakeupSources >> (8*3)) & 0xff; if (maxWait != 0) { diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index 50265bf..96c0e0a 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -407,6 +407,12 @@ const uint32_t VAL_CFG_SUBSEC_ANTCONF = 0x00000400; // antConf - antenna config const uint32_t VAL_CFG_SUBSEC_LOGCONF = 0x00000800; // logConf - logging configuration const uint32_t VAL_CFG_SUBSEC_FTSCONF = 0x00001000; // ftsConf - FTS configuration (FTS products only) +// Bitfield wakeupSources for UBX_RXM_PMREQ +const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX = 0x00000008; // uartrx +const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 = 0x00000020; // extint0 +const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 = 0x00000040; // extint1 +const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS = 0x00000080; // spics + enum dynModel // Possible values for the dynamic platform model, which provide more accuract position output for the situation. Description extracted from ZED-F9P Integration Manual { DYN_MODEL_PORTABLE = 0, //Applications with low acceleration, e.g. portable devices. Suitable for most situations. @@ -642,7 +648,7 @@ class SFE_UBLOX_GPS boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100); uint8_t getPowerSaveMode(uint16_t maxWait = 1100); // Returns 255 if the sendCommand fails boolean powerOff(uint32_t durationInMs, uint16_t maxWait = 1100); - boolean powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin = 1, boolean forceWhileUsb = true, uint16_t maxWait = 1100); + boolean powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, boolean forceWhileUsb = true, uint16_t maxWait = 1100); //Change the dynamic platform model using UBX-CFG-NAV5 boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);