Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 0be1730

Browse files
committed
Changes by PaulZC
1 parent 0f7a8c3 commit 0be1730

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

Diff for: examples/Example22_PowerOff/Example22_PowerOff.ino

+10-7
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ SFE_UBLOX_GPS myGPS;
3232
// define a digital pin capable of driving HIGH and LOW
3333
#define WAKEUP_PIN 5
3434

35-
// interrupt pin mapping
36-
#define GPS_RX 0
37-
#define GPS_INT0 1
38-
#define GPS_INT1 2
39-
#define GPS_SPI_CS 3
40-
35+
// Possible GNSS interrupt pins for powerOffWithInterrupt are:
36+
// VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX = uartrx
37+
// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 = extint0 (default)
38+
// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 = extint1
39+
// VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS = spics
40+
// These values can be or'd (|) together to enable interrupts on multiple pins
4141

4242
void wakeUp() {
4343

@@ -55,13 +55,16 @@ void wakeUp() {
5555
void setup() {
5656

5757
pinMode(WAKEUP_PIN, OUTPUT);
58+
digitalWrite(WAKEUP_PIN, LOW);
5859

5960
Serial.begin(115200);
6061
while (!Serial); //Wait for user to open terminal
6162
Serial.println("SparkFun Ublox Example");
6263

6364
Wire.begin();
6465

66+
//myGPS.enableDebugging(); // Enable debug messages
67+
6568
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
6669
{
6770
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
@@ -72,7 +75,7 @@ void setup() {
7275
Serial.println("-- Powering off module for 20s --");
7376

7477
myGPS.powerOff(20000);
75-
// myGPS.powerOffWithInterrupt(20000, GPS_INT0);
78+
//myGPS.powerOffWithInterrupt(20000, VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0);
7679

7780
delay(10000);
7881

Diff for: keywords.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ setDynamicModel KEYWORD2
139139
getDynamicModel KEYWORD2
140140
powerSaveMode KEYWORD2
141141
getPowerSaveMode KEYWORD2
142-
powerOff KEYWORD2
143-
powerOffWithInterrupt KEYWORD2
142+
powerOff KEYWORD2
143+
powerOffWithInterrupt KEYWORD2
144144

145145
configureMessage KEYWORD2
146146
enableMessage KEYWORD2

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+27-32
Original file line numberDiff line numberDiff line change
@@ -2596,6 +2596,11 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
25962596
payloadCfg[2] = (durationInMs >> (8*2)) & 0xff;
25972597
payloadCfg[3] = (durationInMs >> (8*3)) & 0xff;
25982598

2599+
payloadCfg[4] = 0x02; //Flags : set the backup bit
2600+
payloadCfg[5] = 0x00; //Flags
2601+
payloadCfg[6] = 0x00; //Flags
2602+
payloadCfg[7] = 0x00; //Flags
2603+
25992604
if (maxWait != 0)
26002605
{
26012606
// check for "not acknowledged" command
@@ -2614,7 +2619,7 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
26142619
// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up!
26152620
// Returns true if command has not been not acknowledged.
26162621
// Returns false if command has not been acknowledged or maxWait = 0.
2617-
boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait)
2622+
boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources, boolean forceWhileUsb, uint16_t maxWait)
26182623
{
26192624
// use durationInMs = 0 for infinite duration
26202625
if (_printDebug == true)
@@ -2631,7 +2636,11 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake
26312636
packetCfg.startingSpot = 0;
26322637

26332638
payloadCfg[0] = 0x00; // message version
2634-
// bytes 1-3 are reserved
2639+
2640+
// bytes 1-3 are reserved - and must be set to zero
2641+
payloadCfg[1] = 0x00;
2642+
payloadCfg[2] = 0x00;
2643+
payloadCfg[3] = 0x00;
26352644

26362645
// duration
26372646
// big endian to little endian, switch byte order
@@ -2641,49 +2650,35 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake
26412650
payloadCfg[7] = (durationInMs >> (8*3)) & 0xff;
26422651

26432652
// flags
2644-
payloadCfg[8] = 0x00;
2645-
payloadCfg[9] = 0x00;
2646-
payloadCfg[10] = 0x00;
26472653

26482654
// disables USB interface when powering off, defaults to true
26492655
if (forceWhileUsb)
26502656
{
2651-
payloadCfg[11] = 0x04;
2657+
payloadCfg[8] = 0x06; // force | backup
26522658
}
26532659
else
26542660
{
2655-
payloadCfg[11] = 0x02;
2661+
payloadCfg[8] = 0x02; // backup only (leave the force bit clear - module will stay on if USB is connected)
26562662
}
26572663

2658-
// wakeUpSources
2659-
payloadCfg[12] = 0x00;
2660-
payloadCfg[13] = 0x00;
2661-
payloadCfg[14] = 0x00;
2662-
2663-
// wakeupPin mapping, defaults to EXINT0, limited to one pin for now
2664-
// last byte of wakeUpSources
2665-
uint8_t terminatingByte;
2666-
2667-
switch (wakeupPin)
2668-
{
2669-
case 0: // UART RX
2670-
terminatingByte = 0x08; // 0000 1000
2671-
break;
2664+
payloadCfg[9] = 0x00;
2665+
payloadCfg[10] = 0x00;
2666+
payloadCfg[11] = 0x00;
26722667

2673-
case 1: // EXINT 0
2674-
terminatingByte = 0x20; // 0010 0000
2675-
break;
2668+
// wakeUpSources
26762669

2677-
case 2: // EXINT 1
2678-
terminatingByte = 0x40; // 0100 0000
2679-
break;
2670+
// wakeupPin mapping, defaults to VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0
26802671

2681-
case 3: // SPI CS
2682-
terminatingByte = 0x80; // 1000 0000
2683-
break;
2684-
}
2672+
// Possible values are:
2673+
// VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX
2674+
// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0
2675+
// VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1
2676+
// VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS
26852677

2686-
payloadCfg[15] = terminatingByte;
2678+
payloadCfg[12] = (wakeupSources >> (8*0)) & 0xff;
2679+
payloadCfg[13] = (wakeupSources >> (8*1)) & 0xff;
2680+
payloadCfg[14] = (wakeupSources >> (8*2)) & 0xff;
2681+
payloadCfg[15] = (wakeupSources >> (8*3)) & 0xff;
26872682

26882683
if (maxWait != 0)
26892684
{

Diff for: src/SparkFun_Ublox_Arduino_Library.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ const uint32_t VAL_CFG_SUBSEC_ANTCONF = 0x00000400; // antConf - antenna config
407407
const uint32_t VAL_CFG_SUBSEC_LOGCONF = 0x00000800; // logConf - logging configuration
408408
const uint32_t VAL_CFG_SUBSEC_FTSCONF = 0x00001000; // ftsConf - FTS configuration (FTS products only)
409409

410+
// Bitfield wakeupSources for UBX_RXM_PMREQ
411+
const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX = 0x00000008; // uartrx
412+
const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 = 0x00000020; // extint0
413+
const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 = 0x00000040; // extint1
414+
const uint32_t VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS = 0x00000080; // spics
415+
410416
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
411417
{
412418
DYN_MODEL_PORTABLE = 0, //Applications with low acceleration, e.g. portable devices. Suitable for most situations.
@@ -642,7 +648,7 @@ class SFE_UBLOX_GPS
642648
boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100);
643649
uint8_t getPowerSaveMode(uint16_t maxWait = 1100); // Returns 255 if the sendCommand fails
644650
boolean powerOff(uint32_t durationInMs, uint16_t maxWait = 1100);
645-
boolean powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin = 1, boolean forceWhileUsb = true, uint16_t maxWait = 1100);
651+
boolean powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, boolean forceWhileUsb = true, uint16_t maxWait = 1100);
646652

647653
//Change the dynamic platform model using UBX-CFG-NAV5
648654
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);

0 commit comments

Comments
 (0)