GPS support via MSP

This commit is contained in:
Alex Wolf 2018-08-07 21:06:54 -04:00
parent 946cbd257f
commit 92d3b7ca6f
3 changed files with 15 additions and 7 deletions

View File

@ -2027,7 +2027,7 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
gpsSol.llh.lon = sbufReadU32(src);
gpsSol.llh.alt = sbufReadU16(src) * 100; // alt changed from 1m to 0.01m per lsb since MSP API 1.39 by RTH. Received MSP altitudes in 1m per lsb have to upscaled.
gpsSol.groundSpeed = sbufReadU16(src);
GPS_update |= 2; // New data signalisation to GPS functions // FIXME Magic Numbers
GPS_update |= GPS_MSP_UPDATE; // MSP data signalisation to GPS functions
break;
#endif // USE_GPS
case MSP_SET_FEATURE_CONFIG:

View File

@ -98,7 +98,7 @@ static uint16_t fraction3[2];
gpsSolutionData_t gpsSol;
uint32_t GPS_packetCount = 0;
uint32_t GPS_svInfoReceivedCount = 0; // SV = Space Vehicle, counter increments each time SV info is received.
uint8_t GPS_update = 0; // it's a binary toggle to distinct a GPS position update
uint8_t GPS_update = 0; // toogle to distinct a GPS position update (directly or via MSP)
uint8_t GPS_numCh; // Number of channels
uint8_t GPS_svinfo_chn[GPS_SV_MAXSATS]; // Channel number
@ -492,6 +492,12 @@ void gpsUpdate(timeUs_t currentTimeUs)
if (gpsPort) {
while (serialRxBytesWaiting(gpsPort))
gpsNewData(serialRead(gpsPort));
} else if (GPS_update & GPS_MSP_UPDATE) { // GPS data received via MSP
gpsSetState(GPS_RECEIVING_DATA);
gpsData.lastMessage = millis();
sensorsSet(SENSOR_GPS);
onGpsNewData();
GPS_update &= ~GPS_MSP_UPDATE;
}
switch (gpsData.state) {
@ -547,10 +553,7 @@ static void gpsNewData(uint16_t c)
gpsData.lastMessage = millis();
sensorsSet(SENSOR_GPS);
if (GPS_update == 1)
GPS_update = 0;
else
GPS_update = 1;
GPS_update ^= GPS_DIRECT_TICK;
#if 0
debug[3] = GPS_update;

View File

@ -137,10 +137,15 @@ typedef enum {
} navigationMode_e;
extern navigationMode_e nav_mode; // Navigation mode
typedef enum {
GPS_DIRECT_TICK = 1 << 0,
GPS_MSP_UPDATE = 1 << 1
} gpsUpdateToggle_e;
extern gpsData_t gpsData;
extern gpsSolutionData_t gpsSol;
extern uint8_t GPS_update; // it's a binary toogle to distinct a GPS position update
extern uint8_t GPS_update; // toogle to distinct a GPS position update (directly or via MSP)
extern uint32_t GPS_packetCount;
extern uint32_t GPS_svInfoReceivedCount;
extern uint8_t GPS_numCh; // Number of channels