A driver for the MAX8U GPS by uBlox. Provides core functionality. Communicates through I2C.

MAX8U Driver

This driver supports a wide range of functions provided by the MAX8U chip. Most of the essential features are supported. It lays a framework to add more commands easily, with only a little extra work.

Driver was originally made for the USC Rocket Propulsion Lab by Adhyyan Sekhsaria and Jamie Smith

Features

Currently supports:

  • Getting coordinates in latitude, longitude, accuracy...
  • Velocity measurements in each axis
  • Individual satellite information
  • Time of last message
  • Antenna Power Status
  • GPS Fix Quality
  • Save configuration in memory

Documentation

Full documentation is available here

Usage

Code Structure:

In factory settings, the module is not configured to send any messages. For the GPS to give updates, we need to configure it by sending messages using setMessageEnabled() which internally calls sendMessage() and waitForAck().

calling configure() once will enable a few useful messages, and save this configuration in the MAX8U non-volatile memory.

update() to be called periodically by the user. Processes and reads all the messages currently stored in the GPS. Calls processMessage() on every message. processMessage(): processes the message currently in the buffer by calling the respective functions. Each message is read, and its relevant information is then stored in the public variables.

By default, the GPS sends messages in NMEA format (but we reconfigure it to UBX format), so readNextMessage() has to determine which format the message is.

define the macro MAX8U_DEBUG to enable printing out to message information to the debug port. If not defined, will only print error messages to the debug port.

Example

Outputting Coordinates, Velocity and Time from GPS

#include "MAX8U.h"

int main(){
    MAX8U gps(&pc, PIN_I2C_SDA, PIN_I2C_SCL, p25);
    bool booted = gps.begin();

    if(!booted){
        //handle error
    }
    booted = gps.configure();
    if(!booted){
        //handle error
    }

    while(true){
        bool newMessageRcvd = gps.update();
        pc.printf(">Position: %.06f %c, %.06f %c, Height %.02f m\r\n",
                  std::abs(gps.latitude), gps.latitude > 0 ? 'N' : 'S',
                  std::abs(gps.longitude), gps.longitude > 0 ? 'E' : 'W',
                  gps.height);

        // velocity
        pc.printf(">Velocity: %.02f m/s N, %.02f m/s E, %.02f m/s Down\r\n",
                  gps.northVel * .02f,
                  gps.eastVel * .02f,
                  gps.downVel * .02f);

        // accuracy
        pc.printf(">Fix: Quality: %" PRIu8 ", Num Satellites: %" PRIu8 ", Position Accuracy: %.02f m\r\n",
                static_cast<uint8_t>(gps.fixQuality), gps.numSatellites, gps.posAccuracy);

        // time
        pc.printf(">Time: %" PRIu8 "/%" PRIu8"/%" PRIu16" %" PRIu8":%" PRIu8 ":%" PRIu8 "\r\n",
                gps.month,
                gps.day,
                gps.year,
                gps.hour,
                gps.minute,
                gps.second);
    }
}

