Skip to content

Commit

Permalink
WebTop: a copy of UC6580 GNSS driver from SoftRF [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Nov 2, 2023
1 parent bf73f32 commit 0a2819b
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 3 deletions.
Binary file added documents/images/midi-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 91 additions & 2 deletions software/firmware/source/SkyWatch/GNSSHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const char *GNSS_name[] = {
[GNSS_MODULE_SONY] = "SONY",
[GNSS_MODULE_AT65] = "AT65",
[GNSS_MODULE_MT33] = "MT33",
[GNSS_MODULE_GOKE] = "GOKE"
[GNSS_MODULE_GOKE] = "GOKE",
[GNSS_MODULE_UC65] = "UC65"
};

#if defined(ENABLE_GNSS_STATS)
Expand All @@ -84,6 +85,7 @@ const char *GNSS_name[] = {
* Goke: GGA - 185+, RMC - 265+
* Neo6: GGA - 138 , RMC - 67
* MT33: GGA - 48 , RMC - 175
* UC65: GGA - TBD , RMC - TBD
*/

gnss_stat_t gnss_stats;
Expand Down Expand Up @@ -1061,6 +1063,88 @@ const gnss_chip_ops_t at65_ops = {
};
#endif /* EXCLUDE_GNSS_AT65 */

#if !defined(EXCLUDE_GNSS_UC65)
static gnss_id_t uc65_probe()
{
/* Firmware version request */
return nmea_handshake("$PDTINFO\r\n", "$PDTINFO,FB2S UM600", false) ?
GNSS_MODULE_UC65 : GNSS_MODULE_NMEA;
}

static bool uc65_setup()
{
#if !defined(EXCLUDE_LOG_GNSS_VERSION)
while (Serial_GNSS_In.available() > 0) { Serial_GNSS_In.read(); }

Serial_GNSS_Out.write("$PDTINFO\r\n");

int i=0;
char c;
unsigned long start_time = millis();

/* take response into buffer */
while ((millis() - start_time) < 2000) {

c = Serial_GNSS_In.read();

if (isPrintable(c) || c == '\r' || c == '\n') {
if (i >= sizeof(GNSSbuf) - 1) break;
GNSSbuf[i++] = c;
} else {
/* ignore */
continue;
}

if (c == '\n') break;
}

GNSSbuf[i] = 0;

size_t len = strlen((char *) &GNSSbuf[0]);

if (len > 14) {
for (int i=14; i < len; i++) {
if (GNSSbuf[i] == '*') {
GNSSbuf[i] = 0;
}
}
Serial.print(F("INFO: GNSS module FW version: "));
Serial.println((char *) &GNSSbuf[14]);
}

delay(250);
#endif

/*
* Factory default:
* $CFGSYS,H35155 = GPS + BDS + GLO + GAL + QZSS + SBAS
* $CFGTP,1000000,500000,1,0,0,0 = PPS is enabled, 500 ms pulse, 1 s interval
*/
Serial_GNSS_Out.write("$CFGMSG,0,2,0\r\n"); delay(250); /* GSA off */
Serial_GNSS_Out.write("$CFGMSG,0,3,0\r\n"); delay(250); /* GSV off */

return true;
}

static void uc65_loop()
{

}

static void uc65_fini()
{

}

const gnss_chip_ops_t uc65_ops = {
uc65_probe,
uc65_setup,
uc65_loop,
uc65_fini,
0 /* GGA */, 0 /* RMC */
};
#endif /* EXCLUDE_GNSS_UC65 */

static bool GNSS_fix_cache = false;

bool isValidGNSSFix()
Expand All @@ -1081,7 +1165,8 @@ byte GNSS_setup() {
hw_info.model == SOFTRF_MODEL_LEGO ||
hw_info.model == SOFTRF_MODEL_ES ||
hw_info.model == SOFTRF_MODEL_BALKAN ||
hw_info.model == SOFTRF_MODEL_HAM)
hw_info.model == SOFTRF_MODEL_HAM ||
hw_info.model == SOFTRF_MODEL_MIDI)
{
// power on by wakeup call
Serial_GNSS_Out.write((uint8_t) 0); GNSS_FLUSH(); delay(500);
Expand Down Expand Up @@ -1144,6 +1229,10 @@ byte GNSS_setup() {
gnss_id = gnss_id == GNSS_MODULE_NMEA ?
(gnss_chip = &at65_ops, gnss_chip->probe()) : gnss_id;
#endif /* EXCLUDE_GNSS_AT65 */
#if !defined(EXCLUDE_GNSS_UC65)
gnss_id = gnss_id == GNSS_MODULE_NMEA ?
(gnss_chip = &uc65_ops, gnss_chip->probe()) : gnss_id;
#endif /* EXCLUDE_GNSS_UC65 */

gnss_chip = gnss_id == GNSS_MODULE_NMEA ? &generic_nmea_ops : gnss_chip;

Expand Down
3 changes: 2 additions & 1 deletion software/firmware/source/SkyWatch/GNSSHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ typedef enum
GNSS_MODULE_SONY, /* S7XG */
GNSS_MODULE_AT65, /* AT6558 */
GNSS_MODULE_MT33, /* L80 */
GNSS_MODULE_GOKE /* Air530 */
GNSS_MODULE_GOKE, /* Air530 */
GNSS_MODULE_UC65, /* Unicore FirebirdII UC6580 */
} gnss_id_t;

typedef struct gnss_chip_ops_struct {
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyWatch/Platform_ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ extern PCF8563_Class *rtc;
#define EXCLUDE_GNSS_GOKE
#define EXCLUDE_GNSS_AT65
#define EXCLUDE_GNSS_SONY
#define EXCLUDE_GNSS_UC65
#define EXCLUDE_LOG_GNSS_VERSION
#endif /* CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 */

Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyWatch/SkyWatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ enum
SOFTRF_MODEL_PRIME_MK3,
SOFTRF_MODEL_BALKAN,
SOFTRF_MODEL_HAM,
SOFTRF_MODEL_MIDI,
};

enum
Expand Down

0 comments on commit 0a2819b

Please sign in to comment.