Library for Skytraq Venus838 GPS

Dependents:   Venus838_Test Atlas

Files at this revision

API Documentation at this revision

Comitter:
ethanharstad
Date:
Tue Jun 24 04:46:31 2014 +0000
Commit message:
Initial commit

Changed in this revision

Venus838.cpp Show annotated file Show diff for this revision Revisions of this file
Venus838.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Venus838.cpp	Tue Jun 24 04:46:31 2014 +0000
@@ -0,0 +1,48 @@
+#include "Venus838.h"
+
+// A0 A1 PL(2b) ID Body CS 0D 0A
+Venus838::Venus838(PinName tx, PinName rx) : _gps(tx, rx) {
+    _gps.baud(115200);
+}
+
+void Venus838::setNmeaMessages(const bool gga, const bool gsa, const bool gsv, const bool gll, const bool rmc, const bool vtg) {
+    char cmd[16] = {
+        0xA0, 0xA1, 0x00, 0x09,
+        0x08, gga, gsa, gsv, gll, rmc, vtg, 0x00, 0x01,
+        0x00, 0x0D, 0x0A
+    };
+    for(int i = 4; i < 13; i++) cmd[13] ^= cmd[i];
+    for(int i = 0; i < 16; i++) _gps.putc(cmd[i]);
+}
+
+void Venus838::setUpdateRate(const uint8_t rate) {
+    char cmd[10] = {
+        0xA0, 0xA1, 0x00, 0x03,
+        0x0E, rate, 0x01,
+        0x00, 0x0D, 0x0A
+    };
+    for(int i = 4; i < 7; i++) cmd[7] ^= cmd[i];
+    for(int i = 0; i < 10; i++) _gps.putc(cmd[i]);
+}
+
+void Venus838::setNavigationMode(const int mode) {
+    char cmd[] = {
+        0xA0, 0xA1, 0x00, 0x04,
+        0x64, 0x17, 0x04, 0x01,
+        0x00, 0x0D, 0x0A
+    };
+    for(int i = 4; i < 8; i++) cmd[8] ^= cmd[i];
+    for(int i = 0; i < 10; i++) _gps.putc(cmd[i]);
+}
+
+bool Venus838::readable() {
+    return _gps.readable();
+}
+
+void Venus838::putc(char in) {
+    _gps.putc(in);
+}
+
+char Venus838::getc() {
+    return _gps.getc();
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Venus838.h	Tue Jun 24 04:46:31 2014 +0000
@@ -0,0 +1,20 @@
+#ifndef VENUS838_H_
+#define VENUS838_H_
+
+#include "mbed.h"
+
+class Venus838 {
+    public:
+        Venus838(PinName tx, PinName rx);
+        void setNmeaMessages(const bool gga, const bool gsa, const bool gsv, const bool gll, const bool rmc, const bool vtg);
+        void setUpdateRate(const uint8_t rate);
+        void setNavigationMode(const int mode);
+        bool readable();
+        void putc(char in);
+        char getc();
+    
+    private:
+        Serial _gps;
+};
+
+#endif
\ No newline at end of file