Committer:
adhyyan
Date:
Tue Jan 07 10:49:40 2020 +0000
Revision:
3:b51460af3259
Parent:
2:4d2c874f386e
Added Example Code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
adhyyan 0:7f603f221713 1 #ifndef MAX8U_H
adhyyan 0:7f603f221713 2 #define MAX8U_H
adhyyan 0:7f603f221713 3
adhyyan 0:7f603f221713 4
adhyyan 0:7f603f221713 5 #include "mbed.h"
adhyyan 0:7f603f221713 6 #include "MAX8UConstants.h"
adhyyan 0:7f603f221713 7
adhyyan 3:b51460af3259 8 #define MAX8U_I2C_DEF_ADDRESS 0x42 // this is the default address given in the databook
adhyyan 3:b51460af3259 9
adhyyan 0:7f603f221713 10
adhyyan 1:00ea4db324f2 11 /**
adhyyan 1:00ea4db324f2 12 * Class to use the MAX8U
adhyyan 1:00ea4db324f2 13 */
adhyyan 0:7f603f221713 14 class MAX8U
adhyyan 0:7f603f221713 15 {
adhyyan 0:7f603f221713 16 public:
adhyyan 1:00ea4db324f2 17
adhyyan 1:00ea4db324f2 18 /**
adhyyan 1:00ea4db324f2 19 * U-Blox GPS Fix Values
adhyyan 1:00ea4db324f2 20 */
adhyyan 0:7f603f221713 21 enum class GPSFix : uint8_t
adhyyan 0:7f603f221713 22 {
adhyyan 0:7f603f221713 23 NONE = 0,
adhyyan 0:7f603f221713 24 DEAD_RECKONING = 1,
adhyyan 0:7f603f221713 25 FIX_2D = 2,
adhyyan 0:7f603f221713 26 FIX_3D = 3,
adhyyan 0:7f603f221713 27 FIX_GPS_DEAD_RECKONING = 4,
adhyyan 0:7f603f221713 28 TIME_ONLY = 5
adhyyan 0:7f603f221713 29 };
adhyyan 0:7f603f221713 30
adhyyan 0:7f603f221713 31 /**
adhyyan 0:7f603f221713 32 * U-Blox GNSS identifier
adhyyan 0:7f603f221713 33 */
adhyyan 0:7f603f221713 34 enum class GNSSID : uint8_t
adhyyan 0:7f603f221713 35 {
adhyyan 0:7f603f221713 36 GPS = 0,
adhyyan 0:7f603f221713 37 SBAS = 1,
adhyyan 0:7f603f221713 38 Galileo = 2,
adhyyan 0:7f603f221713 39 BeiDou = 3,
adhyyan 0:7f603f221713 40 IMES = 4,
adhyyan 0:7f603f221713 41 QZSS = 5,
adhyyan 0:7f603f221713 42 GLONASS = 6
adhyyan 0:7f603f221713 43 };
adhyyan 0:7f603f221713 44
adhyyan 0:7f603f221713 45 /**
adhyyan 0:7f603f221713 46 * Used for AntennaPowerStatus, in the UBX_MON_HW message
adhyyan 0:7f603f221713 47 */
adhyyan 0:7f603f221713 48 enum class AntennaPowerStatus : uint8_t
adhyyan 0:7f603f221713 49 {
adhyyan 0:7f603f221713 50 OFF = 0,
adhyyan 0:7f603f221713 51 ON = 1,
adhyyan 0:7f603f221713 52 DONT_KNOW = 2,
adhyyan 0:7f603f221713 53 NO_MESSAGE_RCVD = 3
adhyyan 0:7f603f221713 54 };
adhyyan 0:7f603f221713 55
adhyyan 0:7f603f221713 56 /**
adhyyan 0:7f603f221713 57 * Info about each sattelite, obtained from getSatelliteInfo()
adhyyan 0:7f603f221713 58 */
adhyyan 0:7f603f221713 59 struct SatelliteInfo
adhyyan 0:7f603f221713 60 {
adhyyan 0:7f603f221713 61 /**
adhyyan 0:7f603f221713 62 * GNSS that this satellite is from.
adhyyan 0:7f603f221713 63 */
adhyyan 0:7f603f221713 64 GNSSID gnss;
adhyyan 0:7f603f221713 65
adhyyan 0:7f603f221713 66 /**
adhyyan 0:7f603f221713 67 * ID of this satellite in its GNSS
adhyyan 0:7f603f221713 68 */
adhyyan 0:7f603f221713 69 uint8_t satelliteID;
adhyyan 0:7f603f221713 70
adhyyan 0:7f603f221713 71 /**
adhyyan 0:7f603f221713 72 * Carrier-noise ratio in dbHz
adhyyan 0:7f603f221713 73 */
adhyyan 0:7f603f221713 74 uint8_t signalStrength;
adhyyan 0:7f603f221713 75
adhyyan 0:7f603f221713 76 /**
adhyyan 0:7f603f221713 77 * Signal quality indicator (see U-Blox protocol description section 32.17.17.1)
adhyyan 0:7f603f221713 78 */
adhyyan 0:7f603f221713 79 uint8_t signalQuality;
adhyyan 0:7f603f221713 80
adhyyan 0:7f603f221713 81 /**
adhyyan 0:7f603f221713 82 * Get the string name of this satellite's GNSS.
adhyyan 0:7f603f221713 83 * @return
adhyyan 0:7f603f221713 84 */
adhyyan 0:7f603f221713 85 const char* getGNSSName();
adhyyan 0:7f603f221713 86
adhyyan 0:7f603f221713 87 /**
adhyyan 0:7f603f221713 88 * True if this satellite is beign used to do navigation
adhyyan 0:7f603f221713 89 */
adhyyan 0:7f603f221713 90 bool svUsed;
adhyyan 0:7f603f221713 91 };
adhyyan 0:7f603f221713 92
adhyyan 0:7f603f221713 93 private:
adhyyan 0:7f603f221713 94
adhyyan 0:7f603f221713 95 Serial* _debugPort;
adhyyan 0:7f603f221713 96
adhyyan 0:7f603f221713 97
adhyyan 0:7f603f221713 98 /// buffer stores the data rcvd from reeading the stream on the MAX8U
adhyyan 0:7f603f221713 99 const static int bufferMaxLen = 256;
adhyyan 0:7f603f221713 100 char buffer[bufferMaxLen + 1];
adhyyan 0:7f603f221713 101
adhyyan 0:7f603f221713 102 /// length of the message currently in the buffer.
adhyyan 0:7f603f221713 103 size_t currMessageLength = 0;
adhyyan 0:7f603f221713 104
adhyyan 0:7f603f221713 105
adhyyan 0:7f603f221713 106
adhyyan 0:7f603f221713 107 /**
adhyyan 0:7f603f221713 108 * I2C port object. Provides physical layer communications with the chip.
adhyyan 0:7f603f221713 109 */
adhyyan 0:7f603f221713 110 I2C _i2cPort;
adhyyan 0:7f603f221713 111
adhyyan 0:7f603f221713 112 /// i2c address of IMU (7 bits)
adhyyan 0:7f603f221713 113 uint8_t _i2cAddress;
adhyyan 0:7f603f221713 114
adhyyan 0:7f603f221713 115 /// user defined port speed
adhyyan 0:7f603f221713 116 int _i2cPortSpeed;
adhyyan 0:7f603f221713 117
adhyyan 0:7f603f221713 118 /// Reset pin -- resets GPS when held low.
adhyyan 0:7f603f221713 119 DigitalOut _rst;
adhyyan 0:7f603f221713 120
adhyyan 0:7f603f221713 121 /**
adhyyan 0:7f603f221713 122 * sends header and data in the correct UBX protocol (adding sync chars, and checksums)
adhyyan 0:7f603f221713 123 * @returns true if command was sent sucessfully
adhyyan 0:7f603f221713 124 *
adhyyan 0:7f603f221713 125 */
adhyyan 0:7f603f221713 126 bool sendCommand(uint8_t messageClass, uint8_t messageID, uint8_t *data, uint16_t dataLen);
adhyyan 0:7f603f221713 127
adhyyan 0:7f603f221713 128
adhyyan 0:7f603f221713 129 public:
adhyyan 0:7f603f221713 130
adhyyan 0:7f603f221713 131 // Data read from GPS
adhyyan 0:7f603f221713 132
adhyyan 0:7f603f221713 133 /// Current latitude in decimal degrees.
adhyyan 0:7f603f221713 134 double latitude = 0;
adhyyan 0:7f603f221713 135
adhyyan 0:7f603f221713 136 /// Current longitude in decimal degrees.
adhyyan 0:7f603f221713 137 double longitude = 0;
adhyyan 0:7f603f221713 138
adhyyan 0:7f603f221713 139 /// Current height above earths surface (above ellipsoid) in meters
adhyyan 0:7f603f221713 140 float height = 0;
adhyyan 0:7f603f221713 141
adhyyan 0:7f603f221713 142 /// Quality of the current fix
adhyyan 0:7f603f221713 143 GPSFix fixQuality = GPSFix::NONE;
adhyyan 0:7f603f221713 144
adhyyan 0:7f603f221713 145 /// Estimate of the accuracy of the current position in meters
adhyyan 0:7f603f221713 146 float posAccuracy = 0;
adhyyan 0:7f603f221713 147
adhyyan 0:7f603f221713 148 /// current number of sats used for navigation
adhyyan 0:7f603f221713 149 uint8_t numSatellites = 0;
adhyyan 0:7f603f221713 150
adhyyan 2:4d2c874f386e 151 // Variables for Velocity Solution in NED, units: cm/s
adhyyan 2:4d2c874f386e 152
adhyyan 2:4d2c874f386e 153 /// North Velocity Solution in NED, units: cm/s
adhyyan 0:7f603f221713 154 int32_t northVel = 0;
adhyyan 2:4d2c874f386e 155
adhyyan 2:4d2c874f386e 156 /// East Velocity Solution in NED, units: cm/s
adhyyan 0:7f603f221713 157 int32_t eastVel = 0;
adhyyan 2:4d2c874f386e 158
adhyyan 2:4d2c874f386e 159 /// Down Velocity Solution in NED, units: cm/s
adhyyan 0:7f603f221713 160 int32_t downVel = 0;
adhyyan 2:4d2c874f386e 161
adhyyan 2:4d2c874f386e 162 /// 3D Speed Solution in NED, units: cm/s
adhyyan 0:7f603f221713 163 uint32_t speed3D = 0;
adhyyan 0:7f603f221713 164
adhyyan 2:4d2c874f386e 165 //time as of the last message
adhyyan 2:4d2c874f386e 166
adhyyan 2:4d2c874f386e 167 ///Month: time as of the last message
adhyyan 2:4d2c874f386e 168 uint8_t month;
adhyyan 2:4d2c874f386e 169
adhyyan 2:4d2c874f386e 170 ///Day: time as of the last message
adhyyan 2:4d2c874f386e 171 uint8_t day;
adhyyan 2:4d2c874f386e 172
adhyyan 2:4d2c874f386e 173 ///Hour: time as of the last message
adhyyan 2:4d2c874f386e 174 uint8_t hour;
adhyyan 2:4d2c874f386e 175
adhyyan 2:4d2c874f386e 176 ///Minute: time as of the last message
adhyyan 2:4d2c874f386e 177 uint8_t minute;
adhyyan 2:4d2c874f386e 178
adhyyan 2:4d2c874f386e 179 ///Second: time as of the last message
adhyyan 2:4d2c874f386e 180 uint8_t second;
adhyyan 2:4d2c874f386e 181
adhyyan 2:4d2c874f386e 182 ///Year: time as of the last message
adhyyan 0:7f603f221713 183 uint16_t year;
adhyyan 0:7f603f221713 184
adhyyan 0:7f603f221713 185 /// is true, if the last msg was following the NMEA protocol, otherwise UBX
adhyyan 0:7f603f221713 186 bool isNMEASentence;
adhyyan 0:7f603f221713 187
adhyyan 0:7f603f221713 188 /**
adhyyan 0:7f603f221713 189 * Construct a MAX8U, providing pins and parameters.
adhyyan 0:7f603f221713 190 *
adhyyan 0:7f603f221713 191 * This doesn't actually initialize the chip, you will need to call begin() for that.
adhyyan 3:b51460af3259 192 * @param debugPort DebugPort used to output debug information. Pass nullpntr otherwise.
adhyyan 0:7f603f221713 193 * @param user_SDApin Hardware I2C SDA pin connected to the MAX8
adhyyan 0:7f603f221713 194 * @param user_SCLpin Hardware I2C SCL pin connected to the MAX8
adhyyan 0:7f603f221713 195 * @param user_RSTPin Output pin connected to NRST
adhyyan 0:7f603f221713 196 * @param i2cAddress I2C address. The MAX8 defaults to 0x42
adhyyan 0:7f603f221713 197 * @param i2cPortSpeed I2C frequency.
adhyyan 0:7f603f221713 198 */
adhyyan 0:7f603f221713 199 MAX8U(Serial *debugPort, PinName user_SDApin, PinName user_SCLpin, PinName user_RSTPin,
adhyyan 0:7f603f221713 200 uint8_t i2cAddress = MAX8U_I2C_DEF_ADDRESS, int i2cPortSpeed = 100000);
adhyyan 0:7f603f221713 201
adhyyan 0:7f603f221713 202
adhyyan 0:7f603f221713 203
adhyyan 0:7f603f221713 204
adhyyan 0:7f603f221713 205
adhyyan 0:7f603f221713 206 /**
adhyyan 0:7f603f221713 207 * resets the GPS. Configures the basic i2c settings.
adhyyan 0:7f603f221713 208 * TODO: Verifies that it's connected, and reads out its version
adhyyan 0:7f603f221713 209 *
adhyyan 0:7f603f221713 210 * @return whether or not initialization was successful
adhyyan 0:7f603f221713 211 */
adhyyan 0:7f603f221713 212 bool begin();
adhyyan 0:7f603f221713 213
adhyyan 0:7f603f221713 214 /**
adhyyan 0:7f603f221713 215 * Get the last message recieved from the GPS. Could be binary or a string
adhyyan 0:7f603f221713 216 * depending on the protocol in use.
adhyyan 0:7f603f221713 217 * @return
adhyyan 0:7f603f221713 218 */
adhyyan 0:7f603f221713 219 char const * getLastMessageBuffer() { return buffer; }
adhyyan 0:7f603f221713 220
adhyyan 0:7f603f221713 221 /**
adhyyan 0:7f603f221713 222 * If there is data to be read, then the function will read all queued data.
adhyyan 0:7f603f221713 223 * New data will be store in buffer array
adhyyan 0:7f603f221713 224 * @return true if got new data, false if there was an error or stream was empty
adhyyan 0:7f603f221713 225 */
adhyyan 0:7f603f221713 226 bool update();
adhyyan 0:7f603f221713 227
adhyyan 0:7f603f221713 228 /**
adhyyan 0:7f603f221713 229 * Configure the GPS with the appropriate communications and message settings
adhyyan 0:7f603f221713 230 * for this driver. Unless the driver has changed, you only need to call this once
adhyyan 0:7f603f221713 231 * for each new GPS (the config will be saved on the GPS)
adhyyan 0:7f603f221713 232 * @return
adhyyan 0:7f603f221713 233 */
adhyyan 0:7f603f221713 234 bool configure();
adhyyan 0:7f603f221713 235
adhyyan 0:7f603f221713 236 /**
adhyyan 0:7f603f221713 237 * Receives a single MON_HW message and returns the power status
adhyyan 0:7f603f221713 238 * @return the status of the power of the antenna
adhyyan 0:7f603f221713 239 */
adhyyan 0:7f603f221713 240 AntennaPowerStatus antennaPowerStatus();
adhyyan 0:7f603f221713 241
adhyyan 0:7f603f221713 242 /**
adhyyan 0:7f603f221713 243 * Reads and prints the current enabled GNSS Constellations and prints out the IDS for them
adhyyan 0:7f603f221713 244 */
adhyyan 0:7f603f221713 245 void readGNSSConfig();
adhyyan 0:7f603f221713 246
adhyyan 0:7f603f221713 247 /**
adhyyan 0:7f603f221713 248 * Reads information from the GPS about all the satellites it can see and
adhyyan 0:7f603f221713 249 * fills it into the given array.
adhyyan 0:7f603f221713 250 * @param satelliteInfos Array of SatelliteInfos that the caller allocates.
adhyyan 0:7f603f221713 251 * @param infoLen Length of the info struct array.
adhyyan 0:7f603f221713 252 * @return The number of satellites the GPS returned info about. If negative, there was
adhyyan 0:7f603f221713 253 * an error. If <= the size of the array, then it's the number of valid array entries.
adhyyan 0:7f603f221713 254 * If greater than the size of the array, then the max number of array elements were filled in.
adhyyan 0:7f603f221713 255 */
adhyyan 0:7f603f221713 256 ssize_t readSatelliteInfo(SatelliteInfo * satelliteInfos, size_t infoLen);
adhyyan 0:7f603f221713 257
adhyyan 0:7f603f221713 258 /**
adhyyan 0:7f603f221713 259 * Configures the time pulse. If enabled, it will send a pulse at the frequncy
adhyyan 0:7f603f221713 260 * @param timepulseId, 0 = timepulse, 1 = timepulse2
adhyyan 0:7f603f221713 261 * @param pulseLenRatio duty cycle.
adhyyan 0:7f603f221713 262 * @return
adhyyan 0:7f603f221713 263 */
adhyyan 0:7f603f221713 264 bool configureTimePulse(bool enabled, uint8_t timepulseId, uint32_t freq, uint32_t pulseLenRatio);
adhyyan 0:7f603f221713 265
adhyyan 0:7f603f221713 266
adhyyan 0:7f603f221713 267
adhyyan 0:7f603f221713 268 private:
adhyyan 0:7f603f221713 269
adhyyan 0:7f603f221713 270 /**
adhyyan 0:7f603f221713 271 * Helper function to read form the data buffer.
adhyyan 0:7f603f221713 272 * Numerical values can only be read from aligned memory addresses, but sometimes we need to not do that.
adhyyan 0:7f603f221713 273 * This function takes an address and an optional offset, and reads a value of the template type.
adhyyan 0:7f603f221713 274 */
adhyyan 0:7f603f221713 275 template<typename T>
adhyyan 0:7f603f221713 276 T readUnalignedValue(char* data, size_t offset = 0)
adhyyan 0:7f603f221713 277 {
adhyyan 0:7f603f221713 278 T value;
adhyyan 0:7f603f221713 279 memcpy(&value, data + offset, sizeof(value));
adhyyan 0:7f603f221713 280 return value;
adhyyan 0:7f603f221713 281 }
adhyyan 0:7f603f221713 282
adhyyan 0:7f603f221713 283 /**
adhyyan 0:7f603f221713 284 * Tells the GPS to enable the message indicated by messageClass and messageID
adhyyan 0:7f603f221713 285 * This is done by sending a message to the GPS and then waiting for an ack message
adhyyan 0:7f603f221713 286 * @return true if an ack message has been recieved from the gps
adhyyan 0:7f603f221713 287 */
adhyyan 0:7f603f221713 288
adhyyan 0:7f603f221713 289 bool setMessageEnabled(uint8_t messageClass, uint8_t messageID, bool enabled);
adhyyan 0:7f603f221713 290
adhyyan 0:7f603f221713 291 /**
adhyyan 0:7f603f221713 292 * Processes the message currently in the buffer.
adhyyan 0:7f603f221713 293 * If this is data we are processing, parses it and stores it in class variables.
adhyyan 0:7f603f221713 294 * Otherwise, does nothing.
adhyyan 0:7f603f221713 295 */
adhyyan 0:7f603f221713 296 void processMessage();
adhyyan 0:7f603f221713 297
adhyyan 0:7f603f221713 298 /**
adhyyan 0:7f603f221713 299 * Process a NAV_POSLLH message loaded into the buffer.
adhyyan 0:7f603f221713 300 */
adhyyan 0:7f603f221713 301 void processNAV_POSLLH();
adhyyan 0:7f603f221713 302
adhyyan 0:7f603f221713 303 /**
adhyyan 0:7f603f221713 304 * Process a NAV_SOL message loaded into the buffer.
adhyyan 0:7f603f221713 305 */
adhyyan 0:7f603f221713 306 void processNAV_SOL();
adhyyan 0:7f603f221713 307
adhyyan 0:7f603f221713 308 /**
adhyyan 0:7f603f221713 309 * Process a NAV_TIMEUTC message loaded into the buffer.
adhyyan 0:7f603f221713 310 */
adhyyan 0:7f603f221713 311 void processNAV_TIMEUTC();
adhyyan 0:7f603f221713 312
adhyyan 0:7f603f221713 313 /**
adhyyan 0:7f603f221713 314 * Process a NAV_VELNED message loaded into the buffer.
adhyyan 0:7f603f221713 315 */
adhyyan 0:7f603f221713 316 void processNAV_VELNED();
adhyyan 0:7f603f221713 317
adhyyan 0:7f603f221713 318 /**
adhyyan 0:7f603f221713 319 * Wait for a specific message to be received.
adhyyan 0:7f603f221713 320 * If we get another message that is not the one we're looking for during this time, then
adhyyan 0:7f603f221713 321 * we process that message using processMessage()
adhyyan 0:7f603f221713 322 * If the message is not received before the timeout, returns false.
adhyyan 0:7f603f221713 323 *
adhyyan 0:7f603f221713 324 *
adhyyan 0:7f603f221713 325 * @param messageClass Class of the message to wait for
adhyyan 0:7f603f221713 326 * @param messageID ID of the of the message to wait for
adhyyan 0:7f603f221713 327 * @param timeout How long to wait for the message.
adhyyan 0:7f603f221713 328 * @return
adhyyan 0:7f603f221713 329 */
adhyyan 0:7f603f221713 330 bool waitForMessage(uint8_t messageClass, uint8_t messageID, float timeout = 1.0f);
adhyyan 0:7f603f221713 331
adhyyan 0:7f603f221713 332
adhyyan 0:7f603f221713 333
adhyyan 0:7f603f221713 334
adhyyan 0:7f603f221713 335
adhyyan 0:7f603f221713 336 /**
adhyyan 0:7f603f221713 337 * It will wait for a message of a specific kind.
adhyyan 0:7f603f221713 338 * NOTE: we assume that we wait for an ACK before sending another message,
adhyyan 0:7f603f221713 339 * so there should never be two ACKs in play at once.
adhyyan 0:7f603f221713 340 * @param sentMessageClass Class of the message expecting an ACK for
adhyyan 0:7f603f221713 341 * @param sentMessageID ID of the message expecting an ACK for
adhyyan 0:7f603f221713 342 * @param timeout How long to wait for the message
adhyyan 0:7f603f221713 343 * @return true if a correct ACK was received
adhyyan 0:7f603f221713 344 */
adhyyan 0:7f603f221713 345
adhyyan 0:7f603f221713 346 bool waitForACK(uint8_t sentMessageClass, uint8_t sentMessageID, float timeout = 1.0f);
adhyyan 0:7f603f221713 347
adhyyan 0:7f603f221713 348 /**
adhyyan 0:7f603f221713 349 * Configure the port settings appropriately for this driver.
adhyyan 0:7f603f221713 350 * @return
adhyyan 0:7f603f221713 351 */
adhyyan 0:7f603f221713 352 bool configureCommSettings();
adhyyan 0:7f603f221713 353
adhyyan 0:7f603f221713 354 /**
adhyyan 0:7f603f221713 355 * Save all the current settings to the GPS's flash memory so that they will
adhyyan 0:7f603f221713 356 * be loaded when it boots.
adhyyan 0:7f603f221713 357 * @return
adhyyan 0:7f603f221713 358 */
adhyyan 0:7f603f221713 359 bool saveSettings();
adhyyan 0:7f603f221713 360
adhyyan 0:7f603f221713 361 /**
adhyyan 0:7f603f221713 362 * Check the software version. If not in debug mode, this will just return true if
adhyyan 0:7f603f221713 363 * it was able to talk to the device. In debug mode, this will print all version info
adhyyan 0:7f603f221713 364 * to the console.
adhyyan 0:7f603f221713 365 * @return
adhyyan 0:7f603f221713 366 */
adhyyan 0:7f603f221713 367 bool checkVersion();
adhyyan 0:7f603f221713 368
adhyyan 0:7f603f221713 369 /**
adhyyan 0:7f603f221713 370 * Reads exactly one command in the buffer, by accessing the 0xff register.
adhyyan 0:7f603f221713 371 * Stores the data in a global arr, buffer.
adhyyan 0:7f603f221713 372 */
adhyyan 0:7f603f221713 373 bool readNextMessage();
adhyyan 0:7f603f221713 374
adhyyan 0:7f603f221713 375
adhyyan 0:7f603f221713 376 /**
adhyyan 0:7f603f221713 377 * Returns length of buffer in the GPS module by reading the registers
adhyyan 0:7f603f221713 378 * @returns length of message. -1 if no ack is rcvd.
adhyyan 0:7f603f221713 379 */
adhyyan 0:7f603f221713 380 int32_t readLen();
adhyyan 0:7f603f221713 381 };
adhyyan 0:7f603f221713 382 #endif