void gpsTask(void *unused) { gpsData.serial = serialOpen(USART1, 9600); gpsData.mode = MODE_NMEA; // NMEA while (1) { CoTickDelay(25); while (uartAvailable(gpsData.serial)) { switch (gpsData.mode) { case MODE_NMEA: // NMEA gpsData.validFrames += gpsNewFrameNMEA(uartRead(gpsData.serial)); break; case MODE_UBX: // UBX gpsData.validFrames += gpsNewFrameUBLOX(uartRead(gpsData.serial)); break; case MODE_MTK: // MTK break; case MODE_PASSTHROUGH: // GPS -> UART bridge // TODO // usbSerialWrite(uartRead(gpsData.serial)); break; } } } }
bool gpsNewFrame(uint8_t c) { switch (gpsConfig()->provider) { case GPS_NMEA: // NMEA return gpsNewFrameNMEA(c); case GPS_UBLOX: // UBX binary return gpsNewFrameUBLOX(c); } return false; }
static bool gpsNewFrame(uint8_t c) { switch (mcfg.gps_type) { case GPS_NMEA: // NMEA case GPS_MTK_NMEA: // MTK in NMEA mode return gpsNewFrameNMEA(c); case GPS_UBLOX: // UBX binary return gpsNewFrameUBLOX(c); case GPS_MTK_BINARY: // MTK in BINARY mode (TODO) return false; } return false; }
static bool gpsReceiveData(void) { bool hasNewData = false; if (gpsState.gpsPort) { while (serialRxBytesWaiting(gpsState.gpsPort)) { uint8_t newChar = serialRead(gpsState.gpsPort); if (gpsNewFrameNMEA(newChar)) { gpsSol.flags.gpsHeartbeat = !gpsSol.flags.gpsHeartbeat; gpsSol.flags.validVelNE = 0; gpsSol.flags.validVelD = 0; hasNewData = true; } } } return hasNewData; }