Files
firmware/src/gps/Air530GPS.cpp

84 lines
2.2 KiB
C++
Raw Normal View History

#include "configuration.h"
2020-09-28 17:04:19 -07:00
#include "Air530GPS.h"
#include <assert.h>
/*
Helpful translations from the Air530 GPS datasheet
Sat acquision mode
@3.3v 42.6 mA
sat tracking mode
@3.3v 36.7 mA
Low power mode
@3.3V 0.85 mA
(:$PGKC051,0)
Super low power mode
@3.3V 31 uA
(:$PGKC105,4)
To exit sleep use WAKE pin
Commands to enter sleep
6Command: 105
Arguments:
Arg1: 0, (normal mode)
1,, WAKE (periodic low power tracking mode - keeps sat positions, use wake to wake up)
2, (periodic low power mode)
4,, WAKE (super low power consumption mode immediately, need WAKE to resume)
8,, (automatic low power mode, wake by sending characters to serial port)
9, , WAKE (automatic low power tracking when possible, need wake pin to resume)
(Arg 2 & 3 only valid if Arg1 is "1" or "2")
Arg2:(), Arg1 12 ,
ON time in msecs
Arg3:(), Arg1 12 ,
Sleep time in msecs
Example:
$PGKC105,8*3F<CR><LF>
This will set automatic low power mode with waking when we send chars to the serial port. Possibly do this as soon as we get a
new location. When we wake again in a minute we send a character to wake up.
*/
void Air530GPS::sendCommand(const char *cmd) {
uint8_t sum = 0;
// Skip the $
assert(cmd[0] == '$');
const char *p = cmd + 1;
while(*p)
sum ^= *p++;
assert(_serial_gps);
_serial_gps->write(cmd);
_serial_gps->printf("*%02x\r\n", sum);
// DEBUG_MSG("xsum %02x\n", sum);
}
void Air530GPS::sleep() {
2020-10-13 13:59:06 +08:00
NMEAGPS::sleep();
2020-09-28 17:04:19 -07:00
#ifdef PIN_GPS_WAKE
sendCommand("$PGKC105,4");
#endif
}
/// wake the GPS into normal operation mode
void Air530GPS::wake()
{
2020-09-28 17:38:36 -07:00
#if 1
2020-10-13 13:59:06 +08:00
NMEAGPS::wake();
2020-09-28 17:04:19 -07:00
#else
2020-09-28 17:38:36 -07:00
// For power testing - keep GPS sleeping forever
2020-09-28 17:04:19 -07:00
sleep();
#endif
